private void btn_go_Click(object sender, EventArgs e) { using (DataClasses1DataContext db = new DataClasses1DataContext()) { AccountPurchase1 accnt = new AccountPurchase1(); string items = Convert.ToString(comb_items.SelectedItem); DateTime date = date_picker.Value; int quant = Convert.ToInt16(num_txt.Text); int custid = Convert.ToInt16(txt_cust.ToString()); Customer1 customer = db.Customer1s.Single(u => u.customerID == custid); accnt.customerID = custid; accnt.purchaseDate = date; accnt.quantity = quant; accnt.prodDescription = items; var price = from p in db.Stores where p.prodDescription == items select p.productPrice; decimal totalPrice = Convert.ToDecimal(price) * quant; customer.customerBalance = customer.customerBalance + totalPrice; db.AccountPurchase1s.InsertOnSubmit(accnt); db.SubmitChanges(); MessageBox.Show("Action Completed"); this.Hide(); customerPage pg = new customerPage(); pg.ShowDialog(); } }
private void btn_back_Click(object sender, EventArgs e) { this.Hide(); customerPage page = new customerPage(); page.ShowDialog(); }
private void btn_submit_Click(object sender, EventArgs e) { DataClasses1DataContext db = new DataClasses1DataContext(); var uname = txt_uname.Text; var pword = txt_pass.Text; var customers = db.Customer1s; foreach (var val in customers) { var password = val.password; var username = val.username; if (uname == username) { if (pword == password) { this.Hide(); customerPage page = new customerPage(); page.ShowDialog(); } else { MessageBox.Show("Invalid Username or Password"); } } else { MessageBox.Show("Invalid Username or Password"); } } db.Dispose(); }