private void butSave_Click(object sender, EventArgs e)
        {
            if (boxName.Text == "")
            {
                MessageBox.Show("Name must be filled!");
            }
            else if (boxEmail.Text == "")
            {
                MessageBox.Show("Email must be filled!");
            }
            else if (boxEmail.Text.Length < 3)
            {
                MessageBox.Show("Email must be at least 10 characters!");
            }
            else if (boxEmail.Text.IndexOf(".") == -1)
            {
                MessageBox.Show("Email must contain at least 1 ‘.’ (dot) !");
            }
            else if (boxEmail.Text.IndexOf("@") == -1)
            {
                MessageBox.Show("Email must contain at least 1 ‘@’ (at) !");
            }
            else if (boxEmail.Text.StartsWith("@") || boxEmail.Text.StartsWith(".") || boxEmail.Text.EndsWith("@") || boxEmail.Text.EndsWith("."))
            {
                MessageBox.Show("Email must not be started or ended with '@' (at) or '.' (dot) !");
            }
            else if (boxEmail.Text.IndexOf("@") + 1 == boxEmail.Text.IndexOf(".") || boxEmail.Text.IndexOf(".") + 1 == boxEmail.Text.IndexOf("@"))
            {
                MessageBox.Show("Email's '@' (at) and '.' (dot) must not be side by side !");
            }
            else if (boxEmail.Text.Substring(boxEmail.Text.LastIndexOf(".")).IndexOf("@") != -1)
            {
                MessageBox.Show("Email's '@' (at) may not after the last '.' (dot) !");
            }
            else if (boxEmail.Text.IndexOf("yahoo") == -1 && boxEmail.Text.IndexOf("gmail") == -1)
            {
                MessageBox.Show("Email domain must be 'yahoo' or 'gmail' !");
            }
            else if (boxPassword.Text == "")
            {
                MessageBox.Show("Password must be filled !");
            }
            else if (boxPassword.Text.Length < 8)
            {
                MessageBox.Show("Password must be 8 characters minimum !");
            }
            else if (checkLetter(boxPassword.Text) < 5)
            {
                MessageBox.Show("Password at least contain 5 alphabets minimum !");
            }
            else if (boxPassword.Text.IndexOf(" ") != -1)
            {
                MessageBox.Show("Password may not contain space !");
            }
            else if (boxRole.SelectedIndex == 0)
            {
                MessageBox.Show("Role must be chosen !");
            }
            else
            {
                if (flag == 1)
                {
                    MsEmployee employee = new MsEmployee();
                    employee.EmployeeID = boxEmployeeID.Text;
                    employee.Name       = boxName.Text;
                    employee.Email      = boxEmail.Text;
                    employee.Password   = boxPassword.Text;
                    employee.Role       = boxRole.Text;
                    dtBS.MsEmployees.InsertOnSubmit(employee);
                    dtBS.SubmitChanges();
                    MessageBox.Show("Data succesfuly inserted !");

                    dataGridEmployee.Enabled = true;
                    IUDEnabled();
                    IdentityDisabled();
                    clear();
                    refreshTable();
                }
                else if (flag == 2)
                {
                    var query = (from x in dtBS.MsEmployees where x.EmployeeID == boxEmployeeID.Text select x).First();
                    query.EmployeeID = boxEmployeeID.Text;
                    query.Name       = boxName.Text;
                    query.Email      = boxEmail.Text;
                    query.Password   = boxPassword.Text;
                    query.Role       = boxRole.Text;
                    dtBS.MsEmployees.InsertOnSubmit(query);
                    dtBS.SubmitChanges();
                    MessageBox.Show("Data succesfuly updated !");

                    dataGridEmployee.Enabled = true;
                    IUDEnabled();
                    IdentityDisabled();
                    clear();
                    refreshTable();
                }
            }
        }
Exemple #2
0
 partial void UpdateMsEmployee(MsEmployee instance);
Exemple #3
0
 partial void DeleteMsEmployee(MsEmployee instance);
Exemple #4
0
 partial void InsertMsEmployee(MsEmployee instance);