コード例 #1
0
ファイル: PayrollDetail.aspx.cs プロジェクト: war-man/HRM
        /// <summary>
        /// Sinh cột động
        /// </summary>
        public void InitDynamicColumn()
        {
            // get payroll
            var payroll = PayrollController.GetById(int.Parse(hdfPayrollId.Text));

            if (payroll == null)
            {
                return;
            }

            grpPayrollDetail.Title = payroll.Title;

            // get salary board config
            var salaryBoardConfigs = SalaryBoardConfigController.GetAll(payroll.ConfigId, true, null, null, null, null, null);


            //sort list by columnExcel
            salaryBoardConfigs.Sort((x, y) => CompareUtil.CompareStringByLength(x.ColumnExcel, y.ColumnExcel));


            foreach (var config in salaryBoardConfigs)
            {
                var recordField = new RecordField
                {
                    Name = config.ColumnCode
                };
                var column = new Column
                {
                    Header    = config.Display,
                    DataIndex = recordField.Name,
                    Width     = 120,
                    Align     = Alignment.Right,
                    Renderer  = { Fn = "RenderValue" },
                    Tooltip   = config.Display,
                };
                switch (config.DataType)
                {
                case SalaryConfigDataType.FieldFormula:
                case SalaryConfigDataType.Formula:
                    column.Css = "font-weight:bold;";
                    break;

                case SalaryConfigDataType.DynamicValue:
                    column.Css = "background:#e6eaf2;";
                    column.Editor.Add(new TextField());
                    break;
                }

                storePayrollDetail.AddField(recordField);
                grpPayrollDetail.ColumnModel.Columns.Add(column);
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DownloadTemplate_Click(object sender, DirectEventArgs e)
        {
            // init table
            var dataTable          = new DataTable();
            var salaryBoardConfigs = new List <SalaryBoardConfigModel>();
            var payroll            = new PayrollModel();
            var salaryBoardInfos   = new List <SalaryBoardInfoModel>();

            // adjust table
            dataTable.Rows.Add();
            dataTable.Columns.Add(new DataColumn(EmployeeCode));
            dataTable.Columns.Add(new DataColumn(FullName));

            // get config
            if (!string.IsNullOrEmpty(hdfConfigId.Text))
            {
                salaryBoardConfigs = SalaryBoardConfigController.GetAll(int.Parse(hdfConfigId.Text), null, null, null,
                                                                        SalaryConfigDataType.DynamicValue, null, null);
            }

            // get payroll
            if (!string.IsNullOrEmpty(hdfSalaryBoardListID.Text))
            {
                payroll = PayrollController.GetById(int.Parse(hdfSalaryBoardListID.Text));
            }


            if (salaryBoardConfigs != null)
            {
                foreach (var model in salaryBoardConfigs)
                {
                    dataTable.Columns.Add(new DataColumn(model.Display));
                }
            }

            // get record by department
            if (payroll != null)
            {
                salaryBoardInfos = SalaryBoardInfoController.GetAll(null, payroll.Id.ToString(), null, null);
            }

            // fill employee name and code
            for (var i = 0; i < salaryBoardInfos.Count; i++)
            {
                dataTable.Rows.Add();
                dataTable.Rows[i][EmployeeCode] = salaryBoardInfos[i].EmployeeCode;
                dataTable.Rows[i][FullName]     = salaryBoardInfos[i].FullName;
            }

            ExportToExcel(dataTable, "~/" + Constant.PathTemplate, ImportSalaryExcelFile);
        }
コード例 #3
0
ファイル: SalaryBoardList.aspx.cs プロジェクト: war-man/HRM
        public void SelectSalaryBoard()
        {
            if (!string.IsNullOrEmpty(hdfSalaryBoardListId.Text))
            {
                //Lay danh sach bang luong
                var boardList = PayrollController.GetById(Convert.ToInt32(hdfSalaryBoardListId.Text));

                if (boardList != null)
                {
                    //get all event
                    var lisEvents = GetAllEvents(boardList, false);
                    //TH chua ton tai bang luong thi di tao moi bang luong
                    var salaryBoard = SalaryBoardInfoController.GetAll(null, hdfSalaryBoardListId.Text, null, null);
                    if (salaryBoard != null && salaryBoard.Count > 0)
                    {
                        if (bool.Parse(hdfChkIsUpdateTimeSheet.Text))
                        {
                            //Truong hop da co bang luong, thi cap nhat lai du lieu tu cham cong cho moi recordId
                            foreach (var salary in salaryBoard)
                            {
                                var salaryInfo = SalaryBoardInfoController.GetById(salary.Id);

                                //Lay tu timeSheet
                                GetDataFromTimeSheet(salaryInfo, lisEvents);
                                //Update
                                SalaryBoardInfoController.Update(salaryInfo);
                            }
                        }

                        if (bool.Parse(hdfChkIsUpdateSalary.Text))
                        {
                            //Truong hop da co bang luong, thi cap nhat lai du lieu tu luong cho moi recordId
                            foreach (var salary in salaryBoard)
                            {
                                var salaryInfo = SalaryBoardInfoController.GetById(salary.Id);

                                //Lay tu sal_SalaryDecision
                                EditDataSalary(salary.RecordId, salaryInfo);

                                //Update
                                SalaryBoardInfoController.Update(salaryInfo);
                            }
                        }
                    }
                }
                Response.Redirect(SalaryBoardInfoUrl + "?mId=" + MenuId + "&id=" + hdfSalaryBoardListId.Text, true);
            }
        }
コード例 #4
0
ファイル: SalaryBoardList.aspx.cs プロジェクト: war-man/HRM
        /// <summary>
        /// Init setting window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InitWindow(object sender, DirectEventArgs e)
        {
            ResetForm();
            var param = e.ExtraParams["Id"];

            if (int.TryParse(param, out var id))
            {
                if (id > 0)
                {
                    // edit
                    EmployeeGrid.Disabled  = true;
                    cbxDepartment.Disabled = true;
                    wdSetting.Title        = @"Sửa bảng lương";
                    wdSetting.Icon         = Icon.Pencil;
                }
                else
                {
                    // insert
                    EmployeeGrid.Disabled  = false;
                    cbxDepartment.Disabled = false;
                    wdSetting.Title        = @"Thêm mới bảng lương";
                    wdSetting.Icon         = Icon.Add;
                }
                hdfSalaryBoardListId.Text = id.ToString();
                var payrollModel = new PayrollModel();

                if (id > 0)
                {
                    var result = PayrollController.GetById(Convert.ToInt32(hdfSalaryBoardListId.Text));
                    if (result != null)
                    {
                        payrollModel = result;
                    }
                    //data
                    txtName.Text       = payrollModel.Title;
                    txtCode.Text       = payrollModel.Code;
                    txtNote.Text       = payrollModel.Description;
                    hdfConfigId.Text   = payrollModel.ConfigId.ToString();
                    cbxConfigList.Text = payrollModel.ConfigName;
                }
                hdfMonth.Text = payrollModel.Month.ToString();
                cbxMonth.Text = payrollModel.Month.ToString();
                hdfYear.Text  = payrollModel.Year.ToString();
                spnYear.Text  = payrollModel.Year.ToString();
                // show window
                wdSetting.Show();
            }
        }
コード例 #5
0
ファイル: PayrollDetail.aspx.cs プロジェクト: war-man/HRM
        protected void Page_Load(object sender, EventArgs e)
        {
            hdfPayrollId.Text = Request.QueryString["id"];
            // get payroll
            _payroll = PayrollController.GetById(int.Parse(hdfPayrollId.Text));

            if (!ExtNet.IsAjaxRequest)
            {
                if (_payroll != null)
                {
                    hdfConfigId.Text = _payroll.ConfigId.ToString();
                    ReloadGrid();
                }
            }

            InitDynamicColumn();
        }
コード例 #6
0
ファイル: PayrollDetail.aspx.cs プロジェクト: war-man/HRM
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUnlock_Click(object sender, DirectEventArgs e)
        {
            // get payroll
            _payroll = PayrollController.GetById(int.Parse(hdfPayrollId.Text));

            if (_payroll == null)
            {
                return;
            }

            // lock payroll
            _payroll.Status = PayrollStatus.Active;

            // update payroll
            PayrollController.Update(_payroll);

            ReloadGrid();
        }
コード例 #7
0
 public void GetConfig()
 {
     try
     {
         if (!string.IsNullOrEmpty(hdfPayrollId.Text))
         {
             var payroll = PayrollController.GetById(Convert.ToInt32(hdfPayrollId.Text));
             if (payroll != null)
             {
                 hdfConfigId.Text = payroll.ConfigId.ToString();
             }
         }
     }
     catch (Exception exception)
     {
         Dialog.Alert(exception.Message);
     }
 }
コード例 #8
0
        /// <summary>
        /// Sinh cột và record field động
        /// </summary>
        private void InitDynamicColumn()
        {
            if (string.IsNullOrEmpty(hdfSalaryBoardListID.Text))
            {
                return;
            }

            // get payroll
            var payroll = PayrollController.GetById(Convert.ToInt32(hdfSalaryBoardListID.Text));

            if (payroll == null)
            {
                return;
            }

            // get payroll config
            var salaryBoardConfigs = SalaryBoardConfigController.GetAll(payroll.ConfigId, true, null, null,
                                                                        SalaryConfigDataType.DynamicValue, null, null);

            foreach (var salaryBoardConfig in salaryBoardConfigs)
            {
                // init record field
                var recordField = new RecordField
                {
                    Name = salaryBoardConfig.ColumnCode,
                };

                // init column
                var column = new Column
                {
                    DataIndex = recordField.Name,
                    Header    = salaryBoardConfig.Display,
                    Width     = 120,
                    Align     = Alignment.Right,
                    Tooltip   = salaryBoardConfig.Description,
                    Editor    = { new TextField() },
                    Renderer  = { Fn = "RenderValue" }
                };

                storeAdjustment.AddField(recordField);
                gridColumnDynamic.ColumnModel.Columns.Add(column);
            }
        }
コード例 #9
0
ファイル: PayrollDetail.aspx.cs プロジェクト: war-man/HRM
        public void SaveData(string json)
        {
            // get payroll
            _payroll = PayrollController.GetById(int.Parse(hdfPayrollId.Text));

            if (_payroll == null)
            {
                return;
            }

            // save data
            _payroll.Data = json;

            var table = PayrollController.GetPayrollDetail(null, _payroll.Id, null, null);

            if (table.Rows.Count > 0)
            {
                for (var i = 0; i < table.Rows.Count; i++)
                {
                    //save payrollInfo
                    var payrollInfo = new PayrollInfoModel()
                    {
                        SalaryBoardId = _payroll.Id,
                        RecordId      = table.Rows[i]["RecordId"] != null?Convert.ToInt32(table.Rows[i]["RecordId"].ToString()) : 0,
                                            TotalIncome      = 0,
                                            IndividualTax    = 0,
                                            EnterpriseSocial = 0,
                                            LaborerSocial    = 0,
                                            ActualSalary     = 0,
                                            Month            = _payroll.Month,
                                            Year             = _payroll.Year,
                                            CreatedBy        = "admin",
                                            CreatedDate      = DateTime.Now,
                                            EditedBy         = "",
                                            EditedDate       = DateTime.Now,
                                            IsDeleted        = false
                    };

                    //check exist column
                    if (table.Columns.Contains("{0}".FormatWith(Constant.IndividualTax)))
                    {
                        payrollInfo.IndividualTax = table.Rows[i]["IndividualTax"] != null
                            ? Convert.ToDecimal(table.Rows[i]["IndividualTax"].ToString())
                            : 0;
                    }
                    if (table.Columns.Contains("{0}".FormatWith(Constant.TotalIncome)))
                    {
                        payrollInfo.TotalIncome = table.Rows[i]["TotalIncome"] != null
                            ? Convert.ToInt32(table.Rows[i]["TotalIncome"].ToString())
                            : 0;
                    }
                    if (table.Columns.Contains("{0}".FormatWith(Constant.EnterpriseSocialInsurance)))
                    {
                        payrollInfo.EnterpriseSocial = table.Rows[i]["EnterpriseSocialInsurance"] != null
                            ? Convert.ToInt32(table.Rows[i]["EnterpriseSocialInsurance"].ToString())
                            : 0;
                    }
                    if (table.Columns.Contains("{0}".FormatWith(Constant.LaborerSocialInsurance)))
                    {
                        payrollInfo.LaborerSocial = table.Rows[i]["LaborerSocialInsurance"] != null
                            ? Convert.ToInt32(table.Rows[i]["LaborerSocialInsurance"].ToString())
                            : 0;
                    }
                    if (table.Columns.Contains("{0}".FormatWith(Constant.ActualSalary)))
                    {
                        payrollInfo.ActualSalary = table.Rows[i]["ActualSalary"] != null
                            ? Convert.ToInt32(table.Rows[i]["ActualSalary"].ToString())
                            : 0;
                    }

                    var checkExistModel = PayrollInfoController.GetUnique(payrollInfo.SalaryBoardId, payrollInfo.RecordId, payrollInfo.Month, payrollInfo.Year);
                    if (checkExistModel != null)
                    {
                        payrollInfo.Id         = checkExistModel.Id;
                        payrollInfo.EditedDate = DateTime.Now;
                        payrollInfo.EditedBy   = CurrentUser.User.UserName;
                        //update
                        PayrollInfoController.Update(payrollInfo);
                    }
                    else
                    {
                        //create
                        PayrollInfoController.Create(payrollInfo);
                    }
                }
            }

            // update payroll
            PayrollController.Update(_payroll);
        }
コード例 #10
0
ファイル: SalaryBoardList.aspx.cs プロジェクト: war-man/HRM
        /// <summary>
        /// Insert or Update Catalog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void InsertOrUpdate(object sender, DirectEventArgs e)
        {
            var payrollModel = new PayrollModel();

            // check id
            if (!string.IsNullOrEmpty(hdfSalaryBoardListId.Text) && Convert.ToInt32(hdfSalaryBoardListId.Text) > 0)
            {
                var result = PayrollController.GetById(Convert.ToInt32(hdfSalaryBoardListId.Text));
                if (result != null)
                {
                    payrollModel = result;
                }
            }
            // set new props
            if (!string.IsNullOrEmpty(hdfConfigId.Text))
            {
                payrollModel.ConfigId = Convert.ToInt32(hdfConfigId.Text);
            }

            if (!string.IsNullOrEmpty(hdfMonth.Text))
            {
                payrollModel.Month = Convert.ToInt32(hdfMonth.Text);
            }
            if (!string.IsNullOrEmpty(hdfYear.Text))
            {
                payrollModel.Year = Convert.ToInt32(hdfYear.Text);
            }
            payrollModel.Title       = txtName.Text;
            payrollModel.Code        = txtCode.Text;
            payrollModel.Description = txtNote.Text;
            if (payrollModel.Id > 0)
            {
                payrollModel.EditedDate = DateTime.Now;
                payrollModel.EditedBy   = CurrentUser.User.UserName;
                // update
                var resultModel = PayrollController.Update(payrollModel);
                // check if payroll code exists
                if (resultModel != null)
                {
                    // show success message
                    Dialog.ShowNotification("Lưu thành công");
                    wdSetting.Hide();
                    ResetForm();
                }
                else
                {
                    Dialog.ShowNotification("Mã bảng lương đã tồn tại");
                }
            }
            else
            {
                payrollModel.CreatedDate = DateTime.Now;
                payrollModel.CreatedBy   = CurrentUser.User.UserName;
                payrollModel.EditedDate  = DateTime.Now;
                payrollModel.EditedBy    = CurrentUser.User.UserName;
                // create payroll
                var resultModel = PayrollController.Create(payrollModel);
                // check if payroll code exists
                if (resultModel != null)
                {
                    // init list
                    var listEvents = GetAllEvents(resultModel, true);
                    // create  salaryBoardInfo
                    foreach (var employee in chkEmployeeRowSelection.SelectedRows)
                    {
                        var salaryInfo = new SalaryBoardInfoModel(new hr_SalaryBoardInfo())
                        {
                            RecordId      = Convert.ToInt32(employee.RecordID),
                            SalaryBoardId = resultModel.Id,
                            CreatedDate   = DateTime.Now,
                            EditedDate    = DateTime.Now
                        };

                        //Lay tu timeSheet
                        GetDataFromTimeSheet(salaryInfo, listEvents);
                        //Lay tu sal_SalaryDecision
                        EditDataSalary(salaryInfo.RecordId, salaryInfo);

                        //create
                        SalaryBoardInfoController.Create(salaryInfo);
                    }
                    // show success message
                    Dialog.ShowNotification("Lưu thành công");
                    wdSetting.Hide();
                    ResetForm();
                }
                else
                {
                    Dialog.ShowNotification("Mã bảng lương đã tồn tại");
                }
            }
            grdSalaryBoardList.Reload();
        }
コード例 #11
0
ファイル: DynamicReportView.aspx.cs プロジェクト: war-man/HRM
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private XtraReport InitPayrollReport(ReportDynamicModel report)
        {
            // check payroll config id
            if (!int.TryParse(report.Argument, out var payrollConfigId) || payrollConfigId <= 0)
            {
                // invalid argument
                return(null);
            }

            // set current payroll config id
            hdfPayrollConfigId.Text = payrollConfigId.ToString();

            // check payroll id
            if (!int.TryParse(hdfPayrollId.Text, out var payrollId) || payrollId <= 0)
            {
                // get last payroll
                var payrolls = PayrollController.GetAll(null, payrollConfigId, hdfSelectedDepartmentIds.Text, null, null, null, false, null, 1);

                // check result
                if (payrolls.Count > 0)
                {
                    // set current payroll id
                    hdfPayrollId.Text = payrolls.First().Id.ToString();

                    // payroll selected
                    cboPayroll.Text = payrolls.First().Title;
                }
                else
                {
                    // no payroll found
                    return(null);
                }
            }
            else
            {
                // get payroll by id
                var payroll = PayrollController.GetById(payrollId);

                if (payroll != null)
                {
                    // get month and year
                    var payrollMonth = payroll.Month;
                    var payrollYear  = payroll.Year;

                    // set payroll start date
                    report.StartDate = new DateTime(payrollYear, payrollMonth, 1);

                    // set payroll end date
                    report.EndDate = new DateTime(payrollYear, payrollMonth, DateTime.DaysInMonth(payrollYear, payrollMonth));

                    // payroll selected
                    cboPayroll.Text = payroll.Title;
                }
                else
                {
                    // no payroll found
                    return(null);
                }
            }

            // init payroll report
            XtraReport rpHRM_Payroll = new rpHRM_Payroll_A4_Landscape(report.Id, payrollId);

            // check paper kind and orientation
            switch (report.PaperKind)
            {
            case ReportPaperKind.A4:
                switch (report.Orientation)
                {
                case ReportOrientation.Landscape:
                    rpHRM_Payroll = new rpHRM_Payroll_A4_Landscape(report.Id, payrollId);
                    break;

                case ReportOrientation.Portrait:
                    rpHRM_Payroll = new rpHRM_Payroll_A4_Potrait(report.Id, payrollId);
                    break;
                }
                break;

            case ReportPaperKind.A3:
                switch (report.Orientation)
                {
                case ReportOrientation.Landscape:
                    rpHRM_Payroll = new rpHRM_Payroll_A3_Landscape(report.Id, payrollId);
                    break;

                case ReportOrientation.Portrait:
                    rpHRM_Payroll = new rpHRM_Payroll_A3_Potrait(report.Id, payrollId);
                    break;
                }
                break;

            case ReportPaperKind.A2:
                switch (report.Orientation)
                {
                case ReportOrientation.Landscape:
                    rpHRM_Payroll = new rpHRM_Payroll_A2_Landscape(report.Id, payrollId);
                    break;

                case ReportOrientation.Portrait:
                    rpHRM_Payroll = new rpHRM_Payroll_A2_Landscape(report.Id, payrollId);
                    break;
                }
                break;
            }

            // init extra report
            return(rpHRM_Payroll);
        }