示例#1
0
        /// <summary>
        /// Tự động sinh bảng thanh toán tiền phép dựa trên dữ liệu sẵn có
        /// </summary>
        private void GenerateRestSheet()
        {
            frmStatusMessage message = new frmStatusMessage();
            message.Show("Đang sinh dữ liệu bảng thanh toán tiền phép, xin chờ trong giây lát...");
            this.Cursor = Cursors.WaitCursor;
            employeeDO = new EmployeeDO();
            DataSet dsEmployee = employeeDO.GetEmployeeByDepartment(DepartmentID);
            int totalEmployees = dsEmployee.Tables[0].Rows.Count;
            float percentToComplete = 0;
            int percentProcessing = 0;

            restsheetDO.DeleteRegRestInYear(CurrentYear);

            if (dsEmployee.Tables[0].Rows.Count > 0)
            {
                int ret = 0;
                foreach (DataRow dr in dsEmployee.Tables[0].Rows)
                {
                    int EmployeeID = int.Parse(dr["EmployeeID"].ToString());
                    percentProcessing = ++percentProcessing;
                    try
                    {
                        ret = restsheetDO.GenerateRestSheet(CurrentYear, EmployeeID);
                        percentToComplete = (percentProcessing * 100) / totalEmployees;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    message.ProgressBar.Value = (int)percentToComplete;
                }
                message.Close();
                this.Cursor = Cursors.Default;
                if (ret > 0)
                {
                    string str = WorkingContext.LangManager.GetString("frmRestSheet_Sinh_Messa");
                    string str1 = WorkingContext.LangManager.GetString("frmRestSheet_Sinh_Title");
                    //MessageBox.Show("Sinh bảng thanh toán tiền phép thành công", "Sinh bảng thanh toán tiền phép", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    string str = WorkingContext.LangManager.GetString("frmRestSheet_Sinh_Messa1");
                    string str1 = WorkingContext.LangManager.GetString("frmRestSheet_Sinh_Title");
                    //MessageBox.Show("Sinh bảng thanh toán tiền phép thất bại", "Sinh bảng thanh toán tiền phép", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                message.Close();
                this.Cursor = Cursors.Default;
            }
        }
示例#2
0
        /// <summary>
        /// Tự động sinh bảng ăn trưa dựa trên dữ liệu sẵn có
        /// </summary>
        private void GenerateLunchSheet()
        {
            frmStatusMessage message = new frmStatusMessage();
            string str = WorkingContext.LangManager.GetString("frmListLunch_Sinh_Messa1");
            //message.Show("Đang sinh dữ liệu ăn trưa...");
            message.Show(str);
            this.Cursor = Cursors.WaitCursor;
            employeeDO = new EmployeeDO();
            DataSet dsEmployee = employeeDO.GetEmployeeByDepartment(DepartmentID);
            int totalEmployees = dsEmployee.Tables[0].Rows.Count;
            float percentToComplete = 0;
            int percentProcessing = 0;

            if (dsEmployee.Tables[0].Rows.Count > 0)
            {
                int ret = 0;
                foreach (DataRow dr in dsEmployee.Tables[0].Rows)
                {
                    int EmployeeID = int.Parse(dr["EmployeeID"].ToString());
                    percentProcessing= ++percentProcessing;
                    try
                    {
                        ret = lunchDO.GenerateLunchSheet(CurrentMonth, CurrentYear,EmployeeID);
                        percentToComplete = (percentProcessing*100) / totalEmployees;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    message.ProgressBar.Value = (int)percentToComplete;
                }
                message.Close();
                this.Cursor = Cursors.Default;
                if (ret > 0)
                {
                    string str2 = WorkingContext.LangManager.GetString("frmListLunch_Sinh_Messa2");
                    string str3 = WorkingContext.LangManager.GetString("frmListLunch_Sinh_Title");
                    //MessageBox.Show("Sinh bảng ăn trưa thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageBox.Show(str2, str3, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    string str2 = WorkingContext.LangManager.GetString("frmListLunch_Sinh_Messa3");
                    string str3 = WorkingContext.LangManager.GetString("frmListLunch_Sinh_Title");
                    //MessageBox.Show("Sinh bảng ăn trưa thất bại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MessageBox.Show(str2, str3, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                message.Close();
                this.Cursor = Cursors.Default;
            }
        }
示例#3
0
        /// <summary>
        /// Tự động sinh bảng chấm công dựa trên dữ liệu sẵn có
        /// </summary>
        private void GenerateTimeSheet()
        {
            frmStatusMessage message = new frmStatusMessage();
            string str = WorkingContext.LangManager.GetString("frmTimeSheet_frmmessa");
            //message.Show("Đang sinh dữ liệu bảng chấm công, xin chờ trong giây lát...");
            message.Show(str);

            this.Cursor = Cursors.WaitCursor;
            employeeDO = new EmployeeDO();
            DataSet dsEmployee = employeeDO.GetEmployeeByDepartment(DepartmentID);
            int totalEmployees = dsEmployee.Tables[0].Rows.Count;
            float percentToComplete = 0;
            int percentProcessing = 0;
            //DateTime firstMonth = new DateTime(CurrentYear,CurrentMonth+1,1);

            message.ProgressBar.Value = 0;
            if (dsEmployee.Tables[0].Rows.Count > 0)
            {
                int ret = 0, ret1 = 1;
                foreach (DataRow dr in dsEmployee.Tables[0].Rows)
                {
                    percentProcessing = ++percentProcessing;
                    int EmployeeID = int.Parse(dr["EmployeeID"].ToString());
                    //chi tinh cong cho nhung nhan vien chua thoi viec
                    // if (!bool.Parse(dr["Deleted"].ToString()) )
                    //{
                    //if (dr["StartTrial"]!=DBNull.Value)
                    // if (DateTime.Parse(dr["StartTrial"].ToString()) < firstMonth)
                    // {
                    try
                    {
                        ret = timesheetDO.GenerateTimeSheet(CurrentMonth, CurrentYear, EmployeeID);
                        percentToComplete = (percentProcessing * 100) / totalEmployees;
                        //ret1: sinh bảng tổng hợp dữ liệu nhân viên trong tháng để hiển thị trên báo cáo tháng, năm của từng nhân viên
                        //						ret1 = timesheetDO.GenerateEmployeeSummaryInMonth(CurrentMonth, CurrentYear, EmployeeID);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    // }
                    // }
                    message.ProgressBar.Value = (int)percentToComplete;
                    //						(int)(percentToComplete/totalEmployees);
                }
                message.Close();
                this.Cursor = Cursors.Default;
                if (ret >= 0 && ret1 > 0)
                {
                    string str1 = WorkingContext.LangManager.GetString("frmTimeSheet_SinhBang_Messa");
                    string str2 = WorkingContext.LangManager.GetString("frmTimeSheet_SinhBang_Title");
                    //MessageBox.Show("Sinh bảng chấm công thành công", "Sinh bảng chấm công", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageBox.Show(str1, str2, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    string str1 = WorkingContext.LangManager.GetString("frmTimeSheet_SinhBang_Messa1");
                    string str2 = WorkingContext.LangManager.GetString("frmTimeSheet_SinhBang_Title");
                    //MessageBox.Show("Sinh bảng chấm công thất bại", "Sinh bảng chấm công", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MessageBox.Show(str1, str2, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                message.Close();
                this.Cursor = Cursors.Default;
            }
        }
示例#4
0
        private void departmentTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            departmentTreeView.ExpandNodes(true);
            cboEmployeeName.Items.Clear();
            EmployeeDO employeeDO = new EmployeeDO();
            dsEmployee = employeeDO.GetEmployeeByDepartment((int)e.Node.Tag);
            cboEmployeeName.SourceDataString = new string[] { "EmployeeID", "CardID", "EmployeeName" };
            cboEmployeeName.SourceDataTable = dsEmployee.Tables[0];

            // kiểm tra nếu phòng có nhân viên thì hiển thị thông tin của nhân viên đầu tiên
            if (dsEmployee.Tables[0].Rows.Count > 0)
            {
                cboEmployeeName.SelectedIndex = 0;
                cboEmployeeName.Text = ((MTGCComboBoxItem)cboEmployeeName.SelectedItem).Col3;
            }
            else
            {
                cboEmployeeName.Items.Clear();
                cboEmployeeName.Text = "";
            }
        }
示例#5
0
        private void GenerateSalary()
        {
            frmStatusMessage message = new frmStatusMessage();
            string str = WorkingContext.LangManager.GetString("frmListSalary_btnSinh_THongBao3");
            //message.Show("Đang sinh dữ liệu bảng lương...");
            message.Show(str);
            this.Cursor = Cursors.WaitCursor;
            employeeDO = new EmployeeDO();
            DataSet dsEmployee = employeeDO.GetEmployeeByDepartment(DepartmentID);
            int totalEmployees = dsEmployee.Tables[0].Rows.Count;
            float percentToComplete = 0;
            int percentProcessing = 0;
            message.ProgressBar.Value = 0;

            DataSet dsGetAutoGenerateLunchSheet = salaryDO.GetAutoGenerateLunchSheet();
            string checkStatus = dsGetAutoGenerateLunchSheet.Tables[0].Rows[0][0].ToString();
            string ProcedureName = null;
            bool bSalaryHP = true;
            if (dsGetAutoGenerateLunchSheet != null)
                if (string.Compare(checkStatus, "true") == 0 || string.Compare(checkStatus, "True") == 0 || string.Compare(checkStatus, "TRUE") == 0)
                {
                    bSalaryHP = false;
                    ProcedureName = "GenerateSalary_New";
                }
                //else ProcedureName = "GenerateSalary_HP_New";

            if (dsEmployee.Tables[0].Rows.Count > 0)
            {
                int ret = 0;
                if (bSalaryHP)
                {
                    //Lấy về số ngày làm việc trong tháng
                    float fWorkingDayInMonth = 0;
                    fWorkingDayInMonth = salaryDO.GetWorkingDayInMonth(CurrentMonth, CurrentYear);
                    if (fWorkingDayInMonth == 0)
                        fWorkingDayInMonth = WORKING_DAY_IN_MONTH;

                    foreach (DataRow dr in dsEmployee.Tables[0].Rows)
                    {
                        int EmployeeID = int.Parse(dr["EmployeeID"].ToString());
                        percentProcessing = ++percentProcessing;
                        try
                        {
                            ret = ret + salaryDO.GenerateSalary_HP(CurrentMonth, CurrentYear, EmployeeID, fWorkingDayInMonth);
                            percentToComplete = ((float)(percentProcessing) / (float)(totalEmployees)) * 100;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        message.ProgressBar.Value = (int)percentToComplete;
                    }
                }
                else
                {
                    foreach (DataRow dr in dsEmployee.Tables[0].Rows)
                    {
                        int EmployeeID = int.Parse(dr["EmployeeID"].ToString());
                        percentProcessing = ++percentProcessing;
                        try
                        {
                            ret = ret + salaryDO.GenerateSalary(CurrentMonth, CurrentYear, EmployeeID, ProcedureName);
                            percentToComplete = ((float)(percentProcessing) / (float)(totalEmployees)) * 100;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                        message.ProgressBar.Value = (int)percentToComplete;
                    }
                }

                message.Close();
                this.Cursor = Cursors.Default;
                if (ret > 0)
                {
                    string str1 = WorkingContext.LangManager.GetString("frmListSalary_btnSinh_THongBao4");
                    string str2 = WorkingContext.LangManager.GetString("frmListSalary_btnSinh_THongBao_title");
                    //MessageBox.Show("Sinh bảng lương thành công", "Sinh bảng lương", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageBox.Show(str1, str2, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    string str1 = WorkingContext.LangManager.GetString("frmListSalary_btnSinh_THongBao5");
                    string str2 = WorkingContext.LangManager.GetString("frmListSalary_btnSinh_THongBao_title");
                    //MessageBox.Show("Sinh bảng lương thất bại", "Sinh bảng lương", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MessageBox.Show(str1, str2, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                message.Close();
                this.Cursor = Cursors.Default;
            }
        }