private void idcardinfo_OnIDCardReceived(string xm, string sfzhm) { groupBox1.Enabled = true; pictureBox1.ImageLocation = "photo.bmp"; textBox1.Focus(); CMyGlobal.G_Loging_Sfzhm = string.Empty; CMyGlobal.G_Loging_Username = string.Empty; isidcard = true; DataRow[] drs = ds.Tables[0].Select("idcardnumber='" + MD5.md5(sfzhm.Trim().Substring(0, sfzhm.Length - 2) + "liuying") + "'"); if (drs.Length > 0) { // dq_sfzhm = MD5.md5(sfzhm.Trim().Substring(0, sfzhm.Length - 2) + "liuying"); if (this.InvokeRequired) { CMyGlobal.G_Loging_Sfzhm = sfzhm; CMyGlobal.G_Loging_Username = xm; CMyGlobal.G_UserClass = (int)drs[0]["class"]; CMyGlobal.G_DBMyorder = (int)drs[0]["myorder"]; this.Invoke(new InvokeDelegate(invokeformfun), drs[0]["username"].ToString(), drs[0]["password"].ToString().Trim()); } else { CMyGlobal.G_Loging_Sfzhm = sfzhm; CMyGlobal.G_Loging_Username = xm; CMyGlobal.G_UserClass = (int)drs[0]["class"]; CMyGlobal.G_DBMyorder = (int)drs[0]["myorder"]; groupBox1.Enabled = true; textBox1.Text = drs[0]["username"].ToString().Trim(); CMyGlobal.G_Loging_Password = drs[0]["password"].ToString().Trim(); } } }
private void button1_Click(object sender, EventArgs e) //添加用户 { if (textBox_passwd.Text != textBox_rpasswd.Text) { MessageBox.Show("两次密码输入不一致!"); textBox_passwd.Focus(); return; } if (label_xm.Text != string.Empty && label_sfzhm.Text != string.Empty) { DataRow dr = ds.Tables[0].NewRow(); dr["username"] = label_xm.Text.Trim(); dr["idcardnumber"] = MD5.md5(label_sfzhm.Text + "liuying"); dr["password"] = textBox_passwd.Text.Trim(); dr["class"] = Convert.ToInt16(domainUpDown_class.Text); if (textBox_nicheng.Text == string.Empty) { dr["nickname"] = label_xm.Text.Trim(); } else { dr["nickname"] = textBox_nicheng.Text.Trim(); } ds.Tables[0].Rows.Add(dr); ad.Update(ds); label_xm.Text = string.Empty; label_sfzhm.Text = string.Empty; textBox_passwd.Text = string.Empty; textBox_rpasswd.Text = string.Empty; } else { DataRow dr = ds.Tables[0].NewRow(); if (textBox_nicheng.Text == string.Empty) { MessageBox.Show("不用身份证登记,警号不能为空!"); return; } else { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["nickname"].ToString().Trim() == textBox_nicheng.Text.Trim()) { MessageBox.Show("数据库里已有此警号,请重新选择警号!"); textBox_nicheng.Focus(); return; } } dr["nickname"] = textBox_nicheng.Text.Trim(); } dr["password"] = textBox_passwd.Text.Trim(); if (Convert.ToInt16(domainUpDown_class.Text) < 3) { MessageBox.Show("不用身份证登记,不能创建权限级别小于3的用户!"); return; } else { dr["class"] = Convert.ToInt16(domainUpDown_class.Text); } ds.Tables[0].Rows.Add(dr); ad.Update(ds); textBox_nicheng.Text = string.Empty; label_xm.Text = string.Empty; label_sfzhm.Text = string.Empty; textBox_passwd.Text = string.Empty; textBox_rpasswd.Text = string.Empty; } }