public Login() { InitializeComponent(); this.KeyPreview = true; this.KeyPress += Comdata.textBox_KeyPressDBC; //textBox1.KeyPress += Comdata.textBox_KeyPressDBC; //textBox2.KeyPress += Comdata.textBox_KeyPressDBC; #if ALONE button2.Visible = false; button1.Location = new System.Drawing.Point(100, 161); #else #endif ///读取上次记录的账户密码 if (iniLogin.Read()) { textBox1.Text = iniLogin.FileObj.id; textBox2.Text = iniLogin.FileObj.psw; } //////////////////读取打印机信息///////////////// Comdata.iniPrint.Read(); //////////////////读取服务器配置///////////////// if (!Mysqlcom.ServerSet.Read()) { Form3 f3 = new Form3(); f3.ShowDialog(); } //////////////////读取洗衣店信息///////////////// if (!Comdata.iniShop.Read()) { CreateShop cs = new CreateShop(); cs.ShowDialog(); } this.Font = new System.Drawing.Font("宋体", Comdata.iniShop.FileObj.font_size); }
/// <summary> /// 登录按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "") return; if (Mysqlcom.Myopen()) return; #if !ALONE ////////////////获取所有店铺, 没有则打开创建店铺界面 Comdata.AllShop = sql.Shop.GetAll(); if (Comdata.AllShop == null || Comdata.AllShop.Rows.Count==0) { CreateShop cs = new CreateShop(); cs.ShowDialog(); return; } ///////获取店铺id int Sind = 0; for (; Sind < Comdata.AllShop.Rows.Count; Sind++) { if (Comdata.iniShop.FileObj.name == (string)Comdata.AllShop.Rows[Sind][wa_shop.SHname]) break; } /////没有则打开创建店铺界面 if (Sind >= Comdata.AllShop.Rows.Count) { CreateShop cs = new CreateShop(); cs.ShowDialog(); return; } Comdata.shopnum = (int)Comdata.AllShop.Rows[Sind][wa_shop.SHID]; #endif ///验证用户名和密码 Mwa_login loginM=sql.User.GetByIdPw(textBox1.Text, textBox2.Text); if (loginM==null) { MessageBox.Show("帐号或密码错误!", "错误"); return; } Comdata.loginsuc = true; Comdata.loginid = textBox1.Text; Comdata.logindata = loginM.logdate; Comdata.team = loginM.team; //记录账户密码 if (checkBox1.Checked) { iniLogin.FileObj.id = textBox1.Text; iniLogin.FileObj.psw = textBox2.Text; iniLogin.Write(); } //更新登录日期和ip sql.User.UpdateId(loginM.UID, DateTime.Now.ToString(), Comdata.GetIP()); //////////获取所有服务 Comdata.AllServer = sql.Server.GetAll(); this.Close(); }