Beispiel #1
0
        private void btnAddService_Click(object sender, EventArgs e)
        {
            String fName  = ((txtFname.Text).Replace(" ", string.Empty)).Clone().ToString();
            String lName  = ((txtLname.Text).Replace(" ", string.Empty)).Clone().ToString();
            String nic    = ((txtNIC.Text).Replace(" ", string.Empty)).Clone().ToString();
            String role   = ((cmbRole.Text).Replace(" ", string.Empty)).Clone().ToString();
            String usName = ((userName.Text).Replace(" ", string.Empty)).Clone().ToString();

            if (fName == "")
            {
                fnameVerify.Show();
                hideLabelsTimer();
            }
            else if (lName == "")
            {
                lnameVerify.Show();
                hideLabelsTimer();
            }
            else if (usName == "")
            {
                userNameVerify.Show();
                hideLabelsTimer();
            }
            else if (nic == "")
            {
                nicVerify.Show();
                hideLabelsTimer();
            }
            else if (role == "")
            {
                roleVerify.Show();
                hideLabelsTimer();
            }
            else if (password.Text == "")
            {
                passwordVerify.Show();
                hideLabelsTimer();
            }
            else
            {
                String uName    = (userName.Text).Clone().ToString();
                String urole    = ((KeyValuePair <String, String>)cmbRole.SelectedItem).Key;
                String uPword   = (password.Text).Clone().ToString();
                String uFName   = (txtFname.Text).Clone().ToString();
                String uLName   = (txtLname.Text).Clone().ToString();
                String uAddress = (txtAddress.Text).Clone().ToString();
                String uTel     = (txtTel.Text).Clone().ToString();
                String uLNic    = (txtNIC.Text).Clone().ToString();
                userDataManipulations userDataManipulations = new userDataManipulations();
                if ((userDataManipulations.validateUserName(uName)))
                {
                    user    user = new user(uName, urole, uPword, uFName, uLName, uAddress, uTel, uLNic);
                    Boolean userInsertionFlag = userDataManipulations.updateUser(user);
                    if (userInsertionFlag)
                    {
                        MessageBox.Show("Update Successfull. Data Updated successfully", "Important Note",
                                        MessageBoxButtons.OK);
                        currentView.bindDataTableData();
                        this.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("Update Failed. Check the Updated data again", "Important Note",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
                else
                {
                    userNameVerify.Show();
                }
            }
        }