Пример #1
0
        /// <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();
        }
Пример #2
0
        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);
        }
Пример #3
0
        /// <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();
        }