private void btnChangePassword_Click(object sender, EventArgs e) { if (!ValidateEmail(txtEmail.Text)) { return; } else if (!ValidatePassword(txtConfirmPass.Text, txtNewPass.Text, txtOldPass.Text)) { return; } else { User u = (from x in db.Users where x.UserID == user.UserID select x).First(); u.UserPassword = txtNewPass.Text; db.SaveChanges(); this.Close(); } }
private void btnRegister_Click(object sender, EventArgs e) { string confPass = txtPasswordConfirm.Text; if (!ValidatePassword(txtPassword.Text)) { return; } else if (confPass.Equals("")) { MessageBox.Show("Confirm Password Must be Filled"); return; } else if (confPass != txtPassword.Text) { MessageBox.Show("Password and Confirm Password must be the same"); return; } else if (!ValidateEmail(txtEmail.Text)) { return; } else if (!ValidatePhone(txtPhone.Text)) { return; } else if (!ValidateAddress(txtAddress.Text)) { return; } else { User u = new User(); u.UserName = txtUsername.Text; u.UserPassword = txtPassword.Text; u.UserEmail = txtEmail.Text; u.UserPhoneNumber = txtPhone.Text; u.UserAddress = txtAddress.Text; u.RoleName = "Member"; //ID GENERATOR var data = from x in db.Users select x; if (data.Count() != 0) { String generator = string.Format("US{0}", (data.Count() + 2).ToString("000")); u.UserID = generator; } else { u.UserID = "US001"; } db.Users.AddObject(u); db.SaveChanges(); user = u; } { HomeForm home = new HomeForm(user); home.Show(); this.Hide(); } }
private void btnSave_Click(object sender, EventArgs e) { bool correct = false; string m = cbRolename.Text; if (!ValidateUsername(txtUsername.Text)) { return; } else if (!ValidatePassword(txtPassword.Text)) { return; } else if (!ValidateEmail(txtEmail.Text)) { return; } else if (!ValidateAddress(txtAddress.Text)) { return; } else if (!ValidatePhone(txtPhoneNum.Text)) { return; } else if (m == "") { MessageBox.Show("Please Choose the Role"); return; } else { correct = true; } if (functionNumber == 1 && correct == true) { MessageBox.Show("User has been inserted!"); User u = new User(); u.UserName = txtUsername.Text; u.UserPassword = txtPassword.Text; u.UserEmail = txtEmail.Text; u.UserPhoneNumber = txtPhoneNum.Text; u.UserAddress = txtAddress.Text; if (m == "Member") { u.RoleName = "Member"; } else { u.RoleName = "Admin"; } //ID GENERATOR var data = from x in db.Users select x; if (data.Count() != 0) { String generator = string.Format("US{0}", (data.Count() + 1).ToString("000")); u.UserID = generator; } else { u.UserID = "US001"; } db.Users.AddObject(u); db.SaveChanges(); refreshTable(); refreshUI(); } else if (functionNumber == 2 && correct == true) { MessageBox.Show("User has been updated!"); User u = (from x in db.Users where x.UserID == txtUserID.Text select x).First(); u.UserName = txtUsername.Text; u.UserPassword = txtPassword.Text; u.UserEmail = txtEmail.Text; u.UserPhoneNumber = txtPhoneNum.Text; u.UserAddress = txtAddress.Text; u.RoleName = "Member"; db.SaveChanges(); refreshTable(); refreshUI(); } }
private void btnAddtoCart_Click(object sender, EventArgs e) { if (txtLaundryID.Text.Equals("")) { MessageBox.Show("Please Choose Laundry First"); } else if (numericUpDown1.Value.Equals(0)) { MessageBox.Show("Please Fill the Quantity More Than 0"); } else { key = txtLaundryID.Text; var data = (from x in db.HeaderTransactions join y in db.DetailTransactions on x.TransactionID equals y.TransactionID join z in db.PriceLists on y.ProductID equals z.ProductID where x.Status.Equals("Pending") && z.ProductID == key && x.UserID == user.UserID select new { z.ProductID, z.ProductName, y.Quantity, TotalPrice = y.Quantity * z.ProductPrice }); if (data.Count() == 0) { DetailTransaction d = new DetailTransaction(); var cekHeaderExist = (from x in db.HeaderTransactions where x.Status.Equals("Pending") && x.UserID == user.UserID select x).ToList(); cekH = cekHeaderExist.Count(); if (cekHeaderExist.Count() == 0) { HeaderTransaction h = new HeaderTransaction(); h.TransactionID = txtTransactionID.Text; h.UserID = txtUserID.Text; h.Status = "Pending"; db.HeaderTransactions.AddObject(h); db.SaveChanges(); } d.TransactionID = txtTransactionID.Text; d.ProductID = txtLaundryID.Text; d.Quantity = Convert.ToInt32(Math.Round(numericUpDown1.Value, 0)); d.Price = Int32.Parse(txtPrice.Text); db.DetailTransactions.AddObject(d); db.SaveChanges(); refreshTableDetail(); } else { DetailTransaction d = (from x in db.DetailTransactions join y in db.HeaderTransactions on x.TransactionID equals y.TransactionID where x.ProductID == key && y.Status == "Pending" && y.UserID == user.UserID select x).First(); int qtt = Convert.ToInt32(Math.Round(numericUpDown1.Value, 0)); d.Quantity = d.Quantity + qtt; db.SaveChanges(); refreshTableDetail(); } } grandTotalGenerator(); }
private void btnSave_Click(object sender, EventArgs e) { bool correct = false; //validation if (txtLaundryName.Text == "") { MessageBox.Show("Please Fill the Laundry Name Field"); } else if (validateName(txtLaundryName.Text)) { MessageBox.Show("Laundry Name must be alphabet only"); } else if (txtPrice.Text == "") { MessageBox.Show("Please Fill the Laundry Price Field"); } else if (!validatePrice(txtPrice.Text)) { MessageBox.Show("Laundry Price must be numeric"); } else { correct = true; } if (functionNumber == 1 && correct == true) { MessageBox.Show("Laundry has been inserted!"); string id = txtLaundryID.Text; string name = txtLaundryName.Text; int price = Int32.Parse(txtPrice.Text); PriceList p = new PriceList(); p.ProductID = id; p.ProductName = name; p.ProductPrice = price; db.PriceLists.AddObject(p); db.SaveChanges(); refreshUI(); refreshTable(); } else if (functionNumber == 2 && correct == true) { MessageBox.Show("Laundry has been updated!"); string id = txtLaundryID.Text; string name = txtLaundryName.Text; int price = Int32.Parse(txtPrice.Text); PriceList p = (from x in db.PriceLists where x.ProductID == txtLaundryID.Text select x).First(); p.ProductName = name; p.ProductPrice = price; db.SaveChanges(); refreshUI(); refreshTable(); } }