/// <summary> /// 修改密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e1) { //Console.WriteLine(user); if (Old_Key.Text != user.Key) { MessageBox.Show("旧密码错误!", "⚠警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); } else if (New_Key.Text != Right_Key.Text) { MessageBox.Show("输入密码不一致!", "⚠警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); } else { try { DAL.UserDB userDB = new DAL.UserDB(); userDB.ChangeKey(user.UserName, New_Key.Text); MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK); this.Close(); } catch (Exception e) { MessageBox.Show("发生未知错误!" + e.ToString(), "⚠警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); MOD.Data.WriteLog("密码修改失败!" + e.Message.ToString(), 1); } } }
private void 密码ToolStripMenuItem_Click(object sender, EventArgs e) { DAL.UserDB userDB = new DAL.UserDB(); ChangeKey changeKey = new ChangeKey(Data.User); changeKey.Show(); }
private void button1_Click(object sender, EventArgs e1) { double[] data = new double[6]; int a = 0; TextBox textBox; foreach (Control control in groupBox1.Controls) { if (control.GetType().ToString() == "System.Windows.Forms.TextBox") { textBox = (TextBox)control; data[a] = Convert.ToDouble(textBox.Text); a++; } } try { ///用户注册 MOD.User user = new MOD.User(UserName_box.Text, Key1_box.Text, Number_box.Text, where_box.Text); DAL.UserDB userDB = new DAL.UserDB(); if (userDB.SelectUser(user.UserName) != null) { MessageBox.Show("该用户已存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else if (Key1_box.Text != Key2.Text) { MessageBox.Show("两次输入密码不一致!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else if (data[0] > data[1] || data[2] > data[3] || data[4] > data[5]) { MessageBox.Show("土壤数据范围逻辑错误!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else if (userDB.AddUser(user) != 0) { ///预警数据设置 for (int i = 0; i < 6; i++) { MOD.Data.Data_Soil[i] = data[i]; } DAL.SoilDataDB soilDataDB = new DAL.SoilDataDB(); soilDataDB.add(new MOD.Soil(data, textBox1.Text), UserName_box.Text); MessageBox.Show("注册成功!", "提示", MessageBoxButtons.OK); this.Close(); } //添加SoilData } catch (Exception e) { MessageBox.Show("注册失败!" + e.ToString()); } }
/// <summary> /// 登录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e1) { this.Cursor = Cursors.WaitCursor; try { string name = ID_box.Text; string key = key_box.Text; DAL.UserDB userDB = new DAL.UserDB(); MOD.User user = userDB.SelectUser(name); if (user != null) { if (user.Key == key) { MOD.Data.User = user; Data.gatdata(); Data.Login_1 = true; Main main = new Main(); main.yonghu_ToolStripMenuItem.Text = user.UserName; main.Show(); Data.WriteLog(user.UserName + " 登录成功!", 0); this.Hide(); } else { MessageBox.Show("用户名或密码错误!", "提示"); this.Cursor = Cursors.Default; Data.WriteLog(user.UserName + " 登录失败!", 0); } } else { MessageBox.Show("尚未注册该用户!", "提示"); this.Cursor = Cursors.Default; } } catch (Exception e) { MessageBox.Show("请确保网络畅通!", "温馨提示"); Data.WriteLog(e.Message.ToString(), 1); this.Cursor = Cursors.Default; } }