Ejemplo n.º 1
0
 private void ReCalcByRelation(string AStartYm, string AEndYm)
 {
     try
     {
         DataView view = new DataView(this.tb, "RecordType = ''", "", DataViewRowState.CurrentRows);
         foreach (DataRowView view2 in view)
         {
             DataRow dr = view2.Row;
             if (ConvertRule.ToString(dr["FullCode"]) != "")
             {
                 DataRow[] drs           = this.tbContract.Select("FullCode like '" + ConvertRule.ToString(dr["FullCode"]) + "%'");
                 string[]  textArray     = new string[] { "ContractMoney", "ContractChangeMoney", "ContractApplyMoney", "ContractPay", "ContractPayReal" };
                 string[]  textArray2    = CostBudgetPageRule.BuildArrayFieldByYm(AStartYm, AEndYm, "PayoutMoneyYm_");
                 string[]  arrColumnName = ConvertRule.ArrayConcat(textArray, textArray2);
                 decimal[] numArray      = MathRule.SumColumn(drs, arrColumnName);
                 int       index         = -1;
                 foreach (string text in arrColumnName)
                 {
                     index++;
                     dr[text] = numArray[index];
                 }
                 CostBudgetPageRule.CostBudgetDtlCalcField(dr, CostBudgetPageRule.m_DynamicRowType.Contract, null, 0, 0);
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Ejemplo n.º 2
0
 private void AddApportion(string ContractCode, string CostCode, string PBSCode, string RecordType, string MoneyField, decimal Money)
 {
     try
     {
         DataRow   row;
         DataRow[] rowArray = this.tbApportion.Select("ContractCode = '" + ContractCode + "' and CostCode='" + CostCode + "' and PBSCode = '" + PBSCode + "'");
         if (rowArray.Length == 0)
         {
             row = this.tbApportion.NewRow();
             row["RecordType"]   = RecordType;
             row["ContractCode"] = ContractCode;
             row["CostCode"]     = CostCode;
             row["PBSCode"]      = PBSCode;
             this.tbApportion.Rows.Add(row);
         }
         else
         {
             row = rowArray[0];
         }
         row[MoneyField] = ConvertRule.ToDecimal(row[MoneyField]) + Money;
         CostBudgetPageRule.CostBudgetDtlCalcField(row, CostBudgetPageRule.m_DynamicRowType.Contract, null, 0, 0);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Ejemplo n.º 3
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;
     }
 }
Ejemplo n.º 4
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;
     }
 }
Ejemplo n.º 5
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;
     }
 }