private void btnSave_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtAddress.Text) || String.IsNullOrEmpty(txtCMND.Text) || String.IsNullOrEmpty(txtPhone.Text) || String.IsNullOrEmpty(txtName.Text) || String.IsNullOrEmpty(txtEmail.Text) || String.IsNullOrEmpty(txtShift.Text) || String.IsNullOrEmpty(cbGender.Text) || String.IsNullOrEmpty(dtPkDOB.Text)) { MessageBox.Show("Ban hay nhap day du", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Employee emp = new Employee(); emp.EmployeeID = dgtEmployeeEdit.RowCount + 1; emp.Name = txtName.Text; emp.CMND = txtCMND.Text; emp.PhoneNumber = txtPhone.Text; emp.Address = txtAddress.Text; if (cbGender.SelectedValue == "Female") { emp.IsFemale = true; } else { emp.IsFemale = false; } emp.Email = txtEmail.Text; emp.Username = "******"; emp.Password = "******"; emp.IsAdmin = true; emp.DateOfBirth = dtPkDOB.Value; employeeBLL.AddEmployee(emp); 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.loadUCEmployeeEdit(); } } /* if (txtName.Text.Trim().Length == 0) //Nếu chưa nhập Name * { * MessageBox.Show("Bạn phải nhập Name", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); * txtName.Focus(); * return; * } * if (txtAddress.Text.Trim().Length == 0) //Nếu chưa nhập tên chất liệu * { * MessageBox.Show("Bạn phải nhập Address", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); * txtShift.Focus(); * return; * } * if (txtShift.Text.Trim().Length == 0) //Nếu chưa nhập tên chất liệu * { * MessageBox.Show("Bạn phải nhập Shift", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); * txtShift.Focus(); * return; * } * if (txtCMND.Text.Trim().Length == 0) * { * MessageBox.Show("Bạn phải nhập lại CMND", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); * txtShift.Focus(); * return; * } * if (txtPhone.Text.Trim().Length == 0 ) * { * MessageBox.Show("Bạn phải nhập lại Phone", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); * txtShift.Focus(); * return; * } */ }
private void btnEdit_Click(object sender, EventArgs e) { this.Hide(); mainform.loadUCEmployeeEdit(); }