private void btnchngPwd_Click_1(object sender, EventArgs e) { try { var userchng = db.Users.Where(x => x.UserID == textuserchng.Text && x.Password == txtoldpass.Text).FirstOrDefault(); if (txtnewpass.Text != txtcnfmpass.Text) { MessageBox.Show("confirm password not matching with new passsword"); txtnewpass.Text = ""; txtcnfmpass.Text = ""; txtnewpass.Focus(); } else if (userchng == null) { MessageBox.Show("Incorrect UserId or Password"); textuserchng.Focus(); textuserchng.Text = txtoldpass.Text = txtnewpass.Text = txtcnfmpass.Text = ""; } else { if (userchng != null) { userchng.Password = txtcnfmpass.Text; db.SaveChanges(); MessageBox.Show("Password Changed Successfully"); textuserchng.Text = txtoldpass.Text = txtnewpass.Text = txtcnfmpass.Text = ""; } else { MessageBox.Show("Something Wrong !!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSubmit_Click(object sender, EventArgs e) { if (comboCustomerName.Text == "") { MessageBox.Show("Please enter a Name !"); return; } else if (txtAddress.Text == "") { MessageBox.Show("Please enter a Address !"); return; } else if (txtmobile.Text == "") { MessageBox.Show("Please enter a Mobile No!"); return; } else if (txtIDnumber.Text == "") { MessageBox.Show("Please enter a ID No!"); return; } else { try { var esistcus = db.Customers.Where(x => x.CustomerName == comboCustomerName.Text).FirstOrDefault(); if (esistcus == null) { Customer cust = new Customer(); cust.CustomerName = comboCustomerName.Text; cust.Address = txtAddress.Text; cust.MobileNo = Convert.ToInt64(txtmobile.Text); cust.IdCardNo = txtIDnumber.Text; cust.Photo = image; cust.IdCard = card; cust.PartyGST = textPartyGST.Text; cust.State = textState.Text; db.Customers.Add(cust); db.SaveChanges(); MessageBox.Show("Data Saved successfully"); ClearCustomerDetail(); if (customerId == 0) { var currentvi = db.Customers.OrderByDescending(x => x.CustomerID).FirstOrDefault(); if (currentvi != null) { customerId = currentvi.CustomerID; } } } else { if (Login.Roll == "Admin") { esistcus.Address = txtAddress.Text; esistcus.MobileNo = Convert.ToInt64(txtmobile.Text); esistcus.IdCardNo = txtIDnumber.Text; esistcus.Photo = image; esistcus.IdCard = card; esistcus.PartyGST = textPartyGST.Text; esistcus.State = textState.Text; esistcus.CustomerName = comboCustomerName.Text; db.SaveChanges(); customerId = esistcus.CustomerID; MessageBox.Show("Data Updated successfully"); ClearCustomerDetail(); } else { MessageBox.Show("you are not authorized"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }