コード例 #1
0
        private void DecodeRuleDetails(CustomList <SalaryRule> ruleDetails)
        {
            try
            {
                foreach (SalaryRule item in ruleDetails)
                {
                    var pattern = new Regex(@"(\@.*?\@)", RegexOptions.IgnorePatternWhitespace);

                    foreach (Match m in pattern.Matches(item.Formula2.ToUpper()))
                    {
                        string[]   parts = m.Groups[1].Value.Split('@');
                        SalaryRule obj   = ruleDetails.Find(f => f.HeadName.ToUpper().Trim() == parts[1].ToUpper().Trim());
                        item.Formula2 = item.Formula2.ToUpper().Replace(m.Groups[1].Value, obj.Formula2);
                    }
                    NCalc.Expression exp = new NCalc.Expression(item.Formula2);
                    object           ret = exp.Evaluate();
                    item.Formula2 = ret.ToString();

                    decimal            val = 0M;
                    EmployeeSalaryTemp eST = new EmployeeSalaryTemp();
                    eST.SalaryRuleCode = item.SalaryRuleCode;
                    eST.SalaryHeadKey  = item.SalaryHeadKey;
                    eST.IsFixed        = item.IsFixed;
                    if (decimal.TryParse(item.Formula2, out val))
                    {
                        eST.Amount = Math.Round(val, 2);
                    }
                    _EmpSalaryTempList.Add(eST);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                CustomList <HRM_Emp>            EmpList                = (CustomList <HRM_Emp>)HttpContext.Current.Session["View_EmpList"];
                CustomList <HRM_Emp>            SaveableEmpList        = EmpList.FindAll(f => f.IsChecked == true);
                CustomList <EmployeeSalaryTemp> StructureTempEmpSalary = (CustomList <EmployeeSalaryTemp>)Session["SalaryInfoEntry_grdSalaryEntryList"];
                CustomList <EmployeeSalaryTemp> TempEmpSalary          = new CustomList <EmployeeSalaryTemp>();
                foreach (HRM_Emp H in SaveableEmpList)
                {
                    foreach (EmployeeSalaryTemp S in StructureTempEmpSalary)
                    {
                        EmployeeSalaryTemp ST = new EmployeeSalaryTemp();
                        ST.EmpKey         = H.EmpKey;
                        ST.SalaryHeadKey  = S.SalaryHeadKey;
                        ST.SalaryRuleCode = S.SalaryRuleCode;
                        ST.IsFixed        = S.IsFixed;
                        ST.Amount         = S.Amount;
                        ST.AddedBy        = CurrentUserSession.UserCode;
                        ST.DateAdded      = DateTime.Now;
                        TempEmpSalary.Add(ST);
                    }
                }

                CustomList <EmployeeSalary> InsertSalaryList = new CustomList <EmployeeSalary>();
                CustomList <EmployeeSalary> DeleteSalaryList = new CustomList <EmployeeSalary>();
                if (chkApproved.Checked)
                {
                    TempEmpSalary.ForEach(s => s.DateApproved = DateTime.Now);
                    TempEmpSalary.ForEach(s => s.ApprovedBy   = CurrentUserSession.UserCode);
                    foreach (EmployeeSalaryTemp t in TempEmpSalary)
                    {
                        EmployeeSalary newObjInsert = new EmployeeSalary();
                        newObjInsert.EmpKey         = t.EmpKey;
                        newObjInsert.SalaryRuleCode = t.SalaryRuleCode;
                        newObjInsert.SalaryHeadKey  = t.SalaryHeadKey;
                        newObjInsert.IsFixed        = t.IsFixed;
                        newObjInsert.Amount         = t.Amount;
                        InsertSalaryList.Add(newObjInsert);

                        EmployeeSalary newObjDelete = new EmployeeSalary();
                        newObjDelete.SalaryHeadKey = t.SalaryHeadKey;
                        newObjDelete.EmpKey        = t.EmpKey;
                        newObjDelete.Delete();
                        DeleteSalaryList.Add(newObjDelete);
                    }
                }
                if (!CheckUserAuthentication(TempEmpSalary, DeleteSalaryList, InsertSalaryList))
                {
                    return;
                }
                manager.SaveSalaryInfo(ref TempEmpSalary, ref DeleteSalaryList, ref InsertSalaryList);
                //txtSalaryRuleID.Text = manager.SalaryRuleCode;
                this.SuccessMessage = (StaticInfo.SavedSuccessfullyMsg);
            }
            catch (SqlException ex)
            {
                this.ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex));
            }
            catch (Exception ex)
            {
                this.ErrorMessage = (ExceptionHelper.getExceptionMessage(ex));
            }
        }
コード例 #3
0
 public CustomList <EmployeeSalaryTemp> GetAllEmployeeSalaryByEmpKey(Int64 empKey, string usercode)
 {
     return(EmployeeSalaryTemp.GetAllEmployeeSalaryByEmpKey(empKey, usercode));
 }