/// <summary> /// Phương thức lấy doi tuong Staff theo User name của Staff /// </summary> /// <param name="iStaffId">id của feedback</param> /// <returns>true: lấy thành công, false: lấy thất bại</returns> public DTOStaff GetStaffByIdToObject(String strStaffId) { try { strStaffId = Utils.StandStringSpace(strStaffId); DataTable tb = GetStaffById(strStaffId); if (tb.Rows.Count > 0) { DTOStaff objStaff = new DTOStaff(); objStaff.StaffID = tb.Rows[0][0].ToString(); objStaff.Name = tb.Rows[0][1].ToString(); objStaff.Gender = tb.Rows[0][2].ToString(); objStaff.Birthday = Convert.ToDateTime(tb.Rows[0][3].ToString()); objStaff.Address = tb.Rows[0][4].ToString(); objStaff.Phone = tb.Rows[0][5].ToString(); objStaff.Email = tb.Rows[0][6].ToString(); objStaff.DateCreated = Convert.ToDateTime(tb.Rows[0][7].ToString()); objStaff.RolePermissionId = tb.Rows[0][8].ToString(); objStaff.UserName = tb.Rows[0][9].ToString(); objStaff.Password = tb.Rows[0][10].ToString(); return(objStaff); } else { return(null); } } catch (SqlException) { throw; } }
private void frmHomePage_FormClosed(object sender, FormClosedEventArgs e) { staffLogin = null; rolePermissionObj = null; // this.Dispose(); this.Close(); }
public DTOStaff GetStaffById(int idstaff) { string query = string.Format("SELECT idstaff,namestaff,birthday,workday,sex,address,phonenumber FROM TableStaff WHERE idstaff={0}", idstaff); DataTable dt = DataProvider.Instance.ExecuteQuery(query); DTOStaff gv = new DTOStaff(dt.Rows[0]); return(gv); }
private void frmHomePage_FormClosing(object sender, FormClosingEventArgs e) { new frmLogin().Show(); staffLogin = null; rolePermissionObj = null; // this.Dispose(); this.Close(); }
/// <summary> /// Phương thức cập nhật một Staff xuống csdl theo id ko thay doi user name password /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool UpdateStaffNoUsernamePassword(DTOStaff Staff) { try { return(staffDAO.UpdateStaffNoUsernamePassword(Staff)); } catch (SqlException) { throw; } }
/// <summary> /// Phương thức cập nhật một Staff xuống csdl theo id /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool UpdateStaff(DTOStaff Staff) { try { return(staffDAO.UpdateStaff(Staff)); } catch (SqlException) { throw; } }
/// <summary> /// Phương thức thêm mới một Staff vào csdl /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool InsertStaff(DTOStaff Staff) { try { return(staffDAO.InsertStaff(Staff)); } catch (SqlException) { throw; } }
public frmSearchStaff() { InitializeComponent(); rolePermissionDataTable = new DataTable(); rolePermissionBUS = new BUSRolePermission(); rolePermissionObject = new DTORolePermission(); _StaffDT = new DataTable(); staffBUS = new BUSStaff(); staffObject = new DTOStaff(); staffMultiSelect = new GridCheckMarksSelection(grdvListStaff); ruleBUS = new BUSRule(); StaffSno.VisibleIndex = 1; }
public List <DTOStaff> GetListStaff() { List <DTOStaff> list = new List <DTOStaff>(); string query = string.Format("SELECT * FROM TableStaff "); DataTable dt = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in dt.Rows) { DTOStaff staff = new DTOStaff(item); list.Add(staff); } return(list); }
private void btnSave_Click(object sender, EventArgs e) { if (!checkData()) { return; } try { if (m_IsAdd) { String _user = createUserName(txtStaffName.Text, dateBirthDay.DateTime.ToString()); String _pass = Utils.GetMD5("123456789"); staffObject = new DTOStaff("NV000000", txtStaffName.Text, cmbStaffGender.Text, dateBirthDay.DateTime, txtStaffAddress.Text, txtStaffPhone.Text, txtStaffEmail.Text, dateToWork.DateTime, lkStaffCharge.EditValue.ToString(), _user, _pass); if (staffBUS.InsertStaff(staffObject)) { XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1); } else { XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4); } } else { staffObject = new DTOStaff(txtStaffId.Text, txtStaffName.Text, cmbStaffGender.Text, dateBirthDay.DateTime, txtStaffAddress.Text, txtStaffPhone.Text, txtStaffEmail.Text, dateToWork.DateTime, lkStaffCharge.EditValue.ToString(), null, null); if (staffBUS.UpdateStaffNoUsernamePassword(staffObject)) { XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!\nVui lòng thiết lập quyền truy cập hệ thống cho nhân viên '" + staffObject.Name + "'!", "Thông báo", true, 1); } else { XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true, 4); } } } catch (System.Exception) { XtraCustomMessageBox.Show("Lưu dữ liệu thất bại!", "Lỗi", true, 4); } finally { updateEnableButtonAndResetValueOfControl(ref btnSave); } }
/// <summary> /// Phương thức cập nhật một Staff xuống csdl theo id /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool UpdateStaff(DTOStaff staff) { try { DataExecute.Instance.createSqlCmd("sp_EditStaffUpdate", new object[10] { staff.StaffID, staff.Name, staff.Gender, staff.Birthday, staff.Address, staff.Phone, staff.Email, staff.DateCreated, staff.RolePermissionId, staff.Password }); return(DataExecute.Instance.updateData(DataConnection.Instance.m_cmd) > 0); } catch (SqlException) { throw; } }
private void btnDelete_Click(object sender, EventArgs e) { if (staffMultiSelect.Selection.Count == 0) { XtraCustomMessageBox.Show("Chưa có dòng dữ liệu nào được chọn!", "Cảnh báo", true, 3); return; } try { ArrayList _listStaffId = new ArrayList(); grdvListStaff.FocusedRowHandle -= 1; foreach (DataRowView _rowData in staffMultiSelect.Selection) { staffObject = new DTOStaff(); staffObject.StaffID = _rowData["StaffID"].ToString(); if (!staffBUS.DeleteStaff(staffObject.StaffID)) { _listStaffId.Add(_rowData["StaffID"]); } } if (_listStaffId.Count != 0) { String _erroContent = "Không thể xóa các nhân viên có mã: \n"; foreach (var item in _listStaffId) { _erroContent += item.ToString() + "\n"; } XtraCustomMessageBox.Show(_erroContent, "Lỗi", true, 4); } else { XtraCustomMessageBox.Show("Xóa dữ liệu thành công!", "Thông báo", true, 1); } } catch (System.Exception) { XtraCustomMessageBox.Show("Xóa dữ liệu thất bại", "Lỗi", true, 4); } finally { updateEnableButtonAndResetValueOfControl(ref btnDelete); } }
private void btnSave_Click(object sender, EventArgs e) { staffDTO = frmHomePage.staffLogin; staffDTO.Name = Utils.standardNamePerson(txtStaffName.Text.Trim()); staffDTO.Phone = txtStaffPhone.Text.Trim(); staffDTO.Email = txtStaffEmail.Text.Trim(); staffDTO.Birthday = dateBirthDay.DateTime; staffDTO.Address = Utils.standardNamePerson(txtStaffAddress.Text.Trim()); staffDTO.Gender = cmbStaffGender.Text.Trim(); if (staffBUS.UpdateStaffNoUsernamePassword(staffDTO)) { XtraCustomMessageBox.Show("Cập nhật thành công!", "Thông báo", false, 1); frmHomePage.staffLogin = staffDTO; InitDisplay(false); InitfrmInfoStaff(); } else { XtraCustomMessageBox.Show("Cập nhật thất bại!", "Lỗi", false, 4); } }
public bool CheckLoginToSystem(String strUsername, String strPassword) { strUsername = Utils.StandStringSpace(strUsername); strPassword = Utils.StandStringSpace(strPassword); strPassword = Utils.GetMD5(strPassword); DTOStaff staff = GetStaffByUserNameToObject(strUsername); if (staff != null) { if (staff.Password.Equals(strPassword) && staff.UserName.Equals(strUsername)) { return(true); } else { return(false); } } else { return(false); } }
private void bbtnLogout_ItemClick(object sender, ItemClickEventArgs e) { if (xtraTabbedMdiManagerMenu.FloatForms.Count != 0) { XtraCustomMessageBox.Show("Vui lòng đóng tất cả các của sổ trước khi đăng xuất!", "Thông báo", false, 1); } else { DialogResult rs = XtraCustomMessageBox.Show("Bạn có muốn đăng xuất khỏi hệ thông?", "Thông báo", false, 2); if (rs == DialogResult.Yes) { new frmLogin().Show(); staffLogin = null; rolePermissionObj = null; // this.Dispose(); this.Close(); } else { return; } } }