Example #1
0
 private static void GetBuildingInfo(string alloType, string buildingCode, ref string buildingName, ref decimal buildingArea, EntityData PBSUnits, EntityData buildings, string AreaField)
 {
     if (alloType == "P")
     {
         buildingName = ProjectRule.GetProjectName(buildingCode);
         buildingArea = MathRule.SumColumn(buildings.CurrentTable, AreaField);
     }
     else
     {
         DataRow[] rowArray;
         if (alloType == "U")
         {
             rowArray = PBSUnits.CurrentTable.Select(string.Format("PBSUnitCode='{0}'", buildingCode));
             if (rowArray.Length > 0)
             {
                 buildingName = ConvertRule.ToString(rowArray[0]["PBSUnitName"]);
                 buildingArea = ConvertRule.ToDecimal(rowArray[0]["BuildingAreaSum"]);
             }
         }
         else if (alloType == "B")
         {
             rowArray = buildings.CurrentTable.Select(string.Format("BuildingCode='{0}'", buildingCode));
             if (rowArray.Length > 0)
             {
                 buildingName = ConvertRule.ToString(rowArray[0]["BuildingName"]);
                 buildingArea = ConvertRule.ToDecimal(rowArray[0][AreaField]);
             }
         }
     }
 }
Example #2
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);
            }
        }