private void btnSave_Click(object sender, EventArgs e) { m_EmployeeObject = new CEmployeeDTO(txtEmployeeId.Text, txtEmployeeName.Text, cmbEmployeeGender.Text, dateBirthDay.DateTime, txtEmployeePhone.Text, txtEmployeeAddress.Text, dateToWork.DateTime, lkEmployeeCharge.EditValue.ToString(), "", "", txtEmployeeEmail.Text); m_EmployeeExecute.AddEmployeeToDatabase(m_EmployeeObject); m_EmployeeData = m_EmployeeExecute.getEmployeeDataFromDatabase(); grdListEmployee.DataSource = m_EmployeeData; grdvListEmployee.FocusedRowHandle = grdvListEmployee.DataRowCount - 1; }
private void btnSave_Click(object sender, EventArgs e) { if (!checkData()) { return; } try { if (m_IsAdd) { String _user = createUserName(txtEmployeeName.Text, dateBirthDay.DateTime.ToString()); String _pass = CodeDTO.getMD5Hash("123456789"); m_EmployeeObject = new CEmployeeDTO("NV0000000", txtEmployeeName.Text, cmbEmployeeGender.Text, dateBirthDay.DateTime, txtEmployeePhone.Text, txtEmployeeAddress.Text, dateToWork.DateTime, lkEmployeeCharge.EditValue.ToString(), _user, _pass, txtEmployeeEmail.Text); if (m_EmployeeExecute.AddEmployeeToDatabase(m_EmployeeObject)) { XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true); } else { XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true); } } else { m_EmployeeObject = new CEmployeeDTO(txtEmployeeId.Text, txtEmployeeName.Text, cmbEmployeeGender.Text, dateBirthDay.DateTime, txtEmployeePhone.Text, txtEmployeeAddress.Text, dateToWork.DateTime, lkEmployeeCharge.EditValue.ToString(), txtEmployeeName.Text, null, txtEmployeeEmail.Text); if (m_EmployeeExecute.UpdateEmployeeToDatabase(m_EmployeeObject)) { XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true); } else { XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true); } } } catch (System.Exception) { XtraCustomMessageBox.Show("Lưu dữ liệu thất bại!", "Lỗi", true); } finally { updateEnableButtonAndResetValueOfControl(ref btnSave); } }