Beispiel #1
0
        private DataTable LoadDataGrid(int PageIndex, bool isEmpty)
        {
            try
            {
                DataTable tb = null;

                this.txtTotalCost.Value     = "";
                this.txtTotalPayMoney.Value = "";

                string BuildingName = this.sltSearchBuildingName.Value.Trim();
                this.txtBuildingName.Value = BuildingName;

/*				//成品核算按幢号,必须先选择幢号
 *                              if (BuildingName == "")
 *                              {
 *                                      return tb;
 *                              }
 */
                LoadData(BuildingName);

                //计算成本
                BLL.SalCostClass cost = new RmsPM.BLL.SalCostClass(txtProjectCode.Value, BuildingName);

                EntityData entity;

                SalContractStrategyBuilder sb = new SalContractStrategyBuilder();
                sb.AddStrategy(new Strategy(SalContractStrategyName.ProjectCode, txtProjectCode.Value));
                sb.AddStrategy(new Strategy(SalContractStrategyName.BuildingName, BuildingName));

                if (isEmpty)
                {
                    sb.AddStrategy(new Strategy(SalContractStrategyName.False));
                }

                sb.AddOrder("ContractID", true);

                string sql = sb.BuildMainQueryString();

                QueryAgent qa = new QueryAgent();
                entity = qa.FillEntityData("SalContract", sql);
                qa.Dispose();

                tb = entity.CurrentTable;

                DataColumn col = new DataColumn("CostPrice");
                col.DataType = System.Type.GetType("System.Decimal");
                tb.Columns.Add(col);

                col          = new DataColumn("Cost");
                col.DataType = System.Type.GetType("System.Decimal");
                tb.Columns.Add(col);

                int     count    = tb.Rows.Count;
                int     i        = -1;
                decimal RealCost = 0;

                foreach (DataRow dr in tb.Rows)
                {
                    i = i + 1;

                    dr["CostPrice"] = cost.m_CostPrice;

                    decimal area   = 0;
                    decimal a_cost = 0;

                    if (i == count - 1)
                    {
                        //最后一条 = 总成本 - 前n-1条成本
                        a_cost = cost.m_TotalCost - RealCost;
                    }
                    else
                    {
                        //成本 = 成本单价 * 面积
                        try
                        {
                            area = decimal.Parse(dr["BuildDim"].ToString());
                        }
                        catch
                        {
                        }

                        a_cost   = Math.Round(cost.m_CostPrice * area, 2);
                        RealCost = RealCost + a_cost;
                    }

                    dr["Cost"] = a_cost;
                }

                entity.Dispose();

                decimal TotalPayMoney = BLL.MathRule.SumColumn(tb, "TotalPayMoney");

                this.dgList.CurrentPageIndex       = PageIndex;
                this.dgList.DataSource             = tb;
                this.dgList.Columns[2].FooterText  = "笔数:" + tb.Rows.Count.ToString();
                this.dgList.Columns[7].FooterText  = cost.m_TotalArea.ToString("n");
                this.dgList.Columns[9].FooterText  = TotalPayMoney.ToString("n");
                this.dgList.Columns[11].FooterText = cost.m_TotalCost.ToString("n");
                this.txtTotalCost.Value            = cost.m_TotalCost.ToString();
                this.txtTotalPayMoney.Value        = TotalPayMoney.ToString();
                this.dgList.DataBind();
                return(tb);
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "");
                Response.Write(Rms.Web.JavaScript.Alert(true, "显示列表出错:" + ex.Message));
                return(null);
            }
        }
Beispiel #2
0
        private void LoadDataGrid(int PageIndex, bool isEmpty)
        {
            try
            {
                EntityData entity;

                SalContractStrategyBuilder sb = new SalContractStrategyBuilder();
                sb.AddStrategy(new Strategy(SalContractStrategyName.ProjectCode, txtProjectCode.Value));

                string ContractID = this.txtSearchContractID.Value.Trim();
                if (ContractID != "")
                {
                    sb.AddStrategy(new Strategy(SalContractStrategyName.ContractID, ContractID));
                }

                string BuildingName = this.sltSearchBuildingName.Value.Trim();
                if (BuildingName != "")
                {
                    sb.AddStrategy(new Strategy(SalContractStrategyName.BuildingName, BuildingName));
                }

                string Status = this.sltSearchStatus.Value.Trim();;
                if (Status != "")
                {
                    sb.AddStrategy(new Strategy(SalContractStrategyName.Status, Status));
                }

                if (isEmpty)
                {
                    sb.AddStrategy(new Strategy(SalContractStrategyName.False));
                }

                sb.AddOrder("ContractID", true);

                string sql = sb.BuildMainQueryString();

                QueryAgent qa = new QueryAgent();
                entity = qa.FillEntityData("SalContract", sql);
                qa.Dispose();

                this.dgList.CurrentPageIndex      = PageIndex;
                this.dgList.DataSource            = entity.CurrentTable;
                this.dgList.Columns[2].FooterText = "笔数:" + entity.CurrentTable.Rows.Count.ToString();

                string[]  arrField = { "BuildDim", "TotalPrice", "FactPrice", "TotalPayMoney" };
                decimal[] arrSum   = BLL.MathRule.SumColumn(entity.CurrentTable, arrField);
                this.dgList.Columns[8].FooterText  = arrSum[0].ToString("N");
                this.dgList.Columns[9].FooterText  = arrSum[1].ToString("N");
                this.dgList.Columns[10].FooterText = arrSum[2].ToString("N");
                this.dgList.Columns[11].FooterText = arrSum[3].ToString("N");

                this.dgList.DataBind();

                entity.Dispose();
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "");
                Response.Write(Rms.Web.JavaScript.Alert(true, "显示列表出错:" + ex.Message));
            }
        }