private void Buttonz_Click(object sender, RoutedEventArgs e) { try { int index = (dataGrid.SelectedItem as AdminTable).Id; string account__ = (dataGrid.SelectedItem as AdminTable).account; string password__ = (dataGrid.SelectedItem as AdminTable).password; // MessageBox.Show(account__+" "+password__); string account_ = AccountTextBox.Text; string password_ = PasswordTextBox.Text; if (account_ == "" || account_ == null || password_ == "" || password_ == null) { modify_fail(); return; } var c = new DormEntities(); var query = from t in c.AdminTable where (t.account == account__ && t.password == password__) select t; int temp = query.Count(); if (query.Count() > 0) { query.First <AdminTable>().account = account_; query.First <AdminTable>().password = password_; c.SaveChanges(); modify_ok(); } var q = from t in c.AdminTable select t; dataGrid.ItemsSource = q.ToList(); } catch (Exception) { MessageBoxz.ShowWarning("请选择一个管理员"); //throw; } //var c = new DormEntities(); //var q = from t in c.AdminTable select t; //int count = q.Count(); //AdminTable adminTable = new AdminTable //{ // Id = count + 1, // account = account_, // password = password_ //}; //c.AdminTable.Add(adminTable); //c.SaveChanges(); // showAdmin(); //modify_ok(); }
public void modify_show(string name) { // MessageBox.Show(name); var c = new DormEntities(); var q = from t in c.AdminTable where (t.account == name) select t; string idCard = this.IdCardBox.Text; string password_ = PasswordBox.Password; string password2_ = PasswordBox2.Password; if (password2_ != password_) { MessageBoxz.ShowWarning("两次密码不一致,"); return; } if (q.Count() > 0) { //说明有该用户 var q2 = from t in c.AdminTable where (t.account == name && t.idCard == idCard) select t; // MessageBox.Show(name+idCard); if (q2.Count() == 1) { q2.First <AdminTable>().password = password_; } c.SaveChanges(); MessageBoxz.ShowInfo("密码修改成功"); this.Close(); } }
private void fill_fail() { MessageBoxz.ShowWarning("用户名和密码不能为空!"); }
private void btn_add_Click(object sender, RoutedEventArgs e) { string account_ = AccountTextBox.Text; string password_ = PasswordTextBox.Text; string sex_ = sex.Text; string telphone_ = telphone.Text; string idCard_ = idcard.Text; if (account_ == "" || account_ == null || password_ == "" || password_ == null) { fill_fail(); return; } var c = new DormEntities(); var query = from t in c.AdminTable where (t.account == account_ & t.password == password_) select t; if (query.Count() > 0) { MessageBoxz.ShowInfo("该用户名已经被注册"); } else { //可以注册 if (account_ == "" || account_ == null || password_ == "" || password_ == null || sex_ == "" || sex_ == null || telphone_ == "" || telphone_ == null || idCard_ == "" || idcard == null) { MessageBoxz.ShowWarning("信息填写不完整!"); return; } if (telphone_.Length != 11) { MessageBoxz.ShowWarning("手机号格式不正确!"); return; } if (idCard_.Length != 18) { MessageBoxz.ShowWarning("身份证号格式不正确!"); return; } int count = c.AdminTable.Select(p => p.Id).ToList().Max(); if (path == "") { BitmapImage img = new BitmapImage(new Uri(@"\Resources\icoFiles\moren.png", UriKind.Relative)); byte[] bt = BitmapImageToByteArray(img); AdminTable adminTable = new AdminTable { Id = count + 1, account = account_, password = password_, sex = sex_, telphone = telphone_, idCard = idCard_, photo = bt }; c.AdminTable.Add(adminTable); c.SaveChanges(); MessageBoxz.ShowInfo("恭喜您,注册新用户成功"); this.Close(); } else { System.IO.Stream mystream = ofd.OpenFile(); byte[] bt = new byte[mystream.Length]; mystream.Read(bt, 0, (int)mystream.Length); AdminTable adminTable = new AdminTable { Id = count + 1, account = account_, password = password_, sex = sex_, telphone = telphone_, idCard = idCard_, photo = bt }; c.AdminTable.Add(adminTable); c.SaveChanges(); MessageBoxz.ShowInfo("恭喜您,注册新用户成功"); this.Close(); } } }
private void FButton_Click_Warning(object sender, RoutedEventArgs e) { MessageBoxz.ShowWarning("架构之美、数学之美、.net 核心框架、异步编程的艺术、单元测试的艺术,代码,WPF"); }