Example #1
0
        public static CustomList <SalaryRule> GetAllSalaryRule()
        {
            ConnectionManager       conManager           = new ConnectionManager(ConnectionName.HR);
            CustomList <SalaryRule> SalaryRuleCollection = new CustomList <SalaryRule>();
            IDataReader             reader = null;
            const String            sql    = "select *from SalaryRule";

            try
            {
                conManager.OpenDataReader(sql, out reader);
                while (reader.Read())
                {
                    SalaryRule newSalaryRule = new SalaryRule();
                    newSalaryRule.SetData(reader);
                    SalaryRuleCollection.Add(newSalaryRule);
                }
                SalaryRuleCollection.InsertSpName = "spInsertSalaryRule";
                SalaryRuleCollection.UpdateSpName = "spUpdateSalaryRule";
                SalaryRuleCollection.DeleteSpName = "spDeleteSalaryRule";
                return(SalaryRuleCollection);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
Example #2
0
        public static CustomList <SalaryRule> GetAllSalaryRuleFormula(string salaryRuleCode)
        {
            ConnectionManager       conManager           = new ConnectionManager(ConnectionName.HR);
            CustomList <SalaryRule> SalaryRuleCollection = new CustomList <SalaryRule>();
            IDataReader             reader = null;
            String sql = "Exec spGetSalaryRule '" + salaryRuleCode + "'";

            try
            {
                conManager.OpenDataReader(sql, out reader);
                while (reader.Read())
                {
                    SalaryRule newSalaryRule = new SalaryRule();
                    newSalaryRule.SetDataFoumula(reader);
                    SalaryRuleCollection.Add(newSalaryRule);
                }
                return(SalaryRuleCollection);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                CustomList <SalaryRuleBackup> SalaryRuleBackupList = new CustomList <SalaryRuleBackup>();
                SalaryRuleBackupList = (CustomList <SalaryRuleBackup>)HttpContext.Current.Session["SalaryRule_grdSalaryRuleList"];
                CustomList <ASL.Hr.DAO.SalaryRule> SRList        = new CustomList <ASL.Hr.DAO.SalaryRule>();
                CustomList <ASL.Hr.DAO.SalaryRule> DeletedSRList = new CustomList <ASL.Hr.DAO.SalaryRule>();
                if (chkApproved.Checked && chkApproved.Enabled)
                {
                    foreach (SalaryRuleBackup sRB in SalaryRuleBackupList)
                    {
                        sRB.ApprovalDate = txtApprovalDate.Text.ToDateTime();
                        sRB.ApproveBy    = txtApproveBy_nc.Text;
                        sRB.IsApproved   = chkApproved.Checked;

                        ASL.Hr.DAO.SalaryRule sR = new ASL.Hr.DAO.SalaryRule();
                        sR.SalaryRuleCode   = sRB.SalaryRuleCode;
                        sR.SalaryHeadKey    = sRB.SalaryHeadKey;
                        sR.sCriteria        = sRB.sCriteria;
                        sR.ParentHeadID     = sRB.ParentHeadID;
                        sR.ParentHeadValue  = sRB.ParentHeadValue;
                        sR.PartialHeadID    = sRB.PartialHeadID;
                        sR.PartialHeadValue = sRB.PartialHeadValue;
                        sR.IsFixed          = sRB.IsFixed;
                        sR.IsHigher         = sRB.IsHigher;
                        sR.Formula1         = sRB.Formula1;
                        sR.Formula2         = sRB.Formula2;
                        SRList.Add(sR);

                        ASL.Hr.DAO.SalaryRule deletedSR = new ASL.Hr.DAO.SalaryRule();
                        deletedSR.SalaryRuleCode = sRB.SalaryRuleCode;
                        deletedSR.Delete();
                        DeletedSRList.Add(deletedSR);
                    }
                }
                if (SalaryRuleBackupList.Count != 0)
                {
                    if (!CheckUserAuthentication(SalaryRuleBackupList, SRList, DeletedSRList))
                    {
                        return;
                    }
                    manager.SaveSalaryRule(ref SalaryRuleBackupList, ref DeletedSRList, ref SRList);
                    txtSalaryRuleID.Text = manager.SalaryRuleCode;
                    this.SuccessMessage  = (StaticInfo.SavedSuccessfullyMsg);
                }
            }
            catch (SqlException ex)
            {
                this.ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex));
            }
            catch (Exception ex)
            {
                this.ErrorMessage = (ExceptionHelper.getExceptionMessage(ex));
            }
        }