Beispiel #1
0
        public static DataTable ApportionAllPayout(string projectCode, string AreaField)
        {
            DataTable table2;

            try
            {
                EntityData buildings           = ProductDAO.GetBuildingNotAreaByProjectCode(projectCode);
                EntityData pBSUnits            = PBSDAO.GetPBSUnitByProject(projectCode);
                DataTable  dtApportion         = BuildApportionTable();
                EntityData payoutByProjectCode = PaymentDAO.GetPayoutByProjectCode(projectCode);
                foreach (DataRow row in payoutByProjectCode.CurrentTable.Rows)
                {
                    string payoutCode = ConvertRule.ToString(row["PayoutCode"]);
                    ApportionOnePayout(projectCode, payoutCode, pBSUnits, buildings, dtApportion, AreaField);
                }
                payoutByProjectCode.Dispose();
                pBSUnits.Dispose();
                buildings.Dispose();
                table2 = dtApportion;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(table2);
        }
Beispiel #2
0
        public static DataTable BuildingCostApportionAllPayout(string projectCode, string DateBegin, string DateEnd, string AreaField)
        {
            DataTable table2;

            try
            {
                EntityData            buildings   = ProductDAO.GetBuildingNotAreaByProjectCode(projectCode);
                EntityData            pBSUnits    = PBSDAO.GetPBSUnitByProject(projectCode);
                EntityData            cBS         = CBSDAO.GetCBSByProject(projectCode);
                DataTable             dtApportion = BuildBuildingCostApportionTable();
                PayoutStrategyBuilder builder     = new PayoutStrategyBuilder("Payout");
                builder.AddStrategy(new Strategy(PayoutStrategyName.ProjectCode, projectCode));
                if ((DateBegin != "") || (DateEnd != ""))
                {
                    ArrayList pas = new ArrayList();
                    pas.Add(DateBegin);
                    pas.Add(DateEnd);
                    builder.AddStrategy(new Strategy(PayoutStrategyName.PayoutDateRange, pas));
                }
                string     queryString = builder.BuildMainQueryString();
                QueryAgent agent       = new QueryAgent();
                EntityData data4       = agent.FillEntityData("Payout", queryString);
                agent.Dispose();
                foreach (DataRow row in data4.CurrentTable.Rows)
                {
                    string payoutCode = ConvertRule.ToString(row["PayoutCode"]);
                    BuildingCostApportionOnePayout(projectCode, payoutCode, pBSUnits, buildings, cBS, dtApportion, AreaField);
                }
                data4.Dispose();
                pBSUnits.Dispose();
                buildings.Dispose();
                cBS.Dispose();
                table2 = dtApportion;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(table2);
        }
Beispiel #3
0
 public static void InsertDefaultConstructAnnualPlan(string ProjectCode)
 {
     try
     {
         string val = GetConstructPlanCurrYearByProject(ProjectCode);
         if (val == "")
         {
             val = DateTime.Today.Year.ToString();
         }
         int        iYear            = ConvertRule.ToInt(val);
         EntityData pBSUnitByProject = PBSDAO.GetPBSUnitByProject(ProjectCode);
         EntityData constructAnnualPlanByProjectYear = ConstructDAO.GetConstructAnnualPlanByProjectYear(ProjectCode, iYear);
         EntityData entity = new EntityData("ConstructAnnualPlan");
         foreach (DataRow row in pBSUnitByProject.CurrentTable.Rows)
         {
             string text2 = row["PBSUnitCode"].ToString();
             if (constructAnnualPlanByProjectYear.CurrentTable.Select("PBSUnitCode='" + text2 + "'").Length == 0)
             {
                 DataRow row2 = entity.CurrentTable.NewRow();
                 row2["AnnualPlanCode"] = SystemManageDAO.GetNewSysCode("AnnualPlanCode");
                 row2["PBSUnitCode"]    = text2;
                 row2["ProjectCode"]    = ProjectCode;
                 row2["IYear"]          = iYear;
                 entity.CurrentTable.Rows.Add(row2);
             }
         }
         ConstructDAO.SubmitAllConstructAnnualPlan(entity);
         entity.Dispose();
         constructAnnualPlanByProjectYear.Dispose();
         pBSUnitByProject.Dispose();
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Beispiel #4
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;
            }
        }
Beispiel #5
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);
        }