-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1Class.cs
More file actions
59 lines (53 loc) · 1.55 KB
/
Copy pathForm1Class.cs
File metadata and controls
59 lines (53 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Net;
using System.Net.Mail;
using System.Speech.Synthesis;
using AntdUI;
using MySql.Data.MySqlClient;
namespace _012;
public class Form1Class
{
//用户名和密码框重置按钮
public static void ReSet(Input label1, Input label2)
{
label1.Text = "";
label2.Text = "";
}
//获取数据库中的用户名
public static List<string> GetUserAccount()
{
//创建列表保存数据
List<string> userAccount = new List<string>();
try
{
using (MySqlConnection connect = new MySqlConnection(Form1.ConnectCfg)){
connect.Open();
MySqlCommand command = new MySqlCommand("select uname from user_info", connect);
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
userAccount.Add(reader.GetString("uname"));
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
MessageBox.Show("服务器连接异常");
}
return userAccount;
}
//语音播报
public static void Speak(string text)
{
//创建语音对象
SpeechSynthesizer synth = new SpeechSynthesizer();
//设置语音播报速度
synth.Rate = 0;
//设置语音播报音量
synth.Volume = 100;
//设置语音播报语言
synth.SetOutputToDefaultAudioDevice();
//语音播报
synth.Speak(text);
}
}