private void btn_OK_Click(object sender, EventArgs e) { bool isPassChanged = false; switch (CheckData()) { case 0: MessageBox.Show("You must fill in all fields!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); break; case 1: MessageBox.Show("Invalid Phone Number!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case 2: MessageBox.Show("Invalid Email or Password!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case 3: MessageBox.Show("You must insert an image!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Information); break; case 4: string FileName = tb_Username.Text.Replace(" ", String.Empty) + ".Jpeg"; userVM.UserName = tb_Username.Text.Replace(" ", String.Empty); if (tb_Password.Enabled) { userVM.UserPassword = tb_Password.Text.Replace(" ", String.Empty); isPassChanged = true; } userVM.UserGmail = tb_Email.Text.Replace(" ", String.Empty); userVM.UserPhone = tb_Phone.Text.Replace(" ", String.Empty); if (rbtn_Male.Checked) { userVM.UserGender = true; } else { userVM.UserGender = false; } if (Change) { UpdateIMG(FileName); } userVM.ListImg.Clear(); userVM.ListImg.Add(TempAvatar); ///properties to check existed Dictionary <string, string> properties = new Dictionary <string, string>(); properties.Add("phone", userVM.UserPhone); properties.Add("gmail", userVM.UserGmail); if (ID == 0) { if (qLUserBLL.Checkexisted(properties)) { qLUserBLL.AddUser(userVM); MessageBox.Show("A new user has been successfully created!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); myDel(); this.Dispose(); } else { MessageBox.Show("Existed Email or Phone!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { properties.Add("code", userVM.UserCode); if (qLUserBLL.Checkexisted(properties)) { qLUserBLL.UpdateUser(userVM, listDel, isPassChanged); MessageBox.Show("This user has been successfully updated!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); myDel(); this.Dispose(); } else { MessageBox.Show("Existed Email or Phone!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } break; default: break; } }