private void button1_Click(object sender, RoutedEventArgs e) { using (var context = new MyDbEntities2()) { var q = from t1 in context.Client where t1.YongHuMing == username.Text select t1; if (q.Count() >= 1) { MessageBox.Show("用户名已存在,请直接登陆!"); return; } } DateTime date = DateTime.Now; using (var context = new MyDbEntities2()) { Client client = new Client() { YongHuMing = username.Text, XingMing = name.Text, PassWord = passwordBox.Password, Identify = identify.Text, Tel = telephone.Text, Date = date, YuE = 0 }; try { context.Client.Add(client); context.SaveChanges(); } catch (Exception ex) { MessageBox.Show("信息不合法!"); } Ticket t = new Ticket(); t.YongHuMing = username.Text; t.Password = passwordBox.Password; t.Time = DateTime.Now; try { context.Ticket.Add(t); context.SaveChanges(); MessageBox.Show("创建成功,请登录!"); } catch (Exception ee) { MessageBox.Show(ee.Message + " ticket"); } } }
private void Button_OK_Click(object sender, RoutedEventArgs e) { bool flag = false; using (var context = new MyDbEntities2()) { var q = from t in context.Client where t.YongHuMing == textBox1.Text select t; if (q.Count() == 0) { MessageBox.Show("该用户没有注册!"); return; } foreach (var v in q) { if (v.PassWord.Equals(passwordBox.Password)) { flag = true; } break; } if (!flag) { MessageBox.Show("密码错误,请重新输入"); return; } foreach (var v in q) { if (v.YuE > 0) { MessageBox.Show("您家有米,不许删除!"); return; } context.Client.Remove(v); break; } var q1 = from t in context.Ticket where t.YongHuMing == textBox1.Text select t; foreach (var v in q1) { context.Ticket.Remove(v); break; } context.SaveChanges(); MessageBox.Show("删除成功!"); } }
private void button_Click(object sender, RoutedEventArgs e) { using (var context = new MyDbEntities2()) { var q = from t in context.Manager where t.GuanLiYuanID == textBox.Text && t.password == passwordBox.Password select t; if (q.Count() >= 1) { Management ma = new Management(); this.Close(); ma.Show(); } else { MessageBox.Show("不存在此管理员"); } } }
public ShowTable() { InitializeComponent(); using (var context = new MyDbEntities2()) { var q = from t in context.Client select new { 用户名 = t.YongHuMing, 姓名 = t.XingMing, 省份证号 = t.Identify, 手机号 = t.Tel, 账户余额 = t.YuE, 开户日期 = t.Date, 密码 = t.PassWord }; dataGrid.ItemsSource = q.ToList(); var q1 = from t in context.Company select new { 账户 = t.ZhanghuId, 余额 = t.YuE, 更改日期 = t.Modifydate, 收入或支出 = t.Addordec, 更改的值 = t.Value, 来源账户 = t.Laiziyu }; dataGrid1.ItemsSource = q1.ToList(); var q2 = from t in context.Ticket select new { 用户名 = t.YongHuMing, 购票数量 = t.Num, 购票单价 = t.Cost, 目的地 = t.Destination }; dataGrid2.ItemsSource = q2.ToList(); } }
private void ButtonOK_Click(object sender, RoutedEventArgs e) { using (var context = new MyDbEntities2()) { var q1 = from t in context.Client where t.YongHuMing == this.YongHuMing select t; foreach (var v in q1) { label2.Content = v.YuE; break; } } MessageBox.Show("购票成功"); int num = 2; if (textblock1.Text.Equals("单程票")) { num = 1; } string str = textblock4.Text; string str1 = str.Substring(0, str.Length - 1); int money = int.Parse(str1); string str2 = textblock5.Text; string str3 = str.Substring(0, str.Length - 2); int number = int.Parse(str1); for (int i = 0; i < number; i++) { MyClass.my(textblock3.Text, money, num); } MainWindow ma = new MainWindow(); this.Close(); ma.ShowDialog(); }
public MessageWindow(string yonghuming) { InitializeComponent(); this.YongHuMing = yonghuming; using (var context = new MyDbEntities2()) { var q = from t in context.Ticket where t.YongHuMing == this.YongHuMing select t; foreach (var v in q) { textblock0.Text = v.YongHuMing; textblock1.Text = v.Issigle; textblock3.Text = v.Destination; textblock4.Text = v.Cost + "元"; textblock5.Text = v.Num + "张"; if (textblock1.Text.Equals("单程票")) { label1.Content = v.Num * v.Cost; } else { label1.Content = v.Num * v.Cost * 2; } //MessageBox.Show(v.Cost+"database "+v.Num); break; } var q1 = from t in context.Client where t.YongHuMing == this.YongHuMing select t; foreach (var v in q1) { //label2.Content = v.YuE; break; } } }
public DataUpClass(Ticket t, string yonghuming, string issingle, string start, string end, int price, int num, string password) { this.YongHuMing = yonghuming; this.issingle = issingle; this.start = start; this.end = end; this.price = price; this.num = num; this.Password = password; t.YongHuMing = this.YongHuMing; t.Issigle = issingle; t.StartP = start; t.Time = DateTime.Now; t.Cost = price; t.Num = num; t.Destination = end; using (var context = new MyDbEntities2()) { var q = from tt in context.Ticket where tt.YongHuMing == this.YongHuMing && tt.Password == this.Password select tt; if (q.Count() == 1) { foreach (var v in q) { v.Issigle = this.issingle; v.Num = this.num; v.Time = DateTime.Now; v.Destination = this.end; v.StartP = this.start; v.Cost = this.price; } } context.SaveChanges(); } }
private void Button_OK_Click(object sender, RoutedEventArgs e) { bool flag = false; using (var context = new MyDbEntities2()) { var q = from t in context.Client where t.YongHuMing == textBox1.Text select t; if (q.Count() == 0) { MessageBox.Show("该用户没有注册!"); return; } foreach (var v in q) { if (v.PassWord.Equals(passBox.Password)) { flag = true; } break; } if (!flag) { MessageBox.Show("密码错误,请重新输入"); return; } int num = 0; var q1 = from t1 in context.Company where t1.ZhanghuId == "0001" select t1; int coumt = q1.Count(); Company c = new Company(); c.Value = int.Parse(textBox3.Text); num = (int)c.Value; c.YuE += c.Value; c.Laiziyu = textBox1.Text; c.ZhanghuId = "0001"; DateTime date = new DateTime(); c.Modifydate = date; c.Index = q1.Count() + 1; context.Company.Add(c); foreach (var v in q1) { v.Addordec = "打入"; try { v.Value = int.Parse(textBox3.Text); num = (int)v.Value; v.YuE += v.Value; v.Laiziyu = textBox1.Text; DateTime date1 = new DateTime(); v.Modifydate = date1; } catch { MessageBox.Show("充值金额为整数"); return; } break; } var q2 = from t in context.Client where t.YongHuMing == textBox1.Text select t; foreach (var v in q2) { //if (v.YongHuMing.Equals("阿波罗")) MessageBox.Show("阿波罗"); v.YuE += num; break; } context.SaveChanges(); MessageBox.Show("充值成功!"); } }
public display(Management ma) { InitializeComponent(); using (var context = new MyDbEntities2()) { if (ma.button.Content.ToString() == "中文") { var q = from t in context.Client select new { 用户名 = t.YongHuMing, 姓名 = t.XingMing, 省份证号 = t.Identify, 手机号 = t.Tel, 账户余额 = t.YuE, 开户日期 = t.Date, 密码 = t.PassWord }; dataGrid.ItemsSource = q.ToList(); var q1 = from t in context.Company select new { 账户 = t.ZhanghuId, 余额 = t.YuE, 更改日期 = t.Modifydate, 收入或支出 = t.Addordec, 更改的值 = t.Value, 来源账户 = t.Laiziyu, 序列 = t.Index }; dataGrid1.ItemsSource = q1.ToList(); var q2 = from t in context.Ticket select new { 用户名 = t.YongHuMing, 购票数量 = t.Num, 购票单价 = t.Cost, 目的地 = t.Destination, 票种 = t.Issigle, 出发站 = t.StartP, 购票时间 = t.Time, 密码 = t.Password }; dataGrid2.ItemsSource = q2.ToList(); } else { var q = from t in context.Client select new { UserName = t.YongHuMing, Name = t.XingMing, ID = t.Identify, Tele = t.Tel, Remain = t.YuE, DateOpened = t.Date, PassWord = t.PassWord }; dataGrid.ItemsSource = q.ToList(); var q1 = from t in context.Company select new { Account = t.ZhanghuId, Remain = t.YuE, ChangeDate = t.Modifydate, Inorexpense = t.Addordec, value = t.Value, From = t.Laiziyu, Index = t.Index }; dataGrid1.ItemsSource = q1.ToList(); var q2 = from t in context.Ticket select new { UserName = t.YongHuMing, Number = t.Num, Price = t.Cost, Destination = t.Destination, Ticket = t.Issigle, Start = t.StartP, BuyDate = t.Time, Password = t.Password }; dataGrid2.ItemsSource = q2.ToList(); } } }
private void btnOK_Click(object sender, RoutedEventArgs e) { using (var context = new MyDbEntities2()) { var q = from t in context.Ticket where t.YongHuMing == textBoxUserName.Text select t; if (q.Count() == 0) { MessageBox.Show("该用户没有注册!"); errorTip1.Visibility = System.Windows.Visibility.Visible; errorTip2.Visibility = System.Windows.Visibility.Visible; return; } foreach (var v in q) { if (!v.Password.Equals(password.Password)) { MessageBox.Show("密码错误,请重新输入!"); errorTip1.Visibility = System.Windows.Visibility.Hidden; errorTip2.Visibility = System.Windows.Visibility.Visible; break; } //MessageBox.Show(this.issingle+" "+this.start+ " " + this.issingle+ " " + this.start+ " " + this.end+ " " + this.price+ " " + this.num+ " " + password.Password); DataUpClass da = new DataUpClass(v, textBoxUserName.Text, this.issingle, this.start, this.end, this.price, this.num, password.Password); //MessageBox.Show(v.YongHuMing+" "+v.PassWord); if (v.YongHuMing.ToString().Equals(textBoxUserName.Text) && v.Password.ToString().Equals(password.Password)) { MessageWindow w = new MessageWindow(textBoxUserName.Text); w.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; //w.Owner = this; this.Close(); w.Show(); } break; } var q1 = from t1 in context.Client where t1.YongHuMing == textBoxUserName.Text select t1; foreach (var v in q1) { if (v.YuE < this.allprice) { MessageBox.Show("账户余额不足!购票失败!"); return; } v.YuE -= this.allprice; v.Date = DateTime.Now; break; } var q2 = from t2 in context.Company where t2.ZhanghuId == "0001" select t2; Company cp = new Company(); cp.ZhanghuId = "0001"; cp.YuE += this.price; cp.Addordec = "打入"; cp.Value = this.price; cp.Laiziyu = textBoxUserName.Text; cp.Modifydate = DateTime.Now; context.SaveChanges(); } if (isUserNameError == true || isPasswordError == true) //登录失败 { timer.Start(); tryCount--; if (tryCount == 0) { App.Current.Shutdown(); } textBlockErrorInfo.Text = "登录失败(还有" + tryCount + "次机会)"; } else //成功 { timer.Close(); tryCount = 3; textBlockErrorInfo.Text = ""; } //ShowTable st = new ShowTable(); //st.Show(); }