private void button1_Click(object sender, EventArgs e) { int a = Convert.ToInt32(textBox1.Text); int b = Convert.ToInt32(Class1.total); if (textBox1.Text == "") { MessageBox.Show("Data Cant Be Empty", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Clear(); textBox1.Focus(); } else if (a < b) { MessageBox.Show("Your Money Is Not Enough", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox1.Clear(); textBox1.Focus(); } else { using (DataClassesDataContext db = new DataClassesDataContext()) { Headerorder h = db.Headerorders.Where(s => s.OrderID == Class1.orderid).FirstOrDefault(); h.Payment = "Cash"; db.SubmitChanges(); MessageBox.Show("Success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); close.Enabled = true; this.Close(); } } }
private void button1_Click(object sender, EventArgs e) { if (cbxPayment.SelectedItem == null || tbxCard.Text == "" || cbxBank.SelectedItem == null) { MessageBox.Show("Data Cant Be Empty", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); cbxPayment.SelectedItem = null; tbxCard.Clear(); cbxBank.SelectedItem = null; } else { using (DataClassesDataContext db = new DataClassesDataContext()) { Headerorder h = db.Headerorders.Where(s => s.OrderID == cbxOrderid.SelectedItem.ToString()).FirstOrDefault(); h.Payment = cbxPayment.SelectedItem.ToString(); h.CardNumber = tbxCard.Text; h.bank = cbxBank.SelectedItem.ToString(); h.Date = DateTime.Now; db.SubmitChanges(); cbxPayment.SelectedItem = null; tbxCard.Clear(); cbxBank.SelectedItem = null; dg1.DataSource = null; lblTotal.Text = "Total : 0"; this.Refresh(); MessageBox.Show("Success", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void detach_Headerorders(Headerorder entity) { this.SendPropertyChanging(); entity.Msemployee = null; }
partial void DeleteHeaderorder(Headerorder instance);
partial void UpdateHeaderorder(Headerorder instance);
partial void InsertHeaderorder(Headerorder instance);
private void attach_Headerorders(Headerorder entity) { this.SendPropertyChanging(); entity.Msmember = this; }
private void btnOrder_Click(object sender, EventArgs e) { try { using (DataClassesDataContext db = new DataClassesDataContext()) { if (dg2.DataSource == null) { MessageBox.Show("Data Cant Be Empty", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); awal(); } else { Headerorder d = db.Headerorders.OrderByDescending(s => s.OrderID).FirstOrDefault(); if (d != null) { string auto = d.OrderID.ToString().Substring(6, 4); int n = Convert.ToInt32(auto) + 1; c = DateTime.Today.ToString("yyyyMM") + n.ToString("d4"); } else { c = DateTime.Today.ToString("yyyyMM") + "0001"; } int dd; Detailorder ddd = db.Detailorders.OrderByDescending(s => s.Detailid).FirstOrDefault(); if (ddd != null) { string autonumber = ddd.Detailid.ToString(); int n = Convert.ToInt32(autonumber) + 1; dd = Convert.ToInt32(n.ToString("d1")); } else { dd = 1; } var a = c; List <Msmember> m = db.Msmembers.Select(s => s).ToList(); db.Headerorders.InsertOnSubmit(new Headerorder { OrderID = a, Employeeid = emp.EmployeeID, Date = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd")), Memberid = m[cbxMember.SelectedIndex].MemberID }); db.SubmitChanges(); foreach (menuu i in list) { db.Detailorders.InsertOnSubmit(new Detailorder { Detailid = dd, Orderid = a, Menuid = Convert.ToInt32(i.kodemenu), Qty = i.Qty, Price = i.Price, Status = "Pending" }); db.SubmitChanges(); } MessageBox.Show("Successfully Order Data", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); awal(); } } } catch (Exception ex) { MessageBox.Show("Try Again, Please Contact Admin", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning); awal(); } }