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;
 }
Example #2
0
        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);
        }
Example #3
0
        /// <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;
            }
        }
Example #4
0
        /// <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;
            }
        }
Example #5
0
        /// <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;
            }
        }
Example #6
0
        /// <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 GetStaffByUserNameToObject(String strStaffUsername)
        {
            try
            {
                strStaffUsername = Utils.StandStringSpace(strStaffUsername);

                DataTable tb = GetStaffByUserName(strStaffUsername);

                if (tb.Rows.Count > 0)
                {
                    DTOStaff objStaff = new DTOStaff();
                    objStaff.StaffID = tb.Rows[0][1].ToString();
                    objStaff.Name = tb.Rows[0][2].ToString();
                    objStaff.Gender = tb.Rows[0][3].ToString();
                    objStaff.Birthday = Convert.ToDateTime(tb.Rows[0][4].ToString());
                    objStaff.Address = tb.Rows[0][5].ToString();
                    objStaff.Phone = tb.Rows[0][6].ToString();
                    objStaff.Email = tb.Rows[0][7].ToString();
                    objStaff.DateCreated = Convert.ToDateTime(tb.Rows[0][8].ToString());
                    objStaff.RolePermissionId = tb.Rows[0][9].ToString();
                    objStaff.UserName = tb.Rows[0][10].ToString();
                    objStaff.Password = tb.Rows[0][11].ToString();

                    return objStaff;
                }
                else
                {
                    return null;
                }
            }
            catch (SqlException)
            {
                throw;
            }
        }
Example #7
0
        /// <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
            {
                DataExecute.Instance.createSqlCmd("sp_EditStaffUpdateNoUsernamePassword", new object[9] { staff.StaffID, staff.Name, staff.Gender, staff.Birthday, staff.Address, staff.Phone, staff.Email, staff.DateCreated, staff.RolePermissionId });
                return DataExecute.Instance.updateData(DataConnection.Instance.m_cmd) > 0;
            }
            catch (SqlException)
            {

                throw;
            }
        }
Example #8
0
        public bool InsertStaff(DTOStaff staff)
        {
            try
            {
                DataExecute.Instance.createSqlCmd("sp_AddNewStaffInsert", new object[11] { staff.StaffID, staff.Name, staff.Gender, staff.Birthday, staff.Address, staff.Phone, staff.Email, staff.DateCreated, staff.RolePermissionId, staff.UserName, staff.Password });
                return DataExecute.Instance.updateData(DataConnection.Instance.m_cmd) > 0;
            }
            catch (SqlException)
            {

                throw;
            }
        }
Example #9
0
 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);
     }
 }
Example #10
0
        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);
            }
        }