Example #1
0
        /// <summary>
        /// thiet lap lich lam viec cho nhung nhan vien duoc chon
        /// </summary>
        private void SetWorkingTime()
        {
            int DeparmentID = (int)departmentTreeView.SelectedNode.Tag;
            int employeeID  = 0;

            try
            {
                //				dsWorkingTime = workingTimeDO.GetWorkingTimeByMonthNew(1, CurrentMonth, CurrentYear);
                dsEmployee          = employeeDO.GetEmployeeByDepartment(DeparmentID);
                WorkingTimeDataRows = dsEmployee.Tables[0].Select(dataFilter, dataSort);
                // hien thi form thong bao trang thai hoan thanh
                frmStatusMessage message   = new frmStatusMessage();
                string           strStatus = WorkingContext.LangManager.GetString("frmStatus_thongbao");
                //message.Show("Đang sinh dữ liệu bảng chấm công, xin chờ trong giây lát...");
                message.Show("Đang cập nhật lịch làm thêm cho nhân viên ...");
                message.ProgressBar.Value = 0;
                //			int totalEmployees = dataRows.Length;
                Cursor = Cursors.WaitCursor;
                int percentToComplete = 0;
                int percentProcessing = 0;

                for (int i = 0; i < lvwListEmployee.SelectedIndicies.Length; i++)
                {
                    ++percentProcessing;
                    //					AddWorkingTimeByEmployee(dsWorkingTime,1);
                    // chỉ số hàng được chọn
                    int     rowIndex = (int)lvwListEmployee.SelectedItems[i].Tag;
                    DataRow dr       = dsEmployee.Tables[0].Rows[rowIndex];
                    employeeID = int.Parse(dr["EmployeeID"].ToString());
                    //dsWorkingTime = workingTimeDO.GetWorkingTimeByMonth(employeeID, CurrentMonth, CurrentYear);
                    //if (dsWorkingTime.Tables[0].Rows.Count > 0)
                    //{
                    //    UpdateWorkingTimeByEmployee(dsWorkingTime, employeeID);
                    //}
                    //else
                    //{
                    shiftDO = new ShiftDO();
                    shiftDO.DeleteOverTimeInMonth(CurrentMonth, CurrentYear);
                    AddWorkingTimeByEmployee(employeeID);
                    //}
                    percentToComplete         = (percentProcessing * 100) / lvwListEmployee.SelectedIndicies.Length;
                    message.ProgressBar.Value = percentToComplete;
                }
                message.Close();

                Cursor = Cursors.Default;

                string str  = WorkingContext.LangManager.GetString("frmRegWork_Up_Messa");
                string str1 = WorkingContext.LangManager.GetString("frmRegWork_Up_Title");
                //MessageBox.Show("Đăng ký thời gian làm việc thành công", "Đăng ký thời gian làm việc", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                string str  = WorkingContext.LangManager.GetString("frmLunch_SetLunch_ThongBao");
                string str1 = WorkingContext.LangManager.GetString("frmLunch_SetLunch_Title");
                //MessageBox.Show("Có lỗi xảy ra khi cập nhật dữ liệu ăn trưa", "Thiết lập ăn trưa", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btnExcel_Click(object sender, EventArgs e)
        {
            frmStatusMessage message = new frmStatusMessage();
            string           str     = WorkingContext.LangManager.GetString("frmListPunish_messa1");

            //message.Show("Đang xuất dữ liệu bảng thẻ phạt ra file Excel...");
            message.Show(str);
            this.Cursor = Cursors.WaitCursor;
            if (!Utils.ExportExcel(lvwListPunish, this.Text))
            {
                string str1 = WorkingContext.LangManager.GetString("frmListSalary_btnXuatE_ThongBao1");
                string str2 = WorkingContext.LangManager.GetString("Xuất Excel");
                //MessageBox.Show("Có lỗi xảy ra khi xuất dữ liệu ra file excel", "Xuất excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox.Show(str1, str2, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            message.Close();
            this.Cursor = Cursors.Default;
        }
Example #3
0
        private void btnExcelBarCode_Click(object sender, EventArgs e)
        {
            frmStatusMessage message = new frmStatusMessage();
            //message.Show("Xu?t danh sách ra file excel...");
            string str_xuat = WorkingContext.LangManager.GetString("frmListEmployee_Excel_frmMessa");
            message.Show(str_xuat);
            this.Cursor = Cursors.WaitCursor;

            PopulateEmployeeListView();

            if (!Utils.ExportExcelBC(lvwEmployeeBarcode, this.Text.ToUpper()))
            {
                string str = WorkingContext.LangManager.GetString("frmListEm_XuatExcel_Error");
                string str1 = WorkingContext.LangManager.GetString("frmListEm_XuatExcel_Error_Title");
                //MessageBox.Show("Có l?i x?y ra khi xu?t d? li?u ra file excel", "Xu?t excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            message.Close();
            this.Cursor = Cursors.Default;
        }
Example #4
0
        private void btnExcelBarCode_Click(object sender, EventArgs e)
        {
            frmStatusMessage message = new frmStatusMessage();
            //message.Show("Xu?t danh sách ra file excel...");
            string str_xuat = WorkingContext.LangManager.GetString("frmListEmployee_Excel_frmMessa");

            message.Show(str_xuat);
            this.Cursor = Cursors.WaitCursor;

            PopulateEmployeeListView();

            if (!Utils.ExportExcelBC(lvwEmployeeBarcode, this.Text.ToUpper()))
            {
                string str  = WorkingContext.LangManager.GetString("frmListEm_XuatExcel_Error");
                string str1 = WorkingContext.LangManager.GetString("frmListEm_XuatExcel_Error_Title");
                //MessageBox.Show("Có l?i x?y ra khi xu?t d? li?u ra file excel", "Xu?t excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            message.Close();
            this.Cursor = Cursors.Default;
        }
Example #5
0
        /// <summary>
        /// thiet lap lich lam viec cho nhung nhan vien duoc chon
        /// </summary>
        private void SetWorkingTime()
        {
            int DeparmentID = (int)departmentTreeView.SelectedNode.Tag;
            int employeeID = 0;
            try
            {
                //				dsWorkingTime = workingTimeDO.GetWorkingTimeByMonthNew(1, CurrentMonth, CurrentYear);
                dsEmployee = employeeDO.GetEmployeeByDepartment(DeparmentID);
                WorkingTimeDataRows = dsEmployee.Tables[0].Select(dataFilter, dataSort);
                // hien thi form thong bao trang thai hoan thanh
                frmStatusMessage message = new frmStatusMessage();
                string strStatus = WorkingContext.LangManager.GetString("frmStatus_thongbao");
                //message.Show("Đang sinh dữ liệu bảng chấm công, xin chờ trong giây lát...");
                message.Show("Đang cập nhật lịch làm thêm cho nhân viên ...");
                message.ProgressBar.Value = 0;
                //			int totalEmployees = dataRows.Length;
                Cursor = Cursors.WaitCursor;
                int percentToComplete = 0;
                int percentProcessing = 0;

                for (int i = 0; i < lvwListEmployee.SelectedIndicies.Length; i++)
                {
                    ++percentProcessing;
                    //					AddWorkingTimeByEmployee(dsWorkingTime,1);
                    // chỉ số hàng được chọn
                    int rowIndex = (int)lvwListEmployee.SelectedItems[i].Tag;
                    DataRow dr = dsEmployee.Tables[0].Rows[rowIndex];
                    employeeID = int.Parse(dr["EmployeeID"].ToString());
                    //dsWorkingTime = workingTimeDO.GetWorkingTimeByMonth(employeeID, CurrentMonth, CurrentYear);
                    //if (dsWorkingTime.Tables[0].Rows.Count > 0)
                    //{
                    //    UpdateWorkingTimeByEmployee(dsWorkingTime, employeeID);
                    //}
                    //else
                    //{
                    shiftDO = new ShiftDO();
                    shiftDO.DeleteOverTimeInMonth(CurrentMonth, CurrentYear);
                    AddWorkingTimeByEmployee(employeeID);
                    //}
                    percentToComplete = (percentProcessing * 100) / lvwListEmployee.SelectedIndicies.Length;
                    message.ProgressBar.Value = percentToComplete;

                }
                message.Close();

                Cursor = Cursors.Default;

                string str = WorkingContext.LangManager.GetString("frmRegWork_Up_Messa");
                string str1 = WorkingContext.LangManager.GetString("frmRegWork_Up_Title");
                //MessageBox.Show("Đăng ký thời gian làm việc thành công", "Đăng ký thời gian làm việc", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                string str = WorkingContext.LangManager.GetString("frmLunch_SetLunch_ThongBao");
                string str1 = WorkingContext.LangManager.GetString("frmLunch_SetLunch_Title");
                //MessageBox.Show("Có lỗi xảy ra khi cập nhật dữ liệu ăn trưa", "Thiết lập ăn trưa", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #6
0
        private void btnExcel_Click(object sender, System.EventArgs e)
        {
            //frmStatusMessage message = new frmStatusMessage();
            ////message.Show("Xuất danh sách ra file excel...");
            //string str_xuat = WorkingContext.LangManager.GetString("frmListEmployee_Excel_frmMessa");
            //message.Show(str_xuat);
            //this.Cursor = Cursors.WaitCursor;

            //bool bThoiViec = false;
            //if (checkEmployeeDeleted)
            //    bThoiViec = true;

            //bool bExport = Utils.ExportExcelForEmployee(lvwEmployee, this.Text.ToUpper(), bThoiViec);
            ////if (!Utils.ExportExcel(lvwEmployee, this.Text.ToUpper()))
            //if (!bExport)
            //{
            //    string str = WorkingContext.LangManager.GetString("frmListEm_XuatExcel_Error");
            //    string str1 = WorkingContext.LangManager.GetString("frmListEm_XuatExcel_Error_Title");
            //    //MessageBox.Show("Có lỗi xảy ra khi xuất dữ liệu ra file excel", "Xuất excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
            //message.Close();
            //this.Cursor = Cursors.Default;

            frmStatusMessage message = new frmStatusMessage();
            //message.Show("Xuất danh sách ra file excel...");
            string str_xuat = WorkingContext.LangManager.GetString("frmListEmployee_Excel_frmMessa");
            message.Show(str_xuat);
            this.Cursor = Cursors.WaitCursor;

            bool bThoiViec = false;
            if (checkEmployeeDeleted)
                bThoiViec = true;

            System.Data.DataTable tblExcelPri = KhoiTaoDuLieuBangLuuThongTinXuatExcel(bThoiViec);
            if (tblExcelPri != null && tblExcelPri.Rows.Count > 0)
            {
                // Xuất excel
                if(bThoiViec)
                    ExportToExcel.XuatDuLieuRaExcel(4, 0, string.Empty, tblExcelPri, DANH_SACH_NHAN_VIEN_THOI_VIEC);
                else
                    ExportToExcel.XuatDuLieuRaExcel(4, 0, string.Empty, tblExcelPri, DANH_SACH_NHAN_VIEN);
            }

            message.Close();
            this.Cursor = Cursors.Default;
        }
Example #7
0
 private void btnExcel_Click(object sender, EventArgs e)
 {
     frmStatusMessage message = new frmStatusMessage();
     string str = WorkingContext.LangManager.GetString("frmListPunish_messa1");
     //message.Show("Đang xuất dữ liệu bảng thẻ phạt ra file Excel...");
     message.Show(str);
     this.Cursor = Cursors.WaitCursor;
     if (!Utils.ExportExcel(lvwListPunish,this.Text))
     {
         string str1 = WorkingContext.LangManager.GetString("frmListSalary_btnXuatE_ThongBao1");
         string str2 = WorkingContext.LangManager.GetString("Xuất Excel");
         //MessageBox.Show("Có lỗi xảy ra khi xuất dữ liệu ra file excel", "Xuất excel", MessageBoxButtons.OK, MessageBoxIcon.Error);
         MessageBox.Show(str1, str2, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     message.Close();
     this.Cursor = Cursors.Default;
 }
Example #8
0
        /// <summary>
        /// Hiển thị trạng thái của từng nhân viên
        /// </summary>
        /// <param name="PageIndex"></param>
        private void LoadBoxesByPage(int PageIndex)
        {
            this.groupBox2.Text = WorkingContext.LangManager.GetString("frmEmployeeStatus_GroupBox2");
            if (cboDepartment.SelectedIndex != -1)
            {
                dsEmployeeStatus =
                    statusDO.GetEmployeeStatus((int) cboDepartment.SelectedValue, DateTime.Today, cboSort.SelectedIndex,
                                               PageIndex - 1, BoxesPerPage);
                if (dsEmployeeStatus != null)
                {
                    dataRows = dsEmployeeStatus.Tables[1].Select(dataFilter);
                    if (dataRows.Length == 0)
                    {
                        RemoveStatusBox();
                        AddNoEmployeeLabel();
                        NumPages = 0;
                    }
                    else
                    {
                        totalLate = 0;
                        //				totalWorking=dsEmployeeStatus.Tables[1].Select("Status =" +1+"OR Status = "+7).Length;
                        //				totalLeave=dsEmployeeStatus.Tables[1].Select("Status =" +2).Length;
                        //				totalAbsent=dsEmployeeStatus.Tables[1].Select("Status =" +4+"OR Status = "+8+ "OR Status ="+3).Length;
                        //				totalGoHome=dsEmployeeStatus.Tables[1].Select("Status =" +5 +"OR Status = "+9).Length;

                        RowCount = int.Parse(dsEmployeeStatus.Tables[0].Rows[0][0].ToString());
                        NumPages = RowCount/BoxesPerPage;
                        if (RowCount%BoxesPerPage != 0)
                        {
                            NumPages++;
                        }
                    }

                    frmStatusMessage message = new frmStatusMessage();
                    string str = WorkingContext.LangManager.GetString("frmStatus_thongbao");
                    //message.Show("Đang sinh dữ liệu bảng chấm công, xin chờ trong giây lát...");
                    message.Show(str);
                    message.ProgressBar.Value = 0;
                    //			int totalEmployees = dataRows.Length;
                    this.Cursor = Cursors.WaitCursor;
                    int percentToComplete = 0;
                    int percentProcessing = 0;

                    RemoveStatusBox();
                    txtRecordNum.Text = PageIndex + "/" + NumPages;
                    int i = 0;
                    int lns = 0;
                    int cols = 0;
                    int numbox = 0;

                    numbox = PanelWidth/BoxWidth; // số box tối đa có thể vẽ được trong 1 dòng

                    ctrStatusBox statusBox;

                    for (int box = 0; box < dataRows.Length; box++)
                    {
                        ++percentProcessing;
                        DataRow dr = dataRows[box];
                        cols = i%numbox; //chỉ số của box trong 1 dòng
                        lns = i/numbox; //chỉ số của dòng

                        statusBox = new ctrStatusBox();
                        statusBox.EmployeeID = int.Parse(dr["EmployeeID"].ToString());
                        // Tên nhân viên
                        statusBox.lblEmployeeName.Text = dr["EmployeeName"].ToString();
                        DateTime timeIn = new DateTime();
                        if (dr["TimeIn"] != DBNull.Value)
                        {
                            timeIn = DateTime.Parse(dr["TimeIn"].ToString());
                            statusBox.lblTimeIn.Text = timeIn.ToString("HH:mm");
                        }
                        else
                        {
                            statusBox.lblTimeIn.Text = "";
                        }

                        DateTime timeOut = new DateTime();
                        //				string TimeIn = "";
                        if (dr["TimeOut"] != DBNull.Value)
                        {
                            timeOut = DateTime.Parse(dr["TimeOut"].ToString());
                            statusBox.lblTimeOut.Text = timeOut.ToString("HH:mm");
                        }
                        else
                        {
                            statusBox.lblTimeOut.Text = "";
                        }

                        dsEmployeeLate =
                            statusDO.GetCheckInTime(int.Parse(dr["EmployeeID"].ToString()), DateTime.Today.Date);
                        DateTime checkIn = new DateTime(1900, 1, 1, 8, 0, 0, 0);
                            //mac dinh neu ko dang ky lich lam viec thi gio dau ca la 8h, cuoi ca la 17h
                        DateTime checkOut = new DateTime(1900, 1, 1, 17, 0, 0, 0);
                        DateTime lunchTime = new DateTime(1900, 1, 1, 1, 0, 0, 0);
                        if (dsEmployeeLate.Tables[0].Rows.Count > 0)
                        {
                            if (dsEmployeeLate.Tables[0].Rows[0]["CheckIn"] != DBNull.Value)
                            {
                                checkIn = DateTime.Parse(dsEmployeeLate.Tables[0].Rows[0]["CheckIn"].ToString());
                            }
                            if (dsEmployeeLate.Tables[0].Rows[0]["LunchTime"] != DBNull.Value)
                            {
                                lunchTime = DateTime.Parse(dsEmployeeLate.Tables[0].Rows[0]["LunchTime"].ToString());
                            }
                            if (dsEmployeeLate.Tables[0].Rows[0]["CheckOut"] != DBNull.Value)
                            {
                                checkOut = DateTime.Parse(dsEmployeeLate.Tables[0].Rows[0]["checkOut"].ToString());
                                checkOut = checkOut.Add(lunchTime.TimeOfDay);
                            }
                        }

                        // Trạng thái: 0-Vắng mặt; 1-Làm việc; 2-Công tác; 3-Nghỉ phép;
                        int Status = int.Parse(dr["Status"].ToString());
                        switch (Status)
                        {
                            case 1: //làm việc
                                statusBox.picStatus.Image = Image.FromFile("IMAGES/working.gif");
                                if (timeIn.CompareTo(checkIn) > 0)
                                {
                                    statusBox.lblTimeIn.ForeColor = Color.Red;
                                    ++totalLate;
                                }
                                break;
                            case 2: //công tác
                                statusBox.picStatus.Image = Image.FromFile("IMAGES/mission.gif");
                                //						totalLeave++;
                                break;
                            case 3: //đã đăng ký nghỉ phép
                                statusBox.picStatus.Image = Image.FromFile("IMAGES/absent.gif");
                                dsEmployeeRest =
                                    statusDO.GetDayShortNameByEmployeeRest(int.Parse(dr["EmployeeID"].ToString()),
                                                                           DateTime.Today.Date);
                                statusBox.lblLate.Text = "(" +
                                                         dsEmployeeRest.Tables[0].Rows[0]["DayShortName"].ToString() +
                                                         ")";
                                break;
                            case 4: //vắng mặt ko lý do
                                statusBox.picStatus.Image = Image.FromFile("IMAGES/absent.gif");
                                //						totalAbsent++;
                                break;
                            case 5: //về nhà
                                statusBox.picStatus.Image = Image.FromFile("IMAGES/GoHome.gif");
                                //						totalGoHome++;
                                if (timeIn.CompareTo(checkIn) > 0)
                                {
                                    statusBox.lblTimeIn.ForeColor = Color.Red;
                                    ++totalLate;
                                }
                                if (checkOut.CompareTo(timeOut) > 0)
                                {
                                    statusBox.lblTimeOut.ForeColor = Color.Red;
                                }
                                break;
                            case 6: // đăng ký đi muộn
                                statusBox.picStatus.Image = Image.FromFile("IMAGES/late.gif");
                                if (timeIn.CompareTo(checkIn) > 0)
                                {
                                    statusBox.lblTimeIn.ForeColor = Color.Red;
                                    ++totalLate;
                                }
                                statusBox.lblLate.Text = "(" + checkIn.ToString("HH:mm") + ")";
                                break;
                            case 7: //đi làm sau khi đã đăng ký đi muộn
                                if (timeIn.CompareTo(checkIn) > 0)
                                {
                                    statusBox.lblTimeIn.ForeColor = Color.Red;
                                    ++totalLate;
                                }
                                statusBox.lblLate.Text = "(" + checkIn.ToString("HH:mm") + ")";
                                break;
                            case 8: //đã đăng ký đi muộn nhưng vẫn chưa đến
                                statusBox.picStatus.Image = Image.FromFile("IMAGES/absent.gif");
                                statusBox.lblLate.Text = "(" + checkIn.ToString("HH:mm") + ")";
                                break;
                            case 9: ///*Có làm việc, đã đi về sau khi đã đăng ký đi làm muộn */
                                statusBox.picStatus.Image = Image.FromFile("IMAGES/GoHome.gif");
                                if (timeIn.CompareTo(checkIn) > 0)
                                {
                                    statusBox.lblTimeIn.ForeColor = Color.Red;
                                    ++totalLate;
                                }
                                if (timeOut.CompareTo(checkOut) < 0)
                                {
                                    statusBox.lblTimeOut.ForeColor = Color.Red;
                                }
                                statusBox.lblLate.Text = "(" + checkIn.ToString("HH:mm") + ")";
                                break;
                            case 10: //*Có làm việc, đã đi về +đăng ký nghỉ => ko xảy ra*/
                                statusBox.picStatus.Image = Image.FromFile("IMAGES/GoHome.gif");
                                dsEmployeeRest =
                                    statusDO.GetDayShortNameByEmployeeRest(int.Parse(dr["EmployeeID"].ToString()),
                                                                           DateTime.Today.Date);
                                statusBox.lblLate.Text = "(" +
                                                         dsEmployeeRest.Tables[0].Rows[0]["DayShortName"].ToString() +
                                                         ")";
                                break;
                        }
                        // Ảnh nhân viên
                        if (dr["Picture"] != DBNull.Value)
                        {
                            try
                            {
                                string EmployeePicture = WorkingContext.Setting.PicturePath + '\\' +
                                                         dr["Picture"].ToString();
                                statusBox.picEmployee.Image = Image.FromFile(EmployeePicture);
                            }
                            catch
                            {
                                statusBox.picEmployee.Image = Image.FromFile(@"IMAGES/noimage3.jpg");
                            }
                        }
                        else
                        {
                            statusBox.picEmployee.Image = Image.FromFile(@"IMAGES/noimage3.jpg");
                        }
                        int YellowCardCount = int.Parse(dr["YellowCardCount"].ToString());
                        int RedCardCount = int.Parse(dr["RedCardCount"].ToString());

                        if (YellowCardCount > 0)
                        {
                            statusBox.lblYellowCard.BackColor = Color.Yellow;
                            statusBox.lblYellowCard.Text = YellowCardCount.ToString();
                            //totalLeave++;
                        }
                        if (RedCardCount > 0)
                        {
                            statusBox.lblRedCard.BackColor = Color.Red;
                            statusBox.lblRedCard.Text = RedCardCount.ToString();
                            //totalAbsent++;
                        }

                        statusBox.Size = new Size(BoxWidth, BoxHeight);
                        statusBox.Location = new Point(cols*BoxWidth + 10, lns*BoxHeight + 10);

                        pnEmployee.Controls.Add(statusBox);

                        i++;
                        percentToComplete = (percentProcessing*100)/dataRows.Length;
                        message.ProgressBar.Value = percentToComplete;
                    }
                    if (PageIndex == 1)
                        LoadStatistics((int) cboDepartment.SelectedValue);
                    message.Close();
                }
            }
            this.Cursor = Cursors.Default;
        }