private void button1_Click(object sender, EventArgs e) { groupBox1.Enabled =false ; //配置文件读取类 Readfile.Readfile cfg = new Readfile.Readfile(); button1.Enabled = false; //检验用户名和密码 string user=cfg.GetConfig(Application.StartupPath + "/DB/PWD.mdb", "username"); string pwd = cfg.GetConfig(Application.StartupPath + "/DB/PWD.mdb", "userpassword"); if (GetMd6Str(textBox1.Text) == user && GetMd6Str(textBox2.Text) == pwd) { this.Focus(); //改变鼠标形状 this.Cursor = System.Windows.Forms.Cursors.WaitCursor; progressBar1.Visible = true; button1.Visible = false; timer1.Enabled = true; backgroundWorker1.RunWorkerAsync(); speaker.speak("登陆成功;请稍后"); if (cfg.GetConfig(Application.StartupPath + "/config.inc", "dbroot") == "null") { mainform.db.query("create database DB"); mainform.db.query("use DB"); mainform.db.query("create table `book` (`id` key,`booktitle` text,`description` text,`writer` int,`publisher` text,`type` text,`store` int,`nums` int)"); mainform.db.query("create table `lendinfo` (`id` key,`bookid` int,`readerid` int)"); //mainform.db.query("create table `writer` (`wid` key,`name` text,`sex` text,`description` text)"); mainform.db.query("create table `reader` (`sid` key,`name` text,`sex` text,`maxnum` int,`lending` int,`owe` double)"); //mainform.db.query("create table `publisher` (`pid` key,`booktitle` text,`publisher` text,`type` text,`writer` text,`maxnums` int,`lendnums` int)"); cfg.AddDetail(Application.StartupPath + "/config.inc", "dbroot"); } } else { label3.Text = "用户名或密码错误"; speaker.speak("用户名或密码错误;请重新输入"); timer2.Enabled = true; } }
//+++++++++++++++++++++ private void setdefault() { //默认值的取得 Readfile.Readfile rf = new Readfile.Readfile(); if (groupBox1.Text == "用户配额") { if (cell.usertype == "教师") { water.Text = "0"; elec.Text = "0"; gas.Text = "0"; } else { water.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "waterlimit"); elec.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "eleclimit"); gas.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "gaslimit"); } } if (groupBox1.Text == "单价") { if (cell.usertype == "教师") { water.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "watertc"); elec.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "electc"); gas.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "gastc"); } else { water.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "waterst"); elec.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "elecst"); gas.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "gasst"); } } //rf.GetConfig(); /*water.Text = data[0]; * elec.Text = data[1]; * gas.Text = data[2]; * */ }
private void button1_Click(object sender, EventArgs e) { groupBox1.Enabled = false; //配置文件读取类 Readfile.Readfile cfg = new Readfile.Readfile(); button1.Enabled = false; //检验用户名和密码 string user = cfg.GetConfig(Application.StartupPath + "/DB/PWD.mdb", "username"); string pwd = cfg.GetConfig(Application.StartupPath + "/DB/PWD.mdb", "userpassword"); if (GetMd6Str(textBox1.Text) == user && GetMd6Str(textBox2.Text) == pwd) { this.Focus(); //改变鼠标形状 this.Cursor = System.Windows.Forms.Cursors.WaitCursor; progressBar1.Visible = true; button1.Visible = false; timer1.Enabled = true; backgroundWorker1.RunWorkerAsync(); speaker.speak("登陆成功;请稍后"); if (cfg.GetConfig(Application.StartupPath + "/config.inc", "dbroot") == "null") { mainform.db.query("create database DB"); mainform.db.query("use DB"); mainform.db.query("create table `book` (`id` key,`booktitle` text,`description` text,`writer` int,`publisher` text,`type` text,`store` int,`nums` int)"); mainform.db.query("create table `lendinfo` (`id` key,`bookid` int,`readerid` int)"); //mainform.db.query("create table `writer` (`wid` key,`name` text,`sex` text,`description` text)"); mainform.db.query("create table `reader` (`sid` key,`name` text,`sex` text,`maxnum` int,`lending` int,`owe` double)"); //mainform.db.query("create table `publisher` (`pid` key,`booktitle` text,`publisher` text,`type` text,`writer` text,`maxnums` int,`lendnums` int)"); cfg.AddDetail(Application.StartupPath + "/config.inc", "dbroot"); } } else { label3.Text = "用户名或密码错误"; speaker.speak("用户名或密码错误;请重新输入"); timer2.Enabled = true; } }
private void button1_Click(object sender, EventArgs e) { groupBox1.Enabled = false; //配置文件读取类 Readfile.Readfile cfg = new Readfile.Readfile(); button1.Enabled = false; //检验用户名和密码 string user = cfg.GetConfig(Application.StartupPath + "/Database/PWD.mdb", "username"); string pwd = cfg.GetConfig(Application.StartupPath + "/Database/PWD.mdb", "userpassword"); if (GetMd6Str(textBox1.Text) == user && GetMd6Str(textBox2.Text) == pwd) { this.Focus(); //改变鼠标形状 this.Cursor = System.Windows.Forms.Cursors.WaitCursor; progressBar1.Visible = true; button1.Visible = false; timer1.Enabled = true; backgroundWorker1.RunWorkerAsync(); //启用socket if (cfg.GetConfig(Application.StartupPath + "/config.ini", "enable") == "true") { sck sock = new sck(); //读取线程数量 sock.listen(int.Parse(cfg.GetConfig(Application.StartupPath + "/config.ini", "ThreadNum")), int.Parse(cfg.GetConfig(Application.StartupPath + "/config.ini", "port"))); } else { server.text = "未开启后台服务"; } } else { label3.Text = "用户名或密码错误"; timer2.Enabled = true; } }
private void button1_Click(object sender, EventArgs e) { groupBox1.Enabled =false ; //配置文件读取类 Readfile.Readfile cfg = new Readfile.Readfile(); button1.Enabled = false; //检验用户名和密码 string user=cfg.GetConfig(Application.StartupPath + "/Database/PWD.mdb", "username"); string pwd = cfg.GetConfig(Application.StartupPath + "/Database/PWD.mdb", "userpassword"); if (GetMd6Str(textBox1.Text) == user && GetMd6Str(textBox2.Text) == pwd) { this.Focus(); //改变鼠标形状 this.Cursor = System.Windows.Forms.Cursors.WaitCursor; progressBar1.Visible = true; button1.Visible = false; timer1.Enabled = true; backgroundWorker1.RunWorkerAsync(); //启用socket if(cfg.GetConfig(Application.StartupPath + "/config.ini", "enable")=="true") { sck sock = new sck(); //读取线程数量 sock.listen(int.Parse(cfg.GetConfig(Application.StartupPath + "/config.ini", "ThreadNum")), int.Parse(cfg.GetConfig(Application.StartupPath + "/config.ini", "port"))); } else { server.text="未开启后台服务";} } else { label3.Text = "用户名或密码错误"; timer2.Enabled = true; } }
static private void ls() { string GET, data; string[] result; TcpClient client = listener.AcceptTcpClient(); //创建网络流 NetworkStream netStream = client.GetStream(); StreamReader sr = new StreamReader(client.GetStream()); //读取第一行的东西然后关闭sr GET = sr.ReadLine().ToString(); Console.Write("\r\n"); Console.Write(GET); StreamWriter sw = new StreamWriter(client.GetStream()); Readfile.Readfile rf = new Readfile.Readfile(); result = GET.Split(' '); //sw.Write("HTTP/1.1 200 OK\r\n"); if (result[1] == "") { ; } if (result[1] == "/" | result[1] == "/index.html") { //显示首页 // StreamReader fsr = new StreamReader(binpath + "/UserData/default.dba"); while (fsr.EndOfStream == false) { sw.Write(fsr.ReadLine().ToString()); } fsr.Close(); sw.Close(); sr.Close(); netStream.Close(); } else { try { //分离& string[] fs = result[1].Split('&'); //分离= string[] fr = fs[0].Split('='); if (fr[1].ToString() != "") { if (rf.Existen(binpath + "/UserData/wegDbfile-" + fr[1].ToString() + ".rdb")) { StreamReader fsr = new StreamReader(binpath + "/UserData/wegDbfile-" + fr[1].ToString() + ".rdb"); while (fsr.EndOfStream == false) { sw.Write(fsr.ReadLine().ToString()); } Console.Write("\r\n"); Console.Write(fr[1].ToString() + "数据发送成功"); fsr.Close(); sw.Close(); sr.Close(); netStream.Close(); } else { data = "<html><head><meta http-equiv=content-type content=\"text/html; charset=UTF-8\">数据不存在"; sw.Write(data); Console.Write("\r\n"); Console.Write("/UserData/wegDbfile-" + fr[1].ToString() + ".rdb"); Console.Write(fr[1].ToString() + "无此数据"); sw.Close(); sr.Close(); netStream.Close(); } } else { data = "<html><head><meta http-equiv=content-type content=\"text/html; charset=UTF-8\">数据不存在"; sw.Write(data); Console.Write("\r\n"); Console.Write(fr[1].ToString() + "数据发送失败"); sw.Close(); sr.Close(); netStream.Close(); } } catch { data = "<html><head><meta http-equiv=content-type content=\"text/html; charset=UTF-8\">数据不存在"; sw.Write(data); sw.Close(); sr.Close(); netStream.Close(); } //MessageBox.Show(data); } //此线程退出时创建新线程 Thread thrd = new Thread(new ThreadStart(ls)); thrd.IsBackground = false; thrd.Start(); }
private static void ls() { string GET,data; string[] result; TcpClient client = listener.AcceptTcpClient(); //创建网络流 NetworkStream netStream = client.GetStream(); StreamReader sr = new StreamReader(client.GetStream()); //读取第一行的东西然后关闭sr GET=sr.ReadLine().ToString(); Console.Write("\r\n"); Console.Write(GET); StreamWriter sw = new StreamWriter(client.GetStream()); Readfile.Readfile rf = new Readfile.Readfile(); result=GET.Split(' '); //sw.Write("HTTP/1.1 200 OK\r\n"); if (result[1] == "") { ; } if (result[1] == "/"|result[1] == "/index.html") { //显示首页 // StreamReader fsr = new StreamReader(binpath+"/UserData/default.dba"); while (fsr.EndOfStream == false) { sw.Write(fsr.ReadLine().ToString()); } fsr.Close(); sw.Close(); sr.Close(); netStream.Close(); } else { try {//分离& string[] fs = result[1].Split('&'); //分离= string[] fr = fs[0].Split('='); if (fr[1].ToString() != "") { if (rf.Existen(binpath+"/UserData/wegDbfile-" + fr[1].ToString() + ".rdb")) { StreamReader fsr = new StreamReader(binpath+"/UserData/wegDbfile-" + fr[1].ToString() + ".rdb"); while (fsr.EndOfStream == false) { sw.Write(fsr.ReadLine().ToString()); } Console.Write("\r\n"); Console.Write(fr[1].ToString()+"数据发送成功"); fsr.Close(); sw.Close(); sr.Close(); netStream.Close(); } else { data = "<html><head><meta http-equiv=content-type content=\"text/html; charset=UTF-8\">数据不存在"; sw.Write(data); Console.Write("\r\n"); Console.Write("/UserData/wegDbfile-" + fr[1].ToString() + ".rdb"); Console.Write(fr[1].ToString() + "无此数据"); sw.Close(); sr.Close(); netStream.Close(); } } else { data = "<html><head><meta http-equiv=content-type content=\"text/html; charset=UTF-8\">数据不存在"; sw.Write(data); Console.Write("\r\n"); Console.Write(fr[1].ToString() + "数据发送失败"); sw.Close(); sr.Close(); netStream.Close(); } } catch { data = "<html><head><meta http-equiv=content-type content=\"text/html; charset=UTF-8\">数据不存在"; sw.Write(data); sw.Close(); sr.Close(); netStream.Close(); } //MessageBox.Show(data); } //此线程退出时创建新线程 Thread thrd = new Thread(new ThreadStart(ls)); thrd.IsBackground = false; thrd.Start(); }
private void ls() { string GET,data; string[] result; TcpClient client = listener.AcceptTcpClient(); //���������� NetworkStream netStream = client.GetStream(); StreamReader sr = new StreamReader(client.GetStream()); //��ȡ��һ�еĶ���Ȼ��ر�sr GET=sr.ReadLine().ToString(); StreamWriter sw = new StreamWriter(client.GetStream()); Readfile.Readfile rf = new Readfile.Readfile(); result=GET.Split(' '); //sw.Write("HTTP/1.1 200 OK\r\n"); if (result[1] == "") { ; } if (result[1] == "/"|result[1] == "/index.html") { //��ʾ��ҳ // StreamReader fsr = new StreamReader(Application.StartupPath + "/UserData/default.dba"); while (fsr.EndOfStream == false) { sw.Write(fsr.ReadLine().ToString()); } fsr.Close(); sw.Close(); sr.Close(); netStream.Close(); } else { try {//����& string[] fs = result[1].Split('&'); //����= string[] fr = fs[0].Split('='); if (fr[1].ToString() != "") { if (rf.Existen(Application.StartupPath + "/UserData/wegDbfile-" + fr[1].ToString() + ".rdb")) { StreamReader fsr = new StreamReader(Application.StartupPath + "/UserData/wegDbfile-" + fr[1].ToString() + ".rdb"); while (fsr.EndOfStream == false) { sw.Write(fsr.ReadLine().ToString()); } fsr.Close(); sw.Close(); sr.Close(); netStream.Close(); } else { data = "<html><head><meta http-equiv=content-type content=\"text/html; charset=UTF-8\">���ݲ�����"; sw.Write(data); sw.Close(); sr.Close(); netStream.Close(); } } else { data = "<html><head><meta http-equiv=content-type content=\"text/html; charset=UTF-8\">���ݲ�����"; sw.Write(data); sw.Close(); sr.Close(); netStream.Close(); } } catch { data = "<html><head><meta http-equiv=content-type content=\"text/html; charset=UTF-8\">���ݲ�����"; sw.Write(data); sw.Close(); sr.Close(); netStream.Close(); } //MessageBox.Show(data); } //���߳��˳�ʱ�������߳� Thread thrd = new Thread(new ThreadStart(this.ls)); thrd.IsBackground = true; thrd.Start(); }
//+++++++++++++++++++++ private void setdefault() { //默认值的取得 Readfile.Readfile rf = new Readfile.Readfile(); if (groupBox1.Text == "用户配额") { if (cell.usertype == "教师") { water.Text = "0"; elec.Text = "0"; gas.Text = "0"; } else { water.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "waterlimit"); elec.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "eleclimit"); gas.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "gaslimit"); } } if (groupBox1.Text == "单价") { if (cell.usertype == "教师") { water.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "watertc"); elec.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "electc"); gas.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "gastc"); } else { water.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "waterst"); elec.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "elecst"); gas.Text = rf.GetConfig(Application.StartupPath + "/config.ini", "gasst"); } } //rf.GetConfig(); /*water.Text = data[0]; elec.Text = data[1]; gas.Text = data[2]; * */ }