Exemplo n.º 1
0
 private void AddPlan(DataRow[] drsSrc, string RecordType)
 {
     try
     {
         foreach (DataRow row in drsSrc)
         {
             DataRow   row2;
             string    text     = ConvertRule.ToString(row["ContractCode"]);
             string    text2    = ConvertRule.ToString(row["CostCode"]);
             string    text3    = ConvertRule.ToString(row["PlanYm"]);
             DataRow[] rowArray = this.tbPlan.Select("ContractCode = '" + text + "' and CostCode='" + text2 + "' and PlanYm = '" + text3 + "'");
             if (rowArray.Length == 0)
             {
                 row2 = this.tbPlan.NewRow();
                 row2["RecordType"]   = RecordType;
                 row2["ContractCode"] = text;
                 row2["CostCode"]     = text2;
                 row2["FullCode"]     = row["FullCode"];
                 row2["PlanYm"]       = row["PlanYm"];
                 this.tbPlan.Rows.Add(row2);
             }
             else
             {
                 row2 = rowArray[0];
             }
             row2["PlanMoney"] = ConvertRule.ToDecimal(row2["PlanMoney"]) + ConvertRule.ToDecimal(row["PlanMoney"]);
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 2
0
 private void SetRelationNoContract()
 {
     try
     {
         int       index;
         DataRow[] rowArray = this.tbContract.Select("RecordType = 'NoContract'");
         int       length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbContract.Rows.Remove(rowArray[index]);
         }
         rowArray = this.tbPayout.Select("RecordType = 'NoContract'");
         length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbPayout.Rows.Remove(rowArray[index]);
         }
         rowArray = this.tbApportion.Select("RecordType = 'NoContract'");
         length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbApportion.Rows.Remove(rowArray[index]);
         }
         QueryAgent agent = new QueryAgent();
         try
         {
             string queryString = "select 'Payment_' + a.PaymentCode as ContractCode, '' as ContractID, '非合同请款' + b.PaymentID as ContractName, c.SubjectCode as CostCode, c.SubjectCode as FullCode, b.SupplyCode as SupplierCode, b.SupplyName as SupplierName, a.ItemMoney as Money, a.CostBudgetSetCode, cb.PBSType, cb.PBSCode from PaymentItem a left join CBS c on c.CostCode = a.CostCode left join CostBudgetSet cb on cb.CostBudgetSetCode = a.CostBudgetSetCode, Payment b, PayoutItem oi, Voucher v, VoucherDetail vd where a.PaymentCode = b.PaymentCode and b.ProjectCode = '" + this.ProjectCode + "' and isnull(b.IsContract, 0) = 0 and a.PaymentItemCode = oi.PaymentItemCode and vd.RelaType = '付款' and vd.RelaCode = oi.PayoutCode and v.VoucherCode = vd.VoucherCode and v.Status in (1, 2)";
             if ((this.PBSType != "") || (this.PBSCode != ""))
             {
                 string text4 = queryString;
                 queryString = text4 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
             }
             DataTable tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.AddRelationContractRow(this.tbContract, tbSrc, "NoContract", "ContractMoney");
             foreach (DataRow row in this.tbContract.Rows)
             {
                 string text2 = ConvertRule.ToString(row["ContractCode"]).Replace("Payment_", "");
                 string text3 = ConvertRule.ToString(row["CostCode"]);
                 queryString = "select b.VoucherCode as PayoutCode, b.CheckDate as PayoutDate, a.DebitMoney as Money, 'Payment_' + pi.PaymentCode as ContractCode, a.SubjectCode as CostCode, a.SubjectCode as FullCode, '' as CostBudgetSetCode, '' as PBSType, '' as PBSCode from VoucherDetail a inner join Voucher b on b.VoucherCode = a.VoucherCode       and b.Status in (1, 2), PayoutItem oi, PaymentItem pi where b.ProjectCode = '" + this.ProjectCode + "' and a.RelaType = '付款' and a.RelaCode = oi.PayoutCode and oi.PaymentItemCode = pi.PaymentItemCode and pi.PaymentCode = '" + text2 + "'";
                 tbSrc       = agent.ExecSqlForDataSet(queryString).Tables[0];
                 this.AddPayout(tbSrc, "Contract");
                 foreach (DataRow row2 in tbSrc.Rows)
                 {
                     row["ContractPayReal"] = ConvertRule.ToDecimal(row["ContractPayReal"]) + ConvertRule.ToDecimal(row2["Money"]);
                 }
             }
             CostBudgetPageRule.CostBudgetDtlCalcAllRow(this.tbContract, CostBudgetPageRule.m_DynamicRowType.Contract, null, 0, 0);
         }
         finally
         {
             agent.Dispose();
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 3
0
 private void ResetContractDateRange()
 {
     try
     {
         DropDateRangeColumn(this.tbContract);
         DropDateRangeColumn(this.tb);
         if ((this.StartYm != "") && (this.EndYm != ""))
         {
             string text;
             string text2;
             string text3;
             string name;
             AddDateRangeColumn(this.tbContract, this.StartYm, this.EndYm);
             AddDateRangeColumn(this.tb, this.StartYm, this.EndYm);
             int monthsBetween = StringRule.GetMonthsBetween(this.StartYm, this.EndYm);
             foreach (DataRow row in this.tbContract.Rows)
             {
                 text  = ConvertRule.ToString(row["ContractCode"]);
                 text2 = ConvertRule.ToString(row["CostCode"]);
                 DataRow[] rowArray = this.tbPlan.Select("ContractCode = '" + text + "' and CostCode='" + text2 + "'");
                 foreach (DataRow row2 in rowArray)
                 {
                     text3 = ConvertRule.ToString(row2["PlanYm"]);
                     name  = "PlanMoneyYm_" + text3;
                     if (this.tbContract.Columns.Contains(name))
                     {
                         row[name] = ConvertRule.ToDecimal(row[name]) + ConvertRule.ToDecimal(row2["PlanMoney"]);
                     }
                 }
             }
             foreach (DataRow row in this.tbContract.Rows)
             {
                 text  = ConvertRule.ToString(row["ContractCode"]);
                 text2 = ConvertRule.ToString(row["CostCode"]);
                 DataRow   row3      = null;
                 DataRow[] rowArray2 = this.tb.Select("ContractCode = '" + text + "' and CostCode = '" + text2 + "' and RecordType <> ''");
                 if (rowArray2.Length > 0)
                 {
                     row3 = rowArray2[0];
                 }
                 if (row3 != null)
                 {
                     for (int i = 0; i < monthsBetween; i++)
                     {
                         text3      = StringRule.YmAddMonths(this.StartYm, i);
                         name       = "PlanMoneyYm_" + text3;
                         row3[name] = row[name];
                     }
                 }
             }
             this.ReCalcByRelation(this.StartYm, this.EndYm);
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 4
0
 public static void NewYearConstructAnnualPlan(string ProjectCode, int IYear, string UserCode)
 {
     try
     {
         if ((ProjectCode != "") && (IYear > 0))
         {
             DataRow    drDst;
             int        num = IYear + 1;
             EntityData constructPlanStepByProjectYear = ConstructDAO.GetConstructPlanStepByProjectYear(ProjectCode, IYear);
             EntityData entity = new EntityData("ConstructPlanStep");
             foreach (DataRow row in constructPlanStepByProjectYear.CurrentTable.Rows)
             {
                 drDst = entity.CurrentTable.NewRow();
                 ConvertRule.DataRowCopy(row, drDst, constructPlanStepByProjectYear.CurrentTable, entity.CurrentTable);
                 drDst["ConstructPlanStepCode"] = SystemManageDAO.GetNewSysCode("ConstructPlanStepCode");
                 drDst["IYear"] = num;
                 entity.CurrentTable.Rows.Add(drDst);
             }
             ConstructDAO.InsertConstructPlanStep(entity);
             entity.Dispose();
             constructPlanStepByProjectYear.Dispose();
             EntityData data3 = PBSDAO.GetV_PBSUnitByProject(ProjectCode);
             EntityData constructAnnualPlanByProjectYear = ConstructDAO.GetConstructAnnualPlanByProjectYear(ProjectCode, IYear);
             entity = new EntityData("ConstructAnnualPlan");
             foreach (DataRow row3 in data3.CurrentTable.Rows)
             {
                 string  pBSUnitCode = ConvertRule.ToString(row3["PBSUnitCode"]);
                 string  code        = ConvertRule.ToString(row3["VisualProgress"]);
                 decimal num2        = ConvertRule.ToDecimal(row3["TotalBuildArea"]);
                 drDst = entity.CurrentTable.NewRow();
                 drDst["AnnualPlanCode"] = SystemManageDAO.GetNewSysCode("AnnualPlanCode");
                 entity.CurrentTable.Rows.Add(drDst);
                 drDst["IYear"]       = num;
                 drDst["PBSUnitCode"] = pBSUnitCode;
                 drDst["ProjectCode"] = ProjectCode;
                 drDst["PlanDate"]    = DateTime.Now;
                 drDst["PlanPerson"]  = UserCode;
                 decimal num3 = CalcPBSUnitCompleteInvest(pBSUnitCode);
                 drDst["InvestBefore"] = num3;
                 EntityData visualProgressByCode = ConstructDAO.GetVisualProgressByCode(code);
                 if (visualProgressByCode.HasRecord() && (visualProgressByCode.GetInt("ProgressType") >= 0))
                 {
                     drDst["LCFArea"] = num2;
                 }
                 visualProgressByCode.Dispose();
                 ConstructDAO.InsertConstructAnnualPlan(entity);
             }
             entity.Dispose();
             constructAnnualPlanByProjectYear.Dispose();
             data3.Dispose();
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 5
0
        private static void AddBuildingCostApportion(string projectCode, DataTable dt, string alloType, string buildingCode, decimal money, decimal totalArea, EntityData buildings, EntityData PBSUnits, EntityData CBS, string subjectCode, string AreaField)
        {
            string  buildingName = "";
            decimal buildingArea = 0M;
            string  alloTypeName = GetAlloTypeName(alloType);
            decimal num2         = 0M;

            GetBuildingInfo(alloType, buildingCode, ref buildingName, ref buildingArea, PBSUnits, buildings, AreaField);
            string costCode   = "";
            string costName   = "";
            string fullCode   = "";
            string costSortID = "";

            GetCostDetail(subjectCode, CBS, ref costCode, ref costName, ref fullCode, ref costSortID);
            if (totalArea > 0M)
            {
                num2 = Math.Round((decimal)((money * buildingArea) / totalArea), 2);
            }
            DataRow[] rowArray = dt.Select(string.Format(" AlloType='{0}' and BuildingCode='{1}' and costCode='{2}' ", alloType, buildingCode, costCode));
            DataRow   row      = null;

            if (rowArray.Length > 0)
            {
                row = rowArray[0];
                row["ApportionMoney"] = ConvertRule.ToDecimal(row["ApportionMoney"]) + num2;
            }
            else
            {
                row = dt.NewRow();
                row["BuildingName"] = buildingName;
                row["BuildingArea"] = buildingArea;
                if (alloType == "P")
                {
                    row["SortID"]       = 0;
                    row["BuildingName"] = ProjectRule.GetProjectName(projectCode);
                }
                else if (alloType == "U")
                {
                    row["SortID"] = 1;
                }
                else if (alloType == "B")
                {
                    row["SortID"] = 2;
                }
                row["AlloType"]       = alloType;
                row["AlloTypeName"]   = alloTypeName;
                row["BuildingCode"]   = buildingCode;
                row["ApportionMoney"] = num2;
                row["CostCode"]       = costCode;
                row["CostName"]       = costName;
                row["FullCode"]       = fullCode;
                row["CostSortID"]     = costSortID;
                dt.Rows.Add(row);
            }
        }
Exemplo n.º 6
0
        private static decimal GetBuildingAreaSum(string buildingCode, EntityData buildings, string AreaField)
        {
            decimal num = 0M;

            DataRow[] rowArray = buildings.CurrentTable.Select(string.Format("BuildingCode='{0}'", buildingCode));
            if (rowArray.Length > 0)
            {
                num = ConvertRule.ToDecimal(rowArray[0][AreaField]);
            }
            return(num);
        }
Exemplo n.º 7
0
 private void CalcTotalArea()
 {
     try
     {
         this.m_TotalArea = 0M;
         foreach (DataRow row in this.tbArea.Rows)
         {
             this.m_TotalArea += ConvertRule.ToDecimal(row["Area"]);
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 8
0
 private void AddRelationContractRow(DataTable tbContract, DataTable tbSrc, string RecordType, string MoneyField)
 {
     try
     {
         foreach (DataRow row in tbSrc.Rows)
         {
             DataRow   row2;
             string    text     = ConvertRule.ToString(row["ContractCode"]);
             DataRow[] rowArray = tbContract.Select("ContractCode = '" + text + "' and CostCode='" + ConvertRule.ToString(row["CostCode"]) + "'");
             if (rowArray.Length == 0)
             {
                 row2 = tbContract.NewRow();
                 row2["RecordType"]   = RecordType;
                 row2["ContractCode"] = text;
                 row2["ContractID"]   = row["ContractID"];
                 row2["ContractName"] = row["ContractName"];
                 if (tbSrc.Columns.Contains("SupplierCode"))
                 {
                     row2["SupplierName"] = row["SupplierName"];
                     row2["SupplierCode"] = row["SupplierCode"];
                 }
                 row2["CostCode"] = row["CostCode"];
                 row2["FullCode"] = row["FullCode"];
                 tbContract.Rows.Add(row2);
             }
             else
             {
                 row2 = rowArray[0];
             }
             string text2 = ConvertRule.ToString(row2["AllContractCode"]);
             if (text2.IndexOf("'" + text + "'") < 0)
             {
                 if (text2 != "")
                 {
                     text2 = text2 + ",";
                 }
                 text2 = text2 + "'" + text + "'";
             }
             row2["AllContractCode"] = text2;
             row2[MoneyField]        = ConvertRule.ToDecimal(row2[MoneyField]) + ConvertRule.ToDecimal(row["Money"]);
             CostBudgetPageRule.CostBudgetDtlCalcField(row2, CostBudgetPageRule.m_DynamicRowType.Contract, null, 0, 0);
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 9
0
 private static void SaveBuildingCostTempToFormalByCostCode(DataTable dtTemp, DataTable dtBuilding, string CostCode, string CostSortID)
 {
     try
     {
         foreach (DataRow row in dtTemp.Rows)
         {
             string    text     = ConvertRule.ToString(row["BuildingCode"]);
             DataRow[] rowArray = dtBuilding.Select(string.Format(" BuildingCode='{0}' ", text));
             DataRow   row2     = null;
             if (rowArray.Length > 0)
             {
                 row2 = rowArray[0];
                 row2["TotalCost"] = ConvertRule.ToDecimal(row2["TotalCost"]) + ConvertRule.ToDecimal(row["TotalCost"]);
                 string text2 = "";
                 if (CostSortID.StartsWith("030407"))
                 {
                     text2 = "CostKf";
                 }
                 else if (CostSortID == "0301")
                 {
                     text2 = "CostTj";
                 }
                 else if (CostSortID.StartsWith("01"))
                 {
                     text2 = "CostTd";
                 }
                 else if (CostSortID.StartsWith("02"))
                 {
                     text2 = "CostQq";
                 }
                 else if (CostSortID.StartsWith("04") || CostSortID.StartsWith("030406"))
                 {
                     text2 = "CostZt";
                 }
                 else
                 {
                     text2 = "CostZt";
                 }
                 row2[text2] = ConvertRule.ToDecimal(row2[text2]) + ConvertRule.ToDecimal(row["TotalCost"]);
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 10
0
 public void DoApportion()
 {
     try
     {
         if (this.m_tbTotalMoney.Columns.Count == 0)
         {
             throw new Exception("未设置总金额");
         }
         DataRow row = this.m_tbTotalMoney.Rows[0];
         if (!this.m_IsCustomTotalArea)
         {
             this.CalcTotalArea();
         }
         decimal[] numArray = new decimal[this.m_tbTotalMoney.Columns.Count];
         int       count    = this.tbArea.Rows.Count;
         for (int i = 0; i < count; i++)
         {
             DataRow row2  = this.tbArea.Rows[i];
             int     index = -1;
             foreach (DataColumn column in this.m_tbTotalMoney.Columns)
             {
                 index++;
                 decimal num4 = 0M;
                 decimal num5 = ConvertRule.ToDecimal(row[column.ColumnName]);
                 if (!(this.m_IsCustomTotalArea || (i != (count - 1))))
                 {
                     num4 = num5 - numArray[index];
                 }
                 else
                 {
                     decimal num6 = ConvertRule.ToDecimal(row2["Area"]);
                     if ((num6 != 0M) && (this.TotalArea != 0M))
                     {
                         num4 = MathRule.Round(num5 * (num6 / this.TotalArea), this.m_RoundDec);
                     }
                 }
                 row2[column.ColumnName] = num4;
                 numArray[index]         = ConvertRule.ToDecimal(numArray[index]) + num4;
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 11
0
 public static void CostBudgetDtlCalcField(DataRow dr, m_DynamicRowType RowType, DataRow drArea, int iStartY, int iEndY)
 {
     try
     {
         dr["ContractTotalMoney"] = (ConvertRule.ToDecimal(dr["ContractMoney"]) + ConvertRule.ToDecimal(dr["ContractChangeMoney"])) + ConvertRule.ToDecimal(dr["ContractApplyMoney"]);
         if ((RowType == m_DynamicRowType.CBS) && dr.Table.Columns.Contains("ContractBudgetBalance"))
         {
             dr["ContractBudgetBalance"] = ConvertRule.ToDecimal(dr["ContractTotalMoney"]) - ConvertRule.ToDecimal(dr["BudgetMoney"]);
         }
         dr["ContractPayBalance"]     = ConvertRule.ToDecimal(dr["ContractTotalMoney"]) - ConvertRule.ToDecimal(dr["ContractPay"]);
         dr["ContractPayRealBalance"] = ConvertRule.ToDecimal(dr["ContractPay"]) - ConvertRule.ToDecimal(dr["ContractPayReal"]);
         CalcPercent(dr, drArea);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 12
0
        public static string GetContractBudgetBalanceRemindStyle(object objContractBudgetMoney)
        {
            string text2;

            try
            {
                string text = "";
                if (ConvertRule.ToDecimal(objContractBudgetMoney) > 0M)
                {
                    text = "color:#FF0000;";
                }
                text2 = text;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text2);
        }
Exemplo n.º 13
0
 private void AddPayout(DataRow[] drsSrc, string RecordType)
 {
     try
     {
         foreach (DataRow row in drsSrc)
         {
             DataRow   row2;
             string    text     = ConvertRule.ToString(row["ContractCode"]);
             string    text2    = ConvertRule.ToString(row["CostCode"]);
             string    text3    = ConvertRule.ToString(row["PayoutCode"]);
             string    text4    = ConvertRule.ToString(row["CostBudgetSetCode"]);
             string    text5    = ConvertRule.ToString(row["PBSType"]);
             string    text6    = ConvertRule.ToString(row["PBSCode"]);
             DataRow[] rowArray = this.tbPayout.Select("ContractCode = '" + text + "' and CostCode='" + text2 + "' and PayoutCode = '" + text3 + "' and CostBudgetSetCode = '" + text4 + "' and PBSType = '" + text5 + "' and PBSCode = '" + text6 + "'");
             if (rowArray.Length == 0)
             {
                 row2 = this.tbPayout.NewRow();
                 row2["RecordType"]        = RecordType;
                 row2["ContractCode"]      = text;
                 row2["PayoutCode"]        = text3;
                 row2["CostCode"]          = text2;
                 row2["FullCode"]          = row["FullCode"];
                 row2["CostBudgetSetCode"] = text4;
                 row2["PBSType"]           = text5;
                 row2["PBSCode"]           = text6;
                 row2["PayoutDate"]        = row["PayoutDate"];
                 row2["PayoutYm"]          = ConvertRule.ToDateString(row2["PayoutDate"], "yyyyMM");
                 this.tbPayout.Rows.Add(row2);
             }
             else
             {
                 row2 = rowArray[0];
             }
             row2["PayoutMoney"] = ConvertRule.ToDecimal(row2["PayoutMoney"]) + ConvertRule.ToDecimal(row["Money"]);
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 14
0
 private static void SaveBuildingCostTempToFormal(DataTable dtTemp, DataTable dtBuilding)
 {
     try
     {
         foreach (DataRow row in dtTemp.Rows)
         {
             string    text     = ConvertRule.ToString(row["BuildingCode"]);
             DataRow[] rowArray = dtBuilding.Select(string.Format(" BuildingCode='{0}' ", text));
             DataRow   row2     = null;
             if (rowArray.Length > 0)
             {
                 row2 = rowArray[0];
                 row2["TotalCost"] = ConvertRule.ToDecimal(row2["TotalCost"]) + ConvertRule.ToDecimal(row["TotalCost"]);
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 15
0
        public static string GetMoneyShowString(object money, m_MoneyUnit unit, string MoneyType)
        {
            string text2;

            try
            {
                string wanDecimalShowString = "";
                switch (unit)
                {
                case m_MoneyUnit.yuan:
                    wanDecimalShowString = StringRule.BuildShowNumberString(money, "#,##0");
                    break;

                case m_MoneyUnit.fen:
                    wanDecimalShowString = StringRule.BuildShowNumberString(money, "#,##0.00");
                    break;

                default:
                    if (MoneyType.ToLower() == "price")
                    {
                        wanDecimalShowString = MathRule.GetWanDecimalShowString(money);
                    }
                    else if (m_IsRoundWanMoney)
                    {
                        wanDecimalShowString = StringRule.BuildMoneyWanFormatString(ConvertRule.ToDecimal(money), -1, 0);
                    }
                    else
                    {
                        wanDecimalShowString = MathRule.GetWanDecimalShowString(money);
                    }
                    break;
                }
                text2 = wanDecimalShowString;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text2);
        }
Exemplo n.º 16
0
        private static void AddApportion(string projectCode, DataTable dt, string alloType, string buildingCode, decimal money, EntityData buildings, EntityData PBSUnits, string AreaField)
        {
            string  buildingName = "";
            decimal buildingArea = 0M;
            string  alloTypeName = GetAlloTypeName(alloType);

            GetBuildingInfo(alloType, buildingCode, ref buildingName, ref buildingArea, PBSUnits, buildings, AreaField);
            DataRow[] rowArray = dt.Select(string.Format(" AlloType='{0}' and BuildingCode='{1}' ", alloType, buildingCode));
            DataRow   row      = null;

            if (rowArray.Length > 0)
            {
                row = rowArray[0];
                row["ApportionMoney"] = ConvertRule.ToDecimal(row["ApportionMoney"]) + money;
            }
            else
            {
                row                 = dt.NewRow();
                row["AlloType"]     = alloType;
                row["BuildingName"] = buildingName;
                row["BuildingArea"] = buildingArea;
                if (alloType == "P")
                {
                    row["SortID"] = 0;
                }
                else if (alloType == "U")
                {
                    row["SortID"] = 1;
                }
                else if (alloType == "B")
                {
                    row["SortID"] = 2;
                }
                row["AlloTypeName"]   = alloTypeName;
                row["BuildingCode"]   = buildingCode;
                row["ApportionMoney"] = money;
                dt.Rows.Add(row);
            }
        }
Exemplo n.º 17
0
        public static string GetWanDecimalShowString(object money)
        {
            string text2;

            try
            {
                string wanDecimalShowString = "";
                if (m_IsRoundWanMoney)
                {
                    wanDecimalShowString = StringRule.BuildMoneyWanFormatString(ConvertRule.ToDecimal(money), -1, 0);
                }
                else
                {
                    wanDecimalShowString = MathRule.GetWanDecimalShowString(money);
                }
                text2 = wanDecimalShowString;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text2);
        }
Exemplo n.º 18
0
 private void AddRelationContractRow(DataTable tbContract, DataTable tbSrc, string RecordType, string MoneyField)
 {
     try
     {
         foreach (DataRow row in tbSrc.Rows)
         {
             DataRow   row2;
             string    contractCode = ConvertRule.ToString(row["ContractCode"]);
             string    costCode     = ConvertRule.ToString(row["CostCode"]);
             DataRow[] rowArray     = tbContract.Select("ContractCode = '" + contractCode + "' and CostCode='" + costCode + "'");
             if (rowArray.Length == 0)
             {
                 row2 = tbContract.NewRow();
                 row2["RecordType"]   = RecordType;
                 row2["ContractCode"] = contractCode;
                 row2["ContractID"]   = row["ContractID"];
                 row2["ContractName"] = row["ContractName"];
                 row2["SupplierName"] = row["SupplierName"];
                 row2["SupplierCode"] = row["SupplierCode"];
                 row2["CostCode"]     = costCode;
                 row2["FullCode"]     = row["FullCode"];
                 tbContract.Rows.Add(row2);
             }
             else
             {
                 row2 = rowArray[0];
             }
             string text3 = ConvertRule.ToString(row2["AllContractCode"]);
             if (text3.IndexOf("'" + contractCode + "'") < 0)
             {
                 if (text3 != "")
                 {
                     text3 = text3 + ",";
                 }
                 text3 = text3 + "'" + contractCode + "'";
             }
             row2["AllContractCode"] = text3;
             if (tbSrc.Columns.Contains("ContractCostCode"))
             {
                 string text4 = ConvertRule.ToString(row["ContractCostCode"]);
                 if (text4 != "")
                 {
                     string text5 = ConvertRule.ToString(row2["AllocateCodes"]);
                     if (text5.IndexOf("'" + text4 + "'") < 0)
                     {
                         if (text5 != "")
                         {
                             text5 = text5 + ",";
                         }
                         text5 = text5 + "'" + text4 + "'";
                     }
                     row2["AllocateCodes"] = text5;
                 }
             }
             row2[MoneyField] = ConvertRule.ToDecimal(row2[MoneyField]) + ConvertRule.ToDecimal(row["Money"]);
             CostBudgetPageRule.CostBudgetDtlCalcField(row2, CostBudgetPageRule.m_DynamicRowType.Contract, null, 0, 0);
             this.DoApportion(contractCode, costCode, ConvertRule.ToString(row["CostBudgetSetCode"]), RecordType, MoneyField, ConvertRule.ToDecimal(row["Money"]));
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 19
0
 private void SetRelationContract()
 {
     try
     {
         int       index;
         DataRow[] rowArray = this.tbContract.Select("RecordType = 'Contract'");
         int       length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbContract.Rows.Remove(rowArray[index]);
         }
         rowArray = this.tbPayout.Select("RecordType = 'Contract'");
         length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbPayout.Rows.Remove(rowArray[index]);
         }
         rowArray = this.tbApportion.Select("RecordType = 'Contract'");
         length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbApportion.Rows.Remove(rowArray[index]);
         }
         QueryAgent agent = new QueryAgent();
         try
         {
             string text4;
             string queryString = "select vd.SubjectCode as FullCode, vd.SubjectCode as CostCode, s.SupplierName, cb.PBSType, cb.PBSCode, a.*, b.* from ContractCost a left join CBS c on c.CostCode = a.CostCode left join CostBudgetSet cb on cb.CostBudgetSetCode = a.CostBudgetSetCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode, Voucher v, VoucherDetail vd where a.ContractCode = b.ContractCode and a.ContractCode = vd.ContractCode and v.VoucherCode = vd.VoucherCode and v.Status in (1, 2) and b.ProjectCode = '" + this.ProjectCode + "' and b.Status in (0, 2) and not exists (select * from ContractChange g where g.ContractCode = b.ContractCode)";
             if ((this.PBSType != "") || (this.PBSCode != ""))
             {
                 text4       = queryString;
                 queryString = text4 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
             }
             DataTable tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractMoney");
             queryString = "select vd.SubjectCode as FullCode, vd.SubjectCode as CostCode, a.Money as Money, s.SupplierName, cb.PBSType, cb.PBSCode, a.*, b.* from ContractCostChange a left join CBS c on c.CostCode = a.CostCode left join CostBudgetSet cb on cb.CostBudgetSetCode = a.CostBudgetSetCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode, Voucher v, VoucherDetail vd where a.ContractCode = b.ContractCode and a.ContractCode = vd.ContractCode and v.VoucherCode = vd.VoucherCode and v.Status in (1, 2) and b.ProjectCode = '" + this.ProjectCode + "' and b.Status in (0, 2, 4) and a.ContractChangeCode = (select min(ContractChangeCode) from ContractChange g where g.ContractCode = b.ContractCode) and exists (select * from ContractChange g where g.ContractCode = b.ContractCode)";
             if ((this.PBSType != "") || (this.PBSCode != ""))
             {
                 text4       = queryString;
                 queryString = text4 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
             }
             tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.FillContractChangeCostCode(tbSrc);
             this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractMoney");
             queryString = "select vd.SubjectCode as FullCode, vd.SubjectCode as CostCode, a.ChangeMoney as Money, s.SupplierName, cb.PBSType, cb.PBSCode, a.*, b.* from ContractCostChange a left join CBS c on c.CostCode = a.CostCode left join CostBudgetSet cb on cb.CostBudgetSetCode = a.CostBudgetSetCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode, ContractChange g, Voucher v, VoucherDetail vd where a.ContractCode = b.ContractCode and b.ContractCode = g.ContractCode and a.ContractChangeCode = g.ContractChangeCode and a.ContractCode = vd.ContractCode and v.VoucherCode = vd.VoucherCode and v.Status in (1, 2) and b.ProjectCode = '" + this.ProjectCode + "' and b.Status not in (3) and g.Status in (0) and a.ChangeMoney <> 0";
             if ((this.PBSType != "") || (this.PBSCode != ""))
             {
                 text4       = queryString;
                 queryString = text4 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
             }
             tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.FillContractChangeCostCode(tbSrc);
             this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractChangeMoney");
             foreach (DataRow row in this.tbContract.Rows)
             {
                 string text2 = ConvertRule.ToString(row["ContractCode"]);
                 string text3 = ConvertRule.ToString(row["CostCode"]);
                 queryString = "select b.VoucherCode as PayoutCode, b.CheckDate as PayoutDate, a.DebitMoney as Money, '" + text2 + "' as ContractCode, a.SubjectCode as CostCode, a.SubjectCode as FullCode, '' as CostBudgetSetCode, '' as PBSType, '' as PBSCode from VoucherDetail a inner join Voucher b on b.VoucherCode = a.VoucherCode       and b.Status in (1, 2) where b.ProjectCode = '" + this.ProjectCode + "' and a.ContractCode = '" + text2 + "'";
                 tbSrc       = agent.ExecSqlForDataSet(queryString).Tables[0];
                 this.AddPayout(tbSrc, "Contract");
                 foreach (DataRow row2 in tbSrc.Rows)
                 {
                     row["ContractPayReal"] = ConvertRule.ToDecimal(row["ContractPayReal"]) + ConvertRule.ToDecimal(row2["Money"]);
                 }
             }
         }
         finally
         {
             agent.Dispose();
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 20
0
 public static void CalcPercent(DataRow dr, DataRow drArea)
 {
     try
     {
         if (dr.Table.Columns.Contains("ContractPayPercent"))
         {
             if (ConvertRule.ToDecimal(dr["ContractTotalMoney"]) == 0M)
             {
                 dr["ContractPayPercent"] = DBNull.Value;
             }
             else
             {
                 dr["ContractPayPercent"] = MathRule.Round((ConvertRule.ToDecimal(dr["ContractPay"]) / ConvertRule.ToDecimal(dr["ContractTotalMoney"])) * 100M, 0);
             }
         }
         if (dr.Table.Columns.Contains("BuildingPrice"))
         {
             if ((drArea != null) && (ConvertRule.ToDecimal(drArea["BuildingArea"]) != 0M))
             {
                 dr["BuildingPrice"] = MathRule.Round(ConvertRule.ToDecimal(dr["ContractTotalMoney"]) / ConvertRule.ToDecimal(drArea["BuildingArea"]), 2);
             }
             else
             {
                 dr["BuildingPrice"] = DBNull.Value;
             }
         }
         if (dr.Table.Columns.Contains("HousePrice"))
         {
             if ((drArea != null) && (ConvertRule.ToDecimal(drArea["HouseCount"]) != 0M))
             {
                 dr["HousePrice"] = MathRule.Round(ConvertRule.ToDecimal(dr["ContractTotalMoney"]) / ConvertRule.ToDecimal(drArea["HouseCount"]), 2);
             }
             else
             {
                 dr["HousePrice"] = DBNull.Value;
             }
         }
         if (dr.Table.Columns.Contains("BudgetPrice"))
         {
             if ((drArea != null) && (ConvertRule.ToDecimal(drArea["BuildingArea"]) != 0M))
             {
                 dr["BudgetPrice"] = MathRule.Round(ConvertRule.ToDecimal(dr["BudgetMoney"]) / ConvertRule.ToDecimal(drArea["BuildingArea"]), 2);
             }
             else
             {
                 dr["BudgetPrice"] = DBNull.Value;
             }
         }
         if (dr.Table.Columns.Contains("ContractOriginalPrice"))
         {
             if ((drArea != null) && (ConvertRule.ToDecimal(drArea["BuildingArea"]) != 0M))
             {
                 dr["ContractOriginalPrice"] = MathRule.Round(ConvertRule.ToDecimal(dr["ContractMoney"]) / ConvertRule.ToDecimal(drArea["BuildingArea"]), 2);
             }
             else
             {
                 dr["ContractOriginalPrice"] = DBNull.Value;
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 21
0
        public static DataTable RepRoomIn(string ProjectCode, int JGYear, string BeginDate, string EndDate)
        {
            DataTable table3;

            try
            {
                DataTable table;
                string    format = "";
                if (BeginDate != "")
                {
                    format = format + " and {0} >= convert(DateTime, '" + BeginDate + "', 121)";
                }
                if (EndDate != "")
                {
                    format = format + " and {0} < convert(DateTime, '" + EndDate + "', 121) + 1";
                }
                string     text2 = "select sum(isnull(r.BuildArea, 0))  from TempRoomOut a     , TempRoomStructure b       left join Room r on r.RoomCode = b.TempRoomCode where a.OutListCode = b.OutListCode   and a.CheckState = 1   and a.ProjectCode = '{0}'   and b.TempBuildingCode = '{1}'   and a.out_state = '{2}'";
                string     text3 = "select sum(isnull(r.YuboArea, 0))  from TempRoomOut a     , TempRoomStructure b       left join Building r on r.BuildingCode = b.TempBuildingCode where a.OutListCode = b.OutListCode   and a.CheckState = 1   and a.ProjectCode = '{0}'   and b.TempBuildingCode = '{1}'   and a.out_state = '{2}'";
                QueryAgent agent = new QueryAgent();
                try
                {
                    string queryString = "select a.BuildingCode, a.ProjectCode, a.BuildingName, p.ProjectName, a.Remark, a.YuBoArea, t.PBSTypeName, t.PBSTypeFullName from Building a left join V_PBSType t on t.PBSTypeCode = a.PBSTypeCode, Project p, PBSUnit u where a.ProjectCode = p.ProjectCode and a.PBSUnitCode = u.PBSUnitCode and a.IsArea = 2";
                    if (ProjectCode != "")
                    {
                        string text5 = StrategyConvert.BuildInStr(ProjectCode);
                        queryString = queryString + " and a.ProjectCode in (" + text5 + ")";
                    }
                    string visualProgressJgInStr = PBSRule.GetVisualProgressJgInStr();
                    queryString = queryString + " and u.VisualProgress in (" + visualProgressJgInStr + ")";
                    if (JGYear > 0)
                    {
                        queryString = queryString + " and convert(varchar(4), u.EndDate, 112) = '" + JGYear.ToString() + "'";
                    }
                    queryString = queryString + " order by p.ProjectName, a.BuildingName";
                    table       = agent.ExecSqlForDataSet(queryString).Tables[0];
                    table.Columns.Add("ChamberName", typeof(string));
                    table.Columns.Add("state", typeof(string));
                    table.Columns.Add("BeforeInvArea", typeof(decimal));
                    table.Columns.Add("InArea", typeof(decimal));
                    table.Columns.Add("OutArea", typeof(decimal));
                    table.Columns.Add("BackInArea", typeof(decimal));
                    table.Columns.Add("InvArea", typeof(decimal));
                    foreach (DataRow row in table.Rows)
                    {
                        string text7  = ConvertRule.ToString(row["BuildingCode"]);
                        string text8  = ConvertRule.ToString(row["ProjectCode"]);
                        string text9  = "";
                        string text10 = "";
                        queryString = "select ChamberName from Chamber where BuildingCode = '" + text7 + "' order by ChamberName";
                        DataTable table2 = agent.ExecSqlForDataSet(queryString).Tables[0];
                        foreach (DataRow row2 in table2.Rows)
                        {
                            if (text9.Length > 0)
                            {
                                text9 = text9 + ",";
                            }
                            text9 = text9 + ConvertRule.ToString(row2["ChamberName"]);
                        }
                        row["ChamberName"] = text9;
                        if (text9.Length > 0)
                        {
                            decimal num  = 0M;
                            decimal num2 = 0M;
                            decimal num3 = 0M;
                            if (BeginDate != "")
                            {
                                queryString = string.Format(text2, text8, text7, "入库") + " and a.Out_Date < convert(DateTime, '" + BeginDate + "', 121)";
                                num         = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                                queryString = string.Format(text2, text8, text7, "出库") + " and a.Out_Date < convert(DateTime, '" + BeginDate + "', 121)";
                                num2        = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                                queryString = string.Format(text2, text8, text7, "退库") + " and a.Out_Date < convert(DateTime, '" + BeginDate + "', 121)";
                                num3        = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                            }
                            row["BeforeInvArea"] = (num + num3) - num2;
                            queryString          = string.Format(text2, text8, text7, "入库") + string.Format(format, "a.Out_Date");
                            row["InArea"]        = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                            queryString          = string.Format(text3, text8, text7, "预拨") + string.Format(format, "a.Out_Date");
                            row["YuboArea"]      = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                            queryString          = string.Format(text2, text8, text7, "出库") + string.Format(format, "a.Out_Date");
                            row["OutArea"]       = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                            queryString          = string.Format(text2, text8, text7, "退库") + string.Format(format, "a.Out_Date");
                            row["BackInArea"]    = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                            row["InvArea"]       = ((ConvertRule.ToDecimal(row["BeforeInvArea"]) + ConvertRule.ToDecimal(row["InArea"])) + ConvertRule.ToDecimal(row["BackInArea"])) - ConvertRule.ToDecimal(row["OutArea"]);
                            if (EndDate == "")
                            {
                                queryString = "select top 1 1 from room where BuildingCode = '" + text7 + "' and isnull(InvState, '') not in ('入库', '出库', '退库')";
                            }
                            else
                            {
                                queryString = "select top 1 1 from room r where BuildingCode = '" + text7 + "' and not exists( select a.*   from TempRoomOut a      , TempRoomStructure b  where a.OutListCode = b.OutListCode    and b.TempRoomCode = r.RoomCode    and a.CheckState = 1    and a.out_state in ('入库', '出库', '退库')    and a.Out_Date < convert(DateTime, '" + EndDate + "', 121) + 1)";
                            }
                            if (ConvertRule.ToString(agent.ExecuteScalar(queryString)) == "")
                            {
                                text10 = "入库";
                            }
                            else
                            {
                                text10 = "未入库";
                            }
                        }
                        row["state"] = text10;
                    }
                }
                finally
                {
                    agent.Dispose();
                }
                table3 = table;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(table3);
        }
Exemplo n.º 22
0
        public static void ProjectCostApportion(string projectCode, string AreaField)
        {
            try
            {
                decimal    cost;
                string     text3;
                DataTable  table            = ApportionAllPayout(projectCode, AreaField);
                EntityData entity           = ProductDAO.GetBuildingNotAreaByProjectCode(projectCode);
                EntityData pBSUnitByProject = PBSDAO.GetPBSUnitByProject(projectCode);
                entity.CurrentTable.Columns.Add("BuildingArea", Type.GetType("System.Decimal"));
                foreach (DataRow row in entity.CurrentTable.Rows)
                {
                    row["TotalCost"]    = DBNull.Value;
                    row["CostPrice"]    = DBNull.Value;
                    row["BuildingArea"] = row[AreaField];
                }
                foreach (DataRow row in table.Rows)
                {
                    decimal num3;
                    string  text       = ConvertRule.ToString(row["AlloType"]);
                    decimal totalMoney = ConvertRule.ToDecimal(row["ApportionMoney"]);
                    decimal num2       = ConvertRule.ToDecimal(row["BuildingArea"]);
                    if (num2 <= 0M)
                    {
                        break;
                    }
                    switch (text)
                    {
                    case "P":
                    {
                        DataTable dtTemp = new DataTable();
                        dtTemp.Columns.Add("BuildingCode");
                        dtTemp.Columns.Add("BuildingArea", typeof(decimal));
                        dtTemp.Columns.Add("TotalCost", typeof(decimal));
                        foreach (DataRow row2 in entity.CurrentTable.Rows)
                        {
                            num3 = ConvertRule.ToDecimal(row2["BuildingArea"]);
                            cost = ConvertRule.ToDecimal(row2["TotalCost"]);
                            DataRow row3 = dtTemp.NewRow();
                            row3["BuildingCode"] = row2["BuildingCode"];
                            row3["BuildingArea"] = row2["BuildingArea"];
                            row3["TotalCost"]    = Math.Round((decimal)((num3 * totalMoney) / num2), 2);
                            dtTemp.Rows.Add(row3);
                        }
                        ReCalcLastMoney(dtTemp, totalMoney, "TotalCost");
                        SaveBuildingCostTempToFormal(dtTemp, entity.CurrentTable);
                        break;
                    }

                    case "U":
                    {
                        string text2 = ConvertRule.ToString(row["BuildingCode"]);
                        foreach (DataRow row2 in entity.CurrentTable.Select(string.Format("PBSUnitCode='{0}'", text2)))
                        {
                            num3 = ConvertRule.ToDecimal(row2["BuildingArea"]);
                            cost = ConvertRule.ToDecimal(row2["TotalCost"]);
                            row2["TotalCost"] = cost + Math.Round((decimal)((num3 * totalMoney) / num2), 2);
                        }
                        break;
                    }

                    case "B":
                        text3 = ConvertRule.ToString(row["BuildingCode"]);
                        foreach (DataRow row2 in entity.CurrentTable.Select(string.Format("BuildingCode='{0}'", text3)))
                        {
                            cost = ConvertRule.ToDecimal(row2["TotalCost"]);
                            row2["TotalCost"] = cost + totalMoney;
                        }
                        break;
                    }
                }
                EntityData roomByProjectCode = ProductDAO.GetRoomByProjectCode(projectCode);
                foreach (DataRow row2 in entity.CurrentTable.Rows)
                {
                    text3 = ConvertRule.ToString(row2["BuildingCode"]);
                    decimal area = ConvertRule.ToDecimal(row2["BuildingArea"]);
                    cost = ConvertRule.ToDecimal(row2["TotalCost"]);
                    decimal price = GetPrice(cost, area);
                    row2["CostPrice"] = price;
                    DataRow[] rowArray = roomByProjectCode.CurrentTable.Select(string.Format("BuildingCode='{0}'", text3));
                    int       length   = rowArray.Length;
                    decimal   num8     = 0M;
                    for (int i = 0; i < length; i++)
                    {
                        DataRow row4  = rowArray[i];
                        decimal num10 = ConvertRule.ToDecimal(row4["BuildArea"]);
                        row4["CostPrice"] = price;
                        if (i < (length - 1))
                        {
                            decimal num11 = Math.Round((decimal)(num10 * price), 2);
                            num8        += num11;
                            row4["Cost"] = num11;
                        }
                        else
                        {
                            row4["Cost"] = cost - num8;
                        }
                    }
                }
                ProductDAO.SubmitAllBuilding(entity);
                ProductDAO.SubmitAllRoom(roomByProjectCode);
                table.Dispose();
                entity.Dispose();
                roomByProjectCode.Dispose();
                pBSUnitByProject.Dispose();
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Exemplo n.º 23
0
        public static ContractDefaultValue GetContractDefaultValue(string Code)
        {
            ContractDefaultValue value2  = new ContractDefaultValue();
            BiddingMessage       message = new BiddingMessage();

            message.BiddingMessageCode = Code;
            value2.BiddingCode         = message.BiddingCode;
            value2.ContractName        = message.ContractName;
            value2.ContractNumber      = message.ContractNember;
            value2.ContractRemark      = message.Remark;
            value2.ContractType        = message.ContractType;
            value2.SupplierCode        = message.Supplier;
            Bidding bidding = new Bidding();

            bidding.BiddingCode  = message.BiddingCode;
            value2.Mostly        = bidding.Accessory == "1";
            value2.ObligateMoney = bidding.ObligateMoney;
            value2.ProjectCode   = bidding.ProjectCode;
            value2.UnitCode      = bidding.BiddingRemark1;
            DataRow[]      rowArray   = bidding.GetBiddingReturn().Select("BiddingReturnCode in (" + message.BiddingReturnCode + "'')");
            BiddingMoney[] moneyArray = new BiddingMoney[rowArray.Length];
            int            index      = 0;
            decimal        num2       = 0M;

            foreach (DataRow row in rowArray)
            {
                BiddingDtl dtl = new BiddingDtl();
                dtl.BiddingDtlCode = row["BiddingDtlCode"].ToString();
                BiddingMoney money = new BiddingMoney();
                money.CostCode          = dtl.CostCode;
                money.CostBudgetSetCode = dtl.CostBudgetSetCode;
                money.PBSCode           = dtl.PBSCode;
                money.PBSType           = dtl.PBSType;
                string       text     = "";
                Cash_Message message2 = new Cash_Message();
                message2.CashMessageType     = "回标";
                message2.CashMessageTypeCode = row["BiddingReturnCode"].ToString();
                DataTable table2 = message2.GetCash_Messages();
                if (table2.Rows.Count > 0)
                {
                    text = table2.Rows[table2.Rows.Count - 1]["CashMessageCode"].ToString();
                }
                Cash_Detail detail = new Cash_Detail();
                detail.Cash_MessageCode = text;
                DataTable   table3      = detail.GetCash_Details();
                CashMoney[] moneyArray2 = new CashMoney[table3.Rows.Count];
                int         num3        = 0;
                decimal     num4        = 0M;
                foreach (DataRow row2 in table3.Select())
                {
                    CashMoney money2 = new CashMoney();
                    money2.MoneyCash    = row2["Cash"].ToString();
                    money2.MoneyType    = row2["MoneyType"].ToString();
                    money2.ExchangeRate = row2["ExchangeRate"].ToString();
                    money2.RMBTypeCash  = row2["RMB"].ToString();
                    moneyArray2[num3]   = money2;
                    num4 += ConvertRule.ToDecimal(money2.RMBTypeCash);
                    num3++;
                }
                money.CashMoneys   = moneyArray2;
                money.SumCashMoney = num4;
                moneyArray[index]  = money;
                num2 += money.SumCashMoney;
                index++;
            }
            value2.BiddingMoneys = moneyArray;
            value2.ContractMoney = num2;
            return(value2);
        }
Exemplo n.º 24
0
        public static DataTable CostApportionExcel(string projectCode, string AreaField)
        {
            DataTable table4;

            try
            {
                DataTable  table = BuildingCostApportionAllPayout(projectCode, "", "", AreaField);
                EntityData buildingNotAreaByProjectCode = ProductDAO.GetBuildingNotAreaByProjectCode(projectCode);
                EntityData pBSUnitByProject             = PBSDAO.GetPBSUnitByProject(projectCode);
                DataTable  currentTable = buildingNotAreaByProjectCode.CurrentTable;
                currentTable.Columns.Add("BuildingArea", Type.GetType("System.Decimal"));
                currentTable.Columns.Add("CostTd", typeof(decimal));
                currentTable.Columns.Add("CostQq", typeof(decimal));
                currentTable.Columns.Add("CostKf", typeof(decimal));
                currentTable.Columns.Add("CostZt", typeof(decimal));
                currentTable.Columns.Add("CostTj", typeof(decimal));
                currentTable.Columns.Add("CostQt", typeof(decimal));
                DataTable dtTemp = new DataTable();
                dtTemp.Columns.Add("BuildingCode");
                dtTemp.Columns.Add("BuildingArea", typeof(decimal));
                dtTemp.Columns.Add("TotalCost", typeof(decimal));
                foreach (DataRow row in buildingNotAreaByProjectCode.CurrentTable.Rows)
                {
                    row["TotalCost"]    = DBNull.Value;
                    row["CostPrice"]    = DBNull.Value;
                    row["BuildingArea"] = row["Area"];
                }
                foreach (DataRow row in table.Rows)
                {
                    DataRow row3;
                    dtTemp.Clear();
                    string  text       = ConvertRule.ToString(row["AlloType"]);
                    decimal totalMoney = ConvertRule.ToDecimal(row["ApportionMoney"]);
                    decimal num2       = ConvertRule.ToDecimal(row["BuildingArea"]);
                    string  costCode   = ConvertRule.ToString(row["CostCode"]);
                    string  costSortID = ConvertRule.ToString(row["CostSortID"]);
                    if (num2 <= 0M)
                    {
                        break;
                    }
                    switch (text)
                    {
                    case "P":
                        foreach (DataRow row2 in buildingNotAreaByProjectCode.CurrentTable.Rows)
                        {
                            decimal num3 = ConvertRule.ToDecimal(row2["BuildingArea"]);
                            decimal num4 = ConvertRule.ToDecimal(row2["TotalCost"]);
                            row3 = dtTemp.NewRow();
                            row3["BuildingCode"] = row2["BuildingCode"];
                            row3["BuildingArea"] = row2["BuildingArea"];
                            row3["TotalCost"]    = Math.Round((decimal)((num3 * totalMoney) / num2), 2);
                            dtTemp.Rows.Add(row3);
                        }
                        ReCalcLastMoney(dtTemp, totalMoney, "TotalCost");
                        SaveBuildingCostTempToFormalByCostCode(dtTemp, buildingNotAreaByProjectCode.CurrentTable, costCode, costSortID);
                        break;

                    case "U":
                    {
                        string text4 = ConvertRule.ToString(row["BuildingCode"]);
                        foreach (DataRow row2 in buildingNotAreaByProjectCode.CurrentTable.Select(string.Format("PBSUnitCode='{0}'", text4)))
                        {
                            row3 = dtTemp.NewRow();
                            row3["BuildingCode"] = row2["BuildingCode"];
                            row3["BuildingArea"] = row2["BuildingArea"];
                            row3["TotalCost"]    = Math.Round((decimal)((ConvertRule.ToDecimal(row2["BuildingArea"]) * totalMoney) / num2), 2);
                            dtTemp.Rows.Add(row3);
                        }
                        SaveBuildingCostTempToFormalByCostCode(dtTemp, buildingNotAreaByProjectCode.CurrentTable, costCode, costSortID);
                        break;
                    }

                    default:
                        if (text == "B")
                        {
                            row3 = dtTemp.NewRow();
                            row3["BuildingCode"] = row["BuildingCode"];
                            row3["BuildingArea"] = num2;
                            row3["TotalCost"]    = totalMoney;
                            dtTemp.Rows.Add(row3);
                            SaveBuildingCostTempToFormalByCostCode(dtTemp, buildingNotAreaByProjectCode.CurrentTable, costCode, costSortID);
                        }
                        break;
                    }
                }
                table.Dispose();
                pBSUnitByProject.Dispose();
                table4 = currentTable;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(table4);
        }
Exemplo n.º 25
0
        private static void BuildingCostApportionOnePayout(string projectCode, string payoutCode, EntityData PBSUnits, EntityData buildings, EntityData CBS, DataTable dtApportion, string AreaField)
        {
            try
            {
                DataTable  dt   = BuildBuildingCostApportionTable();
                EntityData data = PaymentDAO.GetStandard_PayoutByCode(payoutCode);
                foreach (DataRow row in data.Tables["PayoutItem"].Rows)
                {
                    dt.Clear();
                    string  alloType    = ConvertRule.ToString(row["AlloType"]);
                    string  text2       = ConvertRule.ToString(row["PayoutItemCode"]);
                    int     num         = ConvertRule.ToInt(row["IsManualAlloc"]);
                    string  subjectCode = ConvertRule.ToString(row["SubjectCode"]);
                    decimal money       = ConvertRule.ToDecimal(row["PayoutMoney"]);
                    switch (alloType)
                    {
                    case "P":
                        AddBuildingCostApportion(projectCode, dt, alloType, "项目", money, buildings, PBSUnits, CBS, subjectCode, AreaField);
                        break;

                    case "U":
                    case "B":
                    {
                        DataRow[] drsSelect = data.Tables["PayoutItemBuilding"].Select(string.Format(" PayoutItemCode='{0}' ", text2));
                        decimal   totalArea = SumTotalArea(drsSelect, buildings, PBSUnits, alloType, AreaField);
                        foreach (DataRow row2 in drsSelect)
                        {
                            string  buildingCode = ConvertRule.ToString(row2["BuildingCode"]);
                            string  text5        = ConvertRule.ToString(row2["PBSUnitCode"]);
                            decimal num4         = ConvertRule.ToDecimal(row2["ItemBuildingMoney"]);
                            if (num == 1)
                            {
                                if (alloType == "U")
                                {
                                    AddBuildingCostApportion(projectCode, dt, alloType, text5, num4, buildings, PBSUnits, CBS, subjectCode, AreaField);
                                }
                                else
                                {
                                    AddBuildingCostApportion(projectCode, dt, alloType, buildingCode, num4, buildings, PBSUnits, CBS, subjectCode, AreaField);
                                }
                            }
                            else if (alloType == "U")
                            {
                                AddBuildingCostApportion(projectCode, dt, alloType, text5, money, totalArea, buildings, PBSUnits, CBS, subjectCode, AreaField);
                            }
                            else
                            {
                                AddBuildingCostApportion(projectCode, dt, alloType, buildingCode, money, totalArea, buildings, PBSUnits, CBS, subjectCode, AreaField);
                            }
                        }
                        break;
                    }
                    }
                    ReCalcLastMoney(dt, money, "ApportionMoney");
                    SaveTempToFormalByCost(dt, dtApportion);
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Exemplo n.º 26
0
 private void ResetContractDateRange()
 {
     try
     {
         DropDateRangeColumn(this.tbContract);
         DropDateRangeColumn(this.tb);
         DropDateRangeColumn(this.tbApportion);
         if ((this.StartYm != "") && (this.EndYm != ""))
         {
             string    contractCode;
             string    costCode;
             string    text3;
             string    name;
             DataRow   row3;
             DataRow[] rowArray2;
             int       monthsBetween;
             int       monthCount;
             AddDateRangeColumn(this.tbContract, this.StartYm, this.EndYm);
             AddDateRangeColumn(this.tb, this.StartYm, this.EndYm);
             AddDateRangeColumn(this.tbApportion, this.StartYm, this.EndYm);
             foreach (DataRow row in this.tbContract.Rows)
             {
                 contractCode = ConvertRule.ToString(row["ContractCode"]);
                 costCode     = ConvertRule.ToString(row["CostCode"]);
                 DataRow[] rowArray = this.tbPayout.Select("ContractCode = '" + contractCode + "' and CostCode='" + costCode + "'");
                 foreach (DataRow row2 in rowArray)
                 {
                     text3 = ConvertRule.ToString(row2["PayoutYm"]);
                     name  = "PayoutMoneyYm_" + text3;
                     if (this.tbContract.Columns.Contains(name))
                     {
                         decimal totalMoney = ConvertRule.ToDecimal(row2["PayoutMoney"]);
                         row[name] = ConvertRule.ToDecimal(row[name]) + totalMoney;
                         this.DoApportion(contractCode, costCode, ConvertRule.ToString(row2["CostBudgetSetCode"]), ConvertRule.ToString(row["RecordType"]), name, totalMoney);
                     }
                 }
             }
             foreach (DataRow row in this.tbContract.Rows)
             {
                 contractCode = ConvertRule.ToString(row["ContractCode"]);
                 costCode     = ConvertRule.ToString(row["CostCode"]);
                 row3         = null;
                 rowArray2    = this.tb.Select("ContractCode = '" + contractCode + "' and CostCode = '" + costCode + "' and RecordType <> '' and RecordType <> 'Apportion'");
                 if (rowArray2.Length > 0)
                 {
                     row3 = rowArray2[0];
                 }
                 if (row3 != null)
                 {
                     monthsBetween = StringRule.GetMonthsBetween(this.StartYm, this.EndYm);
                     for (monthCount = 0; monthCount < monthsBetween; monthCount++)
                     {
                         text3      = StringRule.YmAddMonths(this.StartYm, monthCount);
                         name       = "PayoutMoneyYm_" + text3;
                         row3[name] = row[name];
                     }
                 }
             }
             foreach (DataRow row4 in this.tbApportion.Rows)
             {
                 contractCode = ConvertRule.ToString(row4["ContractCode"]);
                 costCode     = ConvertRule.ToString(row4["CostCode"]);
                 string text5 = ConvertRule.ToString(row4["PBSCode"]);
                 row3      = null;
                 rowArray2 = this.tb.Select("ContractCode = '" + contractCode + "' and CostCode = '" + costCode + "' and PBSCode = '" + text5 + "' and RecordType <> ''");
                 if (rowArray2.Length > 0)
                 {
                     row3 = rowArray2[0];
                 }
                 if (row3 != null)
                 {
                     monthsBetween = StringRule.GetMonthsBetween(this.StartYm, this.EndYm);
                     for (monthCount = 0; monthCount < monthsBetween; monthCount++)
                     {
                         text3      = StringRule.YmAddMonths(this.StartYm, monthCount);
                         name       = "PayoutMoneyYm_" + text3;
                         row3[name] = row4[name];
                     }
                 }
             }
             this.ReCalcByRelation(this.StartYm, this.EndYm);
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 27
0
 private void SetRelationContract()
 {
     try
     {
         int       index;
         DataRow[] rowArray = this.tbContract.Select("RecordType = 'Contract'");
         int       length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbContract.Rows.Remove(rowArray[index]);
         }
         rowArray = this.tbPayout.Select("RecordType = 'Contract'");
         length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbPayout.Rows.Remove(rowArray[index]);
         }
         rowArray = this.tbApportion.Select("RecordType = 'Contract'");
         length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbApportion.Rows.Remove(rowArray[index]);
         }
         QueryAgent agent = new QueryAgent();
         try
         {
             string text6;
             string queryString = "select c.FullCode, s.SupplierName, cb.PBSType, cb.PBSCode, a.*, b.* from ContractCost a left join CBS c on c.CostCode = a.CostCode left join CostBudgetSet cb on cb.CostBudgetSetCode = a.CostBudgetSetCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode where a.ContractCode = b.ContractCode and b.ProjectCode = '" + this.ProjectCode + "' and b.Status in (0, 2) and not exists (select * from ContractChange g where g.ContractCode = b.ContractCode)";
             if ((this.PBSType != "") || (this.PBSCode != ""))
             {
                 text6       = queryString;
                 queryString = text6 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
             }
             DataTable tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractMoney");
             queryString = "select c.FullCode, a.Money as Money, s.SupplierName, cb.PBSType, cb.PBSCode, a.*, b.* from ContractCostChange a left join CBS c on c.CostCode = a.CostCode left join CostBudgetSet cb on cb.CostBudgetSetCode = a.CostBudgetSetCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode where a.ContractCode = b.ContractCode and b.ProjectCode = '" + this.ProjectCode + "' and b.Status in (0, 2, 4) and a.ContractChangeCode = (select min(ContractChangeCode) from ContractChange g where g.ContractCode = b.ContractCode) and exists (select * from ContractChange g where g.ContractCode = b.ContractCode)";
             if ((this.PBSType != "") || (this.PBSCode != ""))
             {
                 text6       = queryString;
                 queryString = text6 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
             }
             tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.FillContractChangeCostCode(tbSrc);
             this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractMoney");
             queryString = "select c.FullCode, a.ChangeMoney as Money, s.SupplierName, cb.PBSType, cb.PBSCode, a.*, b.* from ContractCostChange a left join CBS c on c.CostCode = a.CostCode left join CostBudgetSet cb on cb.CostBudgetSetCode = a.CostBudgetSetCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode, ContractChange g where a.ContractCode = b.ContractCode and b.ContractCode = g.ContractCode and a.ContractChangeCode = g.ContractChangeCode and b.ProjectCode = '" + this.ProjectCode + "' and b.Status not in (3) and g.Status in (0) and a.ChangeMoney <> 0";
             if ((this.PBSType != "") || (this.PBSCode != ""))
             {
                 text6       = queryString;
                 queryString = text6 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
             }
             tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.FillContractChangeCostCode(tbSrc);
             this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractChangeMoney");
             foreach (DataRow row in this.tbContract.Rows)
             {
                 string contractCode = ConvertRule.ToString(row["ContractCode"]);
                 string costCode     = ConvertRule.ToString(row["CostCode"]);
                 string text4        = ConvertRule.ToString(row["AllContractCode"]);
                 string text5        = ConvertRule.ToString(row["AllocateCodes"]);
                 if ((text4 != "") && (text5 != ""))
                 {
                     queryString = "select a.CostBudgetSetCode, cb.PBSType, cb.PBSCode, sum(isnull(a.ItemMoney, 0)) as Money from PaymentItem a left join CostBudgetSet cb on cb.CostBudgetSetCode = a.CostBudgetSetCode, Payment b where a.PaymentCode = b.PaymentCode and b.ProjectCode = '" + this.ProjectCode + "' and b.Status in (1, 2) and b.ContractCode in (" + text4 + ") and a.AllocateCode in (" + text5 + ")";
                     if ((this.PBSType != "") || (this.PBSCode != ""))
                     {
                         text6       = queryString;
                         queryString = text6 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
                     }
                     queryString = queryString + " group by a.CostBudgetSetCode, cb.PBSType, cb.PBSCode";
                     tbSrc       = agent.ExecSqlForDataSet(queryString).Tables[0];
                     foreach (DataRow row2 in tbSrc.Rows)
                     {
                         row["ContractPay"] = ConvertRule.ToDecimal(row["ContractPay"]) + ConvertRule.ToDecimal(row2["Money"]);
                         this.DoApportion(contractCode, costCode, ConvertRule.ToString(row2["CostBudgetSetCode"]), ConvertRule.ToString(row["RecordType"]), "ContractPay", ConvertRule.ToDecimal(row2["Money"]));
                     }
                     queryString = "select a.PayoutCode, b.PayoutDate, a.PayoutMoney as Money, '" + contractCode + "' as ContractCode, mi.CostCode, c.FullCode, mi.CostBudgetSetCode, cb.PBSType, cb.PBSCode from PayoutItem a inner join Payout b on b.PayoutCode = a.PayoutCode, PaymentItem mi left join CBS c on c.CostCode = mi.CostCode left join CostBudgetSet cb on cb.CostBudgetSetCode = mi.CostBudgetSetCode, Payment m where a.PaymentItemCode = mi.PaymentItemCode and mi.PaymentCode = m.PaymentCode and m.ProjectCode = '" + this.ProjectCode + "' and m.ContractCode in (" + text4 + ") and mi.AllocateCode in (" + text5 + ")";
                     if (PaymentRule.IsPayoutMoneyIncludeNotCheck == 0)
                     {
                         queryString = queryString + " and b.Status in (1)";
                     }
                     if ((this.PBSType != "") || (this.PBSCode != ""))
                     {
                         text6       = queryString;
                         queryString = text6 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
                     }
                     tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0];
                     this.AddPayout(tbSrc, "Contract");
                     foreach (DataRow row2 in tbSrc.Rows)
                     {
                         row["ContractPayReal"] = ConvertRule.ToDecimal(row["ContractPayReal"]) + ConvertRule.ToDecimal(row2["Money"]);
                         this.DoApportion(contractCode, costCode, ConvertRule.ToString(row2["CostBudgetSetCode"]), ConvertRule.ToString(row["RecordType"]), "ContractPayReal", ConvertRule.ToDecimal(row2["Money"]));
                     }
                     CostBudgetPageRule.CostBudgetDtlCalcField(row, CostBudgetPageRule.m_DynamicRowType.Contract, null, 0, 0);
                 }
             }
         }
         finally
         {
             agent.Dispose();
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 28
0
 private static void SaveTempToFormalByCost(DataTable dtTemp, DataTable dt)
 {
     try
     {
         foreach (DataRow row in dtTemp.Rows)
         {
             string    text     = ConvertRule.ToString(row["AlloType"]);
             string    text2    = ConvertRule.ToString(row["buildingCode"]);
             string    text3    = ConvertRule.ToString(row["costCode"]);
             DataRow[] rowArray = dt.Select(string.Format(" AlloType='{0}' and BuildingCode='{1}' and CostCode='{2}' ", text, text2, text3));
             DataRow   drDst    = null;
             if (rowArray.Length > 0)
             {
                 drDst = rowArray[0];
                 drDst["ApportionMoney"] = ConvertRule.ToDecimal(drDst["ApportionMoney"]) + ConvertRule.ToDecimal(row["ApportionMoney"]);
             }
             else
             {
                 drDst = dt.NewRow();
                 ConvertRule.DataRowCopy(row, drDst, dtTemp, dt);
                 dt.Rows.Add(drDst);
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 29
0
 private void SetRelationNoContract()
 {
     try
     {
         int       index;
         DataRow[] rowArray = this.tbContract.Select("RecordType = 'NoContract'");
         int       length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbContract.Rows.Remove(rowArray[index]);
         }
         rowArray = this.tbPayout.Select("RecordType = 'NoContract'");
         length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbPayout.Rows.Remove(rowArray[index]);
         }
         rowArray = this.tbApportion.Select("RecordType = 'NoContract'");
         length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbApportion.Rows.Remove(rowArray[index]);
         }
         QueryAgent agent = new QueryAgent();
         try
         {
             string text4;
             string queryString = "select 'Payment_' + a.PaymentCode as ContractCode, '' as ContractID, '非合同请款' + b.PaymentID as ContractName, a.CostCode, c.FullCode, b.SupplyCode as SupplierCode, b.SupplyName as SupplierName, a.ItemMoney as Money, a.CostBudgetSetCode, cb.PBSType, cb.PBSCode from PaymentItem a left join CBS c on c.CostCode = a.CostCode left join CostBudgetSet cb on cb.CostBudgetSetCode = a.CostBudgetSetCode, Payment b where a.PaymentCode = b.PaymentCode and b.ProjectCode = '" + this.ProjectCode + "' and isnull(b.IsContract, 0) = 0";
             if ((this.PBSType != "") || (this.PBSCode != ""))
             {
                 text4       = queryString;
                 queryString = text4 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
             }
             DataTable tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.AddRelationContractRow(this.tbContract, tbSrc, "NoContract", "ContractMoney");
             queryString = "select 'Payment_' + a.PaymentCode as ContractCode, '' as ContractID, '非合同请款' + b.PaymentID as ContractName, a.CostCode, c.FullCode, b.SupplyCode as SupplierCode, b.SupplyName as SupplierName, a.ItemMoney as Money, a.CostBudgetSetCode, cb.PBSType, cb.PBSCode from PaymentItem a left join CBS c on c.CostCode = a.CostCode left join CostBudgetSet cb on cb.CostBudgetSetCode = a.CostBudgetSetCode, Payment b where a.PaymentCode = b.PaymentCode and b.ProjectCode = '" + this.ProjectCode + "' and b.Status in (1, 2) and isnull(b.IsContract, 0) = 0";
             if ((this.PBSType != "") || (this.PBSCode != ""))
             {
                 text4       = queryString;
                 queryString = text4 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
             }
             tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.AddRelationContractRow(this.tbContract, tbSrc, "NoContract", "ContractPay");
             queryString = "select mi.CostCode, c.FullCode, 'Payment_' + m.PaymentCode as ContractCode, a.PayoutCode, b.PayoutDate, a.PayoutMoney as Money, mi.CostBudgetSetCode, cb.PBSType, cb.PBSCode from PayoutItem a inner join Payout b on b.PayoutCode = a.PayoutCode, PaymentItem mi left join CBS c on c.CostCode = mi.CostCode left join CostBudgetSet cb on cb.CostBudgetSetCode = mi.CostBudgetSetCode, Payment m where a.PaymentItemCode = mi.PaymentItemCode and mi.PaymentCode = m.PaymentCode and m.ProjectCode = '" + this.ProjectCode + "' and isnull(m.IsContract, 0) = 0";
             if ((this.PBSType != "") || (this.PBSCode != ""))
             {
                 text4       = queryString;
                 queryString = text4 + " and cb.PBSType = '" + this.PBSType + "' and cb.PBSCode = '" + this.PBSCode + "'";
             }
             if (PaymentRule.IsPayoutMoneyIncludeNotCheck == 0)
             {
                 queryString = queryString + " and b.Status in (1)";
             }
             DataTable table2 = agent.ExecSqlForDataSet(queryString).Tables[0];
             DataView  view   = new DataView(this.tbContract, "RecordType = 'NoContract'", "", DataViewRowState.CurrentRows);
             foreach (DataRowView view2 in view)
             {
                 DataRow   row          = view2.Row;
                 string    costCode     = ConvertRule.ToString(row["CostCode"]);
                 string    contractCode = ConvertRule.ToString(row["ContractCode"]);
                 DataRow[] drsSrc       = table2.Select("CostCode = '" + costCode + "' and ContractCode = '" + contractCode + "'");
                 this.AddPayout(drsSrc, "Contract");
                 foreach (DataRow row2 in drsSrc)
                 {
                     row["ContractPayReal"] = ConvertRule.ToDecimal(row["ContractPayReal"]) + ConvertRule.ToDecimal(row2["Money"]);
                     this.DoApportion(contractCode, costCode, ConvertRule.ToString(row2["CostBudgetSetCode"]), ConvertRule.ToString(row["RecordType"]), "ContractPayReal", ConvertRule.ToDecimal(row2["Money"]));
                 }
             }
             CostBudgetPageRule.CostBudgetDtlCalcAllRow(this.tbContract, CostBudgetPageRule.m_DynamicRowType.Contract, null, 0, 0);
         }
         finally
         {
             agent.Dispose();
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemplo n.º 30
0
 public void RefreshHtml()
 {
     try
     {
         DataRow drDst;
         if (!this.ds.Tables.Contains("Html"))
         {
             this.ds.Tables.Add(CostBudgetPageRule.CreateDynamicHtmlTable(this.StartY, this.EndY, this.tb));
         }
         this.tbHtml.Clear();
         foreach (DataRow row in this.tb.Rows)
         {
             drDst = this.tbHtml.NewRow();
             ConvertRule.DataRowCopy(row, drDst, this.tb, this.tbHtml);
             this.tbHtml.Rows.Add(drDst);
         }
         if ((this.StartY != "") && (this.EndY != ""))
         {
             DataRow[] drsChild;
             DataView  view = new DataView(this.tbHtml, "Deep = 3", "", DataViewRowState.CurrentRows);
             foreach (DataRowView view2 in view)
             {
                 int    objYear;
                 int    objMonth;
                 string text4;
                 string name;
                 drDst = view2.Row;
                 string    text     = ConvertRule.ToString(drDst["CostCode"]);
                 string    text2    = ConvertRule.ToString(drDst["FullCode"]);
                 string    text3    = ConvertRule.ToString(drDst["CostBudgetSetCode"]);
                 DataRow[] rowArray = this.tbMonth.Select(string.Format("CostCode = '{0}' and CostBudgetSetCode = '{1}'", text, text3));
                 foreach (DataRow row3 in rowArray)
                 {
                     objYear  = ConvertRule.ToInt(row3["IYear"]);
                     objMonth = ConvertRule.ToInt(row3["IMonth"]);
                     text4    = ConvertRule.FormatYYYYMM(objYear, objMonth);
                     name     = "BudgetMoney_" + text4;
                     if (this.tbHtml.Columns.Contains(name))
                     {
                         drDst[name] = ConvertRule.ToDecimal(drDst[name]) + ConvertRule.ToDecimal(row3["Money"]);
                     }
                 }
                 rowArray = this.tbContractMonth.Select(string.Format("FullCode like '{0}%' and CostBudgetSetCode = '{1}'", text2, text3));
                 foreach (DataRow row3 in rowArray)
                 {
                     objYear  = ConvertRule.ToInt(row3["IYear"]);
                     objMonth = ConvertRule.ToInt(row3["IMonth"]);
                     text4    = ConvertRule.FormatYYYYMM(objYear, objMonth);
                     name     = "ContractMoney_" + text4;
                     if (this.tbHtml.Columns.Contains(name))
                     {
                         drDst[name] = ConvertRule.ToDecimal(drDst[name]) + ConvertRule.ToDecimal(row3["Money"]);
                     }
                     text4 = ConvertRule.FormatYYYYMM(objYear, 0);
                     name  = "ContractMoney_" + text4;
                     if (this.tbHtml.Columns.Contains(name))
                     {
                         drDst[name] = ConvertRule.ToDecimal(drDst[name]) + ConvertRule.ToDecimal(row3["Money"]);
                     }
                 }
             }
             view = new DataView(this.tbHtml, "Deep = 2", "", DataViewRowState.CurrentRows);
             foreach (DataRowView view2 in view)
             {
                 drDst    = view2.Row;
                 drsChild = this.tbHtml.Select("ParentCode = '" + ConvertRule.ToString(drDst["CostBudgetDtlCode"]) + "'");
                 this.CalcByChilds(drDst, drsChild);
             }
             view = new DataView(this.tbHtml, "Deep = 1", "", DataViewRowState.CurrentRows);
             foreach (DataRowView view2 in view)
             {
                 drDst    = view2.Row;
                 drsChild = this.tbHtml.Select("ParentCode = '" + ConvertRule.ToString(drDst["CostBudgetDtlCode"]) + "'");
                 this.CalcByChilds(drDst, drsChild);
             }
         }
         foreach (DataRow row2 in this.tbHtml.Rows)
         {
             string text6   = ConvertRule.ToString(row2["RecordType"]);
             string classTd = ConvertRule.ToString(row2["ClassTd"]);
             if (text6 == "")
             {
                 row2["PlanDataHtml"] = CostBudgetPageRule.GenerateCostBudgetPlanDataHtml(row2, this.iStartY, this.iEndY, new string[] { "BudgetMoney_", "ContractMoney_" }, new string[] { classTd, CostBudgetPageRule.m_ClassTdContract }, new string[] { "预算", "合同" });
             }
             else
             {
                 row2["PlanDataHtml"] = CostBudgetPageRule.GenerateCostBudgetPlanDataHtml(row2, this.iStartY, this.iEndY, "ContractMoney_", classTd);
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }