예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool result = false;

            foreach (var item in ListEmpEdit)
            {
                if (employeeBLL.EditEmployee(item) == false)
                {
                    MessageBox.Show("Cannot save. Please try again");
                    break;
                }
                else
                {
                    result = true;
                }
            }
            if (result == true)
            {
                DialogResult dialog = MessageBox.Show("Saved successfully", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (dialog == DialogResult.OK)  //click ok thì chuyển lại form đầu.
                {
                    mainform.loadUCEmployee();
                }
            }
            dgvEmployee.DataSource = employeeBLL.LoadRecord(pageNumber, numberRecord);
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool result = false;

            foreach (var item in tables)
            {
                if (tableBLL.EditTable(item) == false)
                {
                    MessageBox.Show("Cannot save. Please try again");
                    break;
                }
                else
                {
                    result = true;
                }
            }
            if (result == true)
            {
                DialogResult dialog = MessageBox.Show("Saved successfully", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (dialog == DialogResult.OK)  //click ok thì chuyển lại form đầu.
                {
                    mainform.loadUCEmployee();
                }
            }
        }
예제 #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtUsername.Text) || String.IsNullOrEmpty(txtCMND.Text) ||
                String.IsNullOrEmpty(txtPhone.Text) || String.IsNullOrEmpty(txtName.Text) ||
                String.IsNullOrEmpty(txtEmail.Text) || cbGender.Text == "-select-" ||
                String.IsNullOrEmpty(dtpDOB.Text) || string.IsNullOrEmpty(txtUsername.Text))
            {
                MessageBox.Show("Please insert information fully !", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);

                /*if (cbGender.Text == "-select-")
                 *  errorGender.Text = " This need to be chosen";
                 * if (String.IsNullOrEmpty(txtCMND.Text))
                 *  errorCMND.Text = " This cannot be empty";
                 * if (String.IsNullOrEmpty(txtEmail.Text))
                 *  errorEmail.Text = " This cannot be empty";
                 * if (String.IsNullOrEmpty(txtPhone.Text))
                 *  errorPhone.Text = " This cannot be empty";
                 * if (String.IsNullOrEmpty(txtAddress.Text))
                 *  errorAddress.Text = " This cannot be empty";
                 * if (String.IsNullOrEmpty(txtName.Text))
                 *  errorName.Text = " This cannot be empty";*/
            }
            else
            {
                bool check = true;
                if (errorUsername.Text != "" || errorCMND.Text != "" || errorEmail.Text != "" ||
                    errorGender.Text != "" || errorName.Text != "" || errorPhone.Text != "")
                {
                    MessageBox.Show("Please correct your mistakes before save changes");
                }
                else
                {
                    Employee emp  = new Employee();
                    string   Name = txtName.Text;
                    while (Name.IndexOf("  ") != -1)
                    {
                        Name = Name.Replace("   ", " ");
                    }
                    Name            = Name.Trim();
                    emp.Name        = Name;
                    emp.CMND        = txtCMND.Text;
                    emp.PhoneNumber = txtPhone.Text;
                    emp.Address     = txtUsername.Text;
                    if (cbGender.Text == "Female")
                    {
                        emp.IsFemale = true;
                    }
                    if (cbGender.Text == "Male")
                    {
                        emp.IsFemale = false;
                    }
                    emp.Email = txtEmail.Text;
                    // emp.Username = Create_Username(Name);
                    emp.Username    = txtUsername.Text;
                    emp.Password    = Create_Password(Name, dtpDOB.Value);
                    emp.Status      = 1;
                    emp.IsAdmin     = (cbIsAdmin.Checked == true) ? true : false;
                    emp.DateOfBirth = dtpDOB.Value;

                    if (employeeBLL.AddEmployee(emp) == true)
                    {
                        DialogResult dialog = MessageBox.Show("Saved successfully", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (dialog == DialogResult.OK)  //click ok thì chuyển lại form đầu.
                        {
                            mainform.loadUCEmployee();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Saved unsuccessfully. Please try again!");
                    }
                }
            }
        }
예제 #4
0
 private void brnComeback_Click(object sender, EventArgs e)
 {
     mainform.loadUCEmployee();
 }