Beispiel #1
0
        public override void BtnSave_Click(object sender, EventArgs e)
        {
            //validation for Users form
            if (nameTxt.Text == string.Empty)
            {
                nameErrorLabel.Visible = true;
            }
            else
            {
                nameErrorLabel.Visible = false;
            }
            if (userNameTxt.Text == string.Empty)
            {
                usernameErrorLabel.Visible = true;
            }
            else
            {
                usernameErrorLabel.Visible = false;
            }
            if (pwdTxt.Text == string.Empty)
            {
                pwdErrorLabel.Visible = true;
            }
            else
            {
                pwdErrorLabel.Visible = false;
            }
            if (phoneTxt.Text == string.Empty)
            {
                phoneErrorLabel.Visible = true;
            }
            else
            {
                phoneErrorLabel.Visible = false;
            }
            if (emailTxt.Text == string.Empty)
            {
                emailErrorLabel.Visible = true;
            }
            else
            {
                emailErrorLabel.Visible = false;
            }
            if (statusCb.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }

            if (nameErrorLabel.Visible || usernameErrorLabel.Visible || pwdErrorLabel.Visible || phoneErrorLabel.Visible || emailErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.showMSG("Fields with * are mandatory", "Stop", "Error"); //Error is the type of message
            }
            else
            {
                if (statusCb.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (statusCb.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0) // Code for SAVE Operation
                {
                    Insertion i = new Insertion();
                    i.insertUser(nameTxt.Text, userNameTxt.Text, pwdTxt.Text, phoneTxt.Text, emailTxt.Text, stat);
                    r.showUsers(dataGridView1, UserIDGV, NameGV, UsernameGV, PassGV, PhoneGV, EmailGV, StatusGV);
                    MainClass.disable_reset(LeftPanel);
                }
                else if (edit == 1) // Code for EDIT 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 (statusCb.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (statusCb.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateUser(userID, nameTxt.Text, userNameTxt.Text, pwdTxt.Text, phoneTxt.Text, emailTxt.Text, stat);
                        r.showUsers(dataGridView1, UserIDGV, NameGV, UsernameGV, PassGV, PhoneGV, EmailGV, StatusGV);
                        MainClass.disable_reset(LeftPanel);
                    }
                }
            }
        }
Beispiel #2
0
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text == "")
            {
                namelabelError.Visible = true;
            }
            else
            {
                namelabelError.Visible = false;
            }
            if (userTxt.Text == "")
            {
                usrlabelError.Visible = true;
            }
            else
            {
                usrlabelError.Visible = false;
            }
            if (passTxt.Text == "")
            {
                passlabelError.Visible = true;
            }
            else
            {
                passlabelError.Visible = false;
            }
            if (phoneTxt.Text == "")
            {
                phonelabelError.Visible = true;
            }
            else
            {
                phonelabelError.Visible = false;
            }
            if (emailTxt.Text == "")
            {
                emaillabelError.Visible = true;
            }
            else
            {
                emaillabelError.Visible = false;
            }
            if (statusCombo.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }

            if (namelabelError.Visible || usrlabelError.Visible || passlabelError.Visible || phonelabelError.Visible || emaillabelError.Visible || statusErrorLabel.Visible)
            {
                MainClass.showMessage("Fields with * are mandatory", "Stop", "Error");
            }
            else
            {
                if (statusCombo.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (statusCombo.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)//Code for Save Operation
                {
                    Insertion i = new Insertion();


                    i.insertUser(nameTxt.Text, userTxt.Text, passTxt.Text, phoneTxt.Text, emailTxt.Text, stat);

                    r.showUser(dataGridView1, USERGV, 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 recored", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        Updation u = new Updation();
                        if (statusCombo.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (statusCombo.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateUser(userId, nameTxt.Text, userTxt.Text, passTxt.Text, phoneTxt.Text, emailTxt.Text, stat);

                        r.showUser(dataGridView1, USERGV, nameGV, usernameGV, passGV, EmailGV, PhoneGV, StatusGV);
                        MainClass.disable_reset(leftPanel);
                    }
                }
            }
        }