public override void button3_Click(object sender, EventArgs e) { if (nameTxt.Text == "") { nameErrorLbl.Visible = true; } else { nameErrorLbl.Visible = false; } if (usernametxt.Text == "") { UserNameLbl.Visible = true; } else { nameErrorLbl.Visible = false; } if (usernametxt.Text == "") { UserNameLbl.Visible = true; } else { UserNameLbl.Visible = false; } if (pwdTxt.Text == "") { PwdLbl.Visible = true; } else { PwdLbl.Visible = false; } if (phoneTxt.Text == "") { phoneLbl.Visible = true; } else { phoneLbl.Visible = false; } if (EmailTxt.Text == "") { EmailLbl.Visible = true; } else { EmailLbl.Visible = false; } if (statusDD.SelectedIndex == -1) { statusErrorLbl.Visible = true; } else { statusErrorLbl.Visible = false; } if (nameErrorLbl.Visible || UserNameLbl.Visible || PwdLbl.Visible || phoneLbl.Visible || EmailLbl.Visible || statusErrorLbl.Visible) { MainClass.showMG("Filds With * Are Mandatory", "Stop", "Error"); // Error is the type of Message } else { if (statusDD.SelectedIndex == 0) { stat = 1; } else if (statusDD.SelectedIndex == 1) { stat = 0; } if (edit == 0)//code for save operation { insertion i = new insertion(); i.insertUser(nameTxt.Text, usernametxt.Text, pwdTxt.Text, EmailTxt.Text, phoneTxt.Text, stat); r.Showusers(dataGridView1, userIDGV, NameGV, UserNameGV, PassGV, EmailGV, PhoneGV, statusGV); MainClass.disable_reset(lftPanel); } else if (edit == 1)///for Updte Operation { DialogResult dr = MessageBox.Show("Are you sure, you want to updata Record", "Question..", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { updation u = new updation(); if (statusDD.SelectedIndex == 0) { stat = 1; } else if (statusDD.SelectedIndex == 1) { stat = 0; } u.updateUser(userID, nameTxt.Text, usernametxt.Text, pwdTxt.Text, EmailTxt.Text, phoneTxt.Text, stat); r.Showusers(dataGridView1, userIDGV, NameGV, UserNameGV, PassGV, EmailGV, PhoneGV, statusGV); MainClass.disable_reset(lftPanel); } } } }
public override void saveBtn_Click(object sender, EventArgs e) { //Here we enable and disable the red asterisc "*" in the form, validating that no txt left unfilled if (nameTxt.Text == "") { nameErrorLabel.Visible = true; } else { nameErrorLabel.Visible = false; } if (usernameTxt.Text == "") { usernameErrorLabel.Visible = true; } else { usernameErrorLabel.Visible = false; } if (passwordTxt.Text == "") { passwordErrorLabel.Visible = true; } else { passwordErrorLabel.Visible = false; } if (emailTxt.Text == "") { emailErrorLabel.Visible = true; } else { emailErrorLabel.Visible = false; } if (phoneTxt.Text == "") { phoneErrorLabel.Visible = true; } else { phoneErrorLabel.Visible = false; } if (statusDD.SelectedIndex == -1) { statusErrorLabel.Visible = true; } else { statusErrorLabel.Visible = false; } if (nameErrorLabel.Visible || usernameErrorLabel.Visible || passwordErrorLabel.Visible || emailErrorLabel.Visible || phoneErrorLabel.Visible || statusErrorLabel.Visible) { MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error"); //Error is the type of msg } else { if (statusDD.SelectedIndex == 0) { stat = 1; } else if (statusDD.SelectedIndex == 1) { stat = 0; } if (edit == 0) //Code for SAVE operation { insertion i = new insertion(); i.insertUser(nameTxt.Text, usernameTxt.Text, passwordTxt.Text, emailTxt.Text, phoneTxt.Text, stat); r.showUsers(dataGridView1, UserIDGV, NameGV, UserNameGV, PassGV, EmailGV, PhoneGV, StatusGV); MainClass.disable_reset(leftPanel); } else if (edit == 1) //Code for UPDATE operation { DialogResult dr = MessageBox.Show("Are you sure , you want to update record?", "Question...", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { updation u = new updation(); if (statusDD.SelectedIndex == 0) { stat = 1; } else if (statusDD.SelectedIndex == 1) { stat = 0; } u.updateUser(userID, nameTxt.Text, usernameTxt.Text, passwordTxt.Text, emailTxt.Text, phoneTxt.Text, stat); r.showUsers(dataGridView1, UserIDGV, NameGV, UserNameGV, PassGV, EmailGV, PhoneGV, StatusGV); MainClass.disable_reset(leftPanel); } } } }