Ejemplo n.º 1
0
        public List <PayMonthInfo> GetPayMonthInfoList(WhereSqlClauseBuilder builder)
        {
            String              sql    = String.Format("SELECT * FROM {0} WHERE {1} ", ORMapping.GetMappingInfo <PayMonthInfo>().TableName, builder.ToSqlString());
            DataTable           dt     = _DataHelper.GetDataTable(sql);
            List <PayMonthInfo> result = new List <PayMonthInfo>();

            for (Int32 i = 0; i < dt.Rows.Count; i++)
            {
                PayMonthInfo info = new PayMonthInfo();
                ORMapping.DataRowToObject(dt.Rows[i], info);
                result.Add(info);
            }
            return(result);
        }
Ejemplo n.º 2
0
 public List<PayMonthInfo> GetPayMonthInfoList(WhereSqlClauseBuilder builder)
 {
     String sql = String.Format("SELECT * FROM {0} WHERE {1} ",ORMapping.GetMappingInfo<PayMonthInfo>().TableName, builder.ToSqlString());
     DataTable dt = _DataHelper.GetDataTable(sql);
     List<PayMonthInfo> result = new List<PayMonthInfo>();
     for (Int32 i = 0; i < dt.Rows.Count; i++)
     {
         PayMonthInfo info = new PayMonthInfo();
         ORMapping.DataRowToObject(dt.Rows[i], info);
         result.Add(info);
     }
     return result;
 }
Ejemplo n.º 3
0
 public Int32 InsertPayMonthInfo(String yearMonth, bool rewrite)
 {
     using (TransactionScope scope = TransactionScopeFactory.Create(TransactionScopeOption.Required))
     {
         StringBuilder         sql     = new StringBuilder();
         WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();
         if (rewrite)
         {
             builder.AppendItem(PayMonthInfoDBConst.YearMonth, yearMonth);
             this.DeletePayMonthInfo(builder);
             //工资月表
             foreach (PayMonthInfo payMonthInfo in PersonBaseFeeInfoAdapter.Instance.GetPersonBaseFeeInfoList(PersonBaseFeeTarget.PayMonth, yearMonth))
             {
                 sql.Append(ORMapping.GetInsertSql(payMonthInfo, BuilderEx.TSqlBuilderInstance));
                 sql.Append(";");
             }
         }
         else
         {
             builder.AppendItem(String.Concat(PersonInfoDBConst.EntryDate, "<= DATEADD(Day,-1,CONVERT(CHAR(8),DATEADD(Month,1,'", yearMonth, "01'),120)+'1')"));
             builder.AppendItem(String.Concat("ISNULL(", PersonInfoDBConst.LeftDate, ",DATEADD(Month,1,GETDATE()))"), yearMonth + "01", ">=");
             List <PersonInfo> personList = PersonInfoAdapter.Instance.GetPersonInfoList(builder);
             //工资项目月表
             foreach (FeeInfo feeInfo in FeeInfoAdapter.Instance.GetFeeInfoList(null, null))
             {
                 FeeMonthInfo feeMonthInfo = Tools.ClassDataCopy <FeeInfo, FeeMonthInfo>(feeInfo);
                 feeMonthInfo.YearMonth = yearMonth;
                 sql.Append(ORMapping.GetInsertSql(feeMonthInfo, BuilderEx.TSqlBuilderInstance));
                 sql.Append(";");
             }//人员基本工资月表
             foreach (PersonBaseFeeMonthInfo personBaseFeeMonthInfo in PersonBaseFeeInfoAdapter.Instance.GetPersonBaseFeeInfoList(PersonBaseFeeTarget.PersonBaseFeeMonth, null).Join(personList, baseFee => baseFee.PersonID, person => person.PersonID, (baseFeeDepart, person) => baseFeeDepart).ToList())
             {
                 personBaseFeeMonthInfo.YearMonth = yearMonth;
                 sql.Append(ORMapping.GetInsertSql(personBaseFeeMonthInfo, BuilderEx.TSqlBuilderInstance));
                 sql.Append(";");
                 //工资月表
                 FeeInfo feeInfo = FeeInfoAdapter.Instance.LoadFeeInfo(null, personBaseFeeMonthInfo.FeeID);
                 if (String.IsNullOrEmpty(feeInfo.CalculateExp))
                 {
                     PayMonthInfo PayMonthInfo = Tools.ClassDataCopy <PersonBaseFeeMonthInfo, PayMonthInfo>(personBaseFeeMonthInfo);
                     PayMonthInfo.YearMonth = yearMonth;
                     PayMonthInfo.PayMoney  = PayMonthInfo.FeeValue;
                     sql.Append(ORMapping.GetInsertSql(PayMonthInfo, BuilderEx.TSqlBuilderInstance));
                     sql.Append(";");
                 }
             }
             //人员基本工资项目部门分摊月表
             WhereSqlClauseBuilder builderDepartment = new WhereSqlClauseBuilder();
             foreach (PersonBaseFeeDepartmentProjectInfo personFeeDepartmentProjectInfo in PersonBaseFeeDepartmentProjectInfoAdapter.Instance.GetPersonBaseFeeDepartmentProjectInfoList(null, null).Join(personList, baseFeeDepart => baseFeeDepart.PersonID, person => person.PersonID, (baseFeeDepart, person) => baseFeeDepart).ToList())
             {
                 PersonBaseFeeDepartmentProjectMonthInfo personFeeDepartmentProjectMonthInfo = Tools.ClassDataCopy <PersonBaseFeeDepartmentProjectInfo, PersonBaseFeeDepartmentProjectMonthInfo>(personFeeDepartmentProjectInfo);
                 personFeeDepartmentProjectMonthInfo.YearMonth = yearMonth;
                 sql.Append(ORMapping.GetInsertSql(personFeeDepartmentProjectMonthInfo, BuilderEx.TSqlBuilderInstance));
                 sql.Append(";");
             }
             //税率月表
             builder.Clear();
             foreach (TaxInfo taxInfo in TaxInfoAdapter.Instance.GetTaxInfoList(null, builder))
             {
                 TaxMonthInfo taxMonthInfo = Tools.ClassDataCopy <TaxInfo, TaxMonthInfo>(taxInfo);
                 taxMonthInfo.YearMonth = yearMonth;
                 sql.Append(ORMapping.GetInsertSql(taxMonthInfo, BuilderEx.TSqlBuilderInstance));
                 sql.Append(";");
             }
         }
         int result = _DataHelper.ExecuteSql(sql.ToString());
         scope.Complete();
         return(result);
     }
 }