private void button_Click(object sender, RoutedEventArgs e) { if (c == 1) { if (AddTo.a != "" && AddTo.b != "") { using (var con = new UserEntities8()) { Admin ad = new Admin() { adminInfo = AddTo.a, password = AddTo.b }; try { con.Admin.Add(ad); con.SaveChanges(); MessageBox.Show("注册成功!"); } catch (Exception ex) { MessageBox.Show(ex.Message + "添加失败!"); } } } else { MessageBox.Show("所填内容不能为空!"); } } if (c == 2) { using (var con = new UserEntities8()) { var q1 = from t in con.Admin where t.adminInfo.Equals(AdEnter.a) == true && t.password.Equals(AdEnter.b) == true select t; if (q1.Count() != 0) { User.UserGoing us = new User.UserGoing(); us.Show(); this.Close(); } else { MessageBox.Show("登录失败\n输入有错误!或所填内容有空!"); } } } }
private void Button_Click(object sender, RoutedEventArgs e) { using (var con = new UserEntities8()) { var q1 = from t in con.Admin where t.adminInfo.Equals(t1.Text) == true && t.password.Equals(p2.Password) == true select t; if (q1.Count() != 0) { User.UserGoing us = new User.UserGoing(); us.Show(); this.Close(); } else { MessageBox.Show("登录失败\n输入有错误!或所填内容有空!"); } } }