示例#1
0
文件: CostRule.cs 项目: riyuexing/rms
 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]);
             }
         }
     }
 }
示例#2
0
        public static void ClearDtsPay(string ProjectCode)
        {
            QueryAgent agent = new QueryAgent();

            try
            {
                try
                {
                    agent.ExecuteSql("exec sp_dts_clear_pay '" + ProjectCode + "'");
                    string projectCode = ProjectRule.GetSalProjectCode(ProjectCode);
                    if ((projectCode != "") || (ProjectCode == ""))
                    {
                        new SalService().ClearSalImpFlag(projectCode);
                    }
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
                agent.Dispose();
            }
        }
示例#3
0
文件: CostRule.cs 项目: riyuexing/rms
        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);
            }
        }
示例#4
0
        public static void DtsPaySingleByClient(string ClientCode)
        {
            Exception exception;

            try
            {
                SalService srv   = new SalService();
                DataSet    dsSrc = srv.GetSalDataByClient(ClientCode);
                DataTable  table = dsSrc.Tables["Client"];
                if (table.Rows.Count > 0)
                {
                    string projectCode = ProjectRule.GetProjectCodeBySalProjectCode(table.Rows[0]["proj_code"].ToString());
                    switch (projectCode)
                    {
                    case null:
                    case "":
                        throw new Exception("该客户在项目管理系统中无对应的项目");
                    }
                    using (StandardEntityDAO dao = new StandardEntityDAO("SalClient"))
                    {
                        dao.BeginTrans();
                        try
                        {
                            EntityData data  = ImportSalClientByClient(ClientCode, projectCode, dsSrc, dao);
                            EntityData data2 = ImportSalContractByClient(ClientCode, projectCode, dsSrc, dao);
                            EntityData data3 = ImportSalPayByClient(ClientCode, projectCode, dsSrc, dao);
                            EntityData data4 = ImportSalPayPlanByClient(ClientCode, projectCode, dsSrc, dao);
                            EntityData data5 = ImportSalPayRelaByClient(ClientCode, projectCode, dsSrc, dao);
                            dao.CommitTrans();
                        }
                        catch (Exception exception1)
                        {
                            exception = exception1;
                            try
                            {
                                dao.RollBackTrans();
                            }
                            catch
                            {
                            }
                            throw exception;
                        }
                        SetSalImpFlag(srv, dsSrc);
                    }
                }
            }
            catch (Exception exception2)
            {
                exception = exception2;
                throw exception;
            }
        }
示例#5
0
        public static DataTable GetDtsPayByClient(string ProjectCode, string ClientName)
        {
            string projectCode = "";

            if ((ProjectCode == null) || (ProjectCode == ""))
            {
                projectCode = ProjectRule.GetAllSalProjectCode();
            }
            else
            {
                projectCode = ProjectRule.GetSalProjectCode(ProjectCode);
            }
            SalService service = new SalService();

            return(service.GetSalDataHeadClientByClientName(projectCode, ClientName).Tables[0]);
        }
示例#6
0
        public static string GetUserNameByProjectCode(string ProjectCode, string UserName, string UserShortName, EntityData ProjectData)
        {
            string text3;

            try
            {
                string text = "";
                bool   flag = false;
                if (ProjectData != null)
                {
                    foreach (DataRow row in ProjectData.CurrentTable.Select())
                    {
                        if (row["ProjectCode"].ToString() == ProjectCode)
                        {
                            flag = ProjectRule.IsUseShortNameByValue(row["IsUseShortName"].ToString());
                        }
                    }
                }
                else
                {
                    flag = ProjectRule.IsUseShortNameByProjectCode(ProjectCode);
                }
                if (flag)
                {
                    text = UserShortName;
                    switch (text)
                    {
                    case null:
                    case "":
                        text = UserName;
                        break;
                    }
                }
                else
                {
                    text = UserName;
                }
                text3 = text;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text3);
        }
示例#7
0
        public DataRow ImportSupplierMaterialSingle(string val, EntityData entity, ref string hint, ref string SupplierName, ref string GroupFullName, bool isTest, DataTable tbAllSystemGroup)
        {
            Exception exception;

            hint = "";
            DataRow row = null;

            try
            {
                int        index;
                DataRow    row2;
                string     text4;
                DataColumn column;
                string     s;
                string[]   arr = ImportRule.SplitCsvLine(val);
                if (arr.Length < base.MinColCount)
                {
                    hint = string.Format("列不足{0}个", base.MinColCount);
                    return(null);
                }
                SupplierName  = arr[1].Trim();
                GroupFullName = "";
                if (SupplierName == "")
                {
                    hint = "厂商为空";
                    return(null);
                }
                string text  = arr[0].Trim();
                string text2 = "";
                if (text != "")
                {
                    DataRow[] rowArray = tbAllSystemGroup.Select("FullName = '" + text + "'");
                    if (rowArray.Length > 0)
                    {
                        text2         = rowArray[0]["GroupCode"].ToString();
                        GroupFullName = text;
                    }
                }
                if (text2 == "")
                {
                    hint = string.Format("未知的类型“{0}”", text);
                    return(null);
                }
                string supplierCodeByName = "";
                if (SupplierName != "")
                {
                    supplierCodeByName = ProjectRule.GetSupplierCodeByName(SupplierName);
                }
                if (supplierCodeByName == "")
                {
                    hint = string.Format("厂商信息中找不到厂商“{0}”", SupplierName);
                    return(null);
                }
                int count = base.tbDefine.Rows.Count;
                for (index = 0; index < count; index++)
                {
                    row2  = base.tbDefine.Rows[index];
                    text4 = row2["FieldName"].ToString();
                    string text5 = row2["FieldDesc"].ToString();
                    column = entity.CurrentTable.Columns[text4];
                    if ((text4 != "") && (text4 != "GroupCode"))
                    {
                        s = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                        if ((column.DataType == typeof(string)) && (StringRule.LenB(s) > column.MaxLength))
                        {
                            hint = string.Format("{0}({1})长度超过{2}位(现为{3}位)", new object[] { text5, s, column.MaxLength, s.Length });
                            return(null);
                        }
                    }
                }
                row = entity.CurrentTable.NewRow();
                try
                {
                    if (isTest)
                    {
                        row["SupplierMaterialCode"] = Guid.NewGuid().ToString();
                    }
                    else
                    {
                        row["SupplierMaterialCode"] = SystemManageDAO.GetNewSysCode("SupplierMaterialCode").ToString();
                    }
                    count = base.tbDefine.Rows.Count;
                    for (index = 0; index < count; index++)
                    {
                        row2   = base.tbDefine.Rows[index];
                        text4  = row2["FieldName"].ToString();
                        column = entity.CurrentTable.Columns[text4];
                        if (text4 != "")
                        {
                            string text7 = text4;
                            if (text7 == null)
                            {
                                goto Label_03AE;
                            }
                            if (text7 != "GroupCode")
                            {
                                if (text7 == "SupplierCode")
                                {
                                    goto Label_03A1;
                                }
                                goto Label_03AE;
                            }
                            row[text4] = text2;
                        }
                        continue;
Label_03A1:
                        row[text4] = supplierCodeByName;
                        continue;
Label_03AE:
                        s = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, index)).Trim();
                        if (s == "")
                        {
                            try
                            {
                                row[text4] = s;
                            }
                            catch
                            {
                                row[text4] = DBNull.Value;
                            }
                        }
                        else
                        {
                            row[text4] = s;
                        }
                    }
                    entity.CurrentTable.Rows.Add(row);
                }
                catch (Exception exception1)
                {
                    exception = exception1;
                    row       = null;
                    throw exception;
                }
            }
            catch (Exception exception2)
            {
                exception = exception2;
                hint      = "异常出错:" + exception.Message;
            }
            return(row);
        }
 public void Generate()
 {
     try
     {
         this.InitCostBudgetSet();
         this.SetRelationContract();
         this.SetRelationNoContract();
         string   subjectSetCode = ProjectRule.GetSubjectSetCodeByProject(this.ProjectCode);
         DataView view           = new DataView(SubjectDAO.GetSubjectBySubjectSet(subjectSetCode).CurrentTable, "", "SubjectCode", DataViewRowState.CurrentRows);
         foreach (DataRowView view2 in view)
         {
             DataRow row2        = view2.Row;
             DataRow row         = this.tb.NewRow();
             string  subjectCode = row2["SubjectCode"].ToString();
             row["DtlCode"]    = row2["SubjectCode"];
             row["RecordType"] = "";
             row["CostCode"]   = row2["SubjectCode"];
             row["CostName"]   = row2["SubjectName"];
             row["SortID"]     = row2["SubjectCode"];
             row["ParentCode"] = SubjectRule.GetSubjectParentCode(subjectCode, subjectSetCode);
             row["Deep"]       = row2["Layer"];
             row["FullCode"]   = row2["SubjectCode"];
             row["ChildCount"] = row2["ChildNodesCount"];
             row["IsLeafCBS"]  = ConvertRule.ToInt(row["ChildCount"]) <= 0;
             this.tb.Rows.Add(row);
             DataRow[] rowArray = this.tbContract.Select("CostCode = '" + subjectCode + "'");
             foreach (DataRow row3 in rowArray)
             {
                 string  text3 = row3["ContractCode"].ToString();
                 DataRow drDst = this.tb.NewRow();
                 ConvertRule.DataRowCopy(row3, drDst, this.tbContract, this.tb);
                 drDst["DtlCode"]    = "C_" + subjectCode + ":" + text3;
                 drDst["RecordType"] = row3["RecordType"];
                 drDst["Deep"]       = row["Deep"];
                 drDst["ParentCode"] = row["ParentCode"];
                 drDst["ChildCount"] = 0;
                 drDst["ClassTd"]    = CostBudgetPageRule.m_ClassTdContract;
                 this.tb.Rows.Add(drDst);
                 DataRow[] rowArray2 = this.tbApportion.Select("ContractCode = '" + text3 + "' and CostCode = '" + subjectCode + "'");
                 foreach (DataRow row5 in rowArray2)
                 {
                     string costBudgetSetCode = ConvertRule.ToString(row5["PBSCode"]);
                     drDst = this.tb.NewRow();
                     ConvertRule.DataRowCopy(row5, drDst, this.tbApportion, this.tb);
                     drDst["DtlCode"]      = "A_" + subjectCode + ":" + text3 + "@" + costBudgetSetCode;
                     drDst["RecordType"]   = "Apportion";
                     drDst["PBSCode"]      = costBudgetSetCode;
                     drDst["Deep"]         = row["Deep"];
                     drDst["ParentCode"]   = row["ParentCode"];
                     drDst["ChildCount"]   = 0;
                     drDst["ClassTd"]      = CostBudgetPageRule.m_ClassTdApportion;
                     drDst["ContractName"] = "  " + this.GetCostBudgetSetName(costBudgetSetCode);
                     this.tb.Rows.Add(drDst);
                 }
             }
         }
         this.ReCalcByRelation("", "");
         this.RefreshDateRange();
         for (int i = this.tb.Rows.Count - 1; i >= 0; i--)
         {
             DataRow row6 = this.tb.Rows[i];
             if (((ConvertRule.ToString(row6["RecordType"]) == "") && (ConvertRule.ToString(row6["FullCode"]) != "")) && (ConvertRule.ToInt(row6["IsExistsContract"]) == 0))
             {
                 this.tb.Rows.Remove(row6);
             }
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
示例#9
0
        public static void GetSHTreeDataSource(DataTable dtConsiderDiathesis, DataTable dtBiddingSupplier, DataTable returndt, string GradeMessageCode, string CodeName, string ParentCodeName, string ParentCode, string Code, string LeftStr, int Deep, decimal PercentageValue, string ConsiderDiathesisCode)
        {
            int num5;

            if (Code == "")
            {
                returndt.Columns.Add("code", Type.GetType("System.String"));
                returndt.Columns.Add("freeflag", Type.GetType("System.String"));
                returndt.Columns.Add("issubtotal", Type.GetType("System.String"));
                returndt.Columns.Add("ColumnCount", Type.GetType("System.Int32"));
                returndt.Clear();
                dtConsiderDiathesis.Columns.Add("code", Type.GetType("System.String"));
                dtConsiderDiathesis.Columns.Add("freeflag", Type.GetType("System.String"));
                dtConsiderDiathesis.Columns.Add("issubtotal", Type.GetType("System.String"));
                dtConsiderDiathesis.Columns.Add("ColumnCount", Type.GetType("System.Int32"));
                for (int i = 0; i < dtBiddingSupplier.Rows.Count; i++)
                {
                    returndt.Columns.Add("Point" + (i + 1), Type.GetType("System.String"));
                    returndt.Columns.Add("Code" + (i + 1), Type.GetType("System.String"));
                    returndt.Columns.Add("GradeMessageCode" + (i + 1), Type.GetType("System.String"));
                    returndt.Columns["Point" + (i + 1)].Caption = ProjectRule.GetSupplierName(dtBiddingSupplier.Rows[i]["SupplierCode"].ToString());
                    dtConsiderDiathesis.Columns.Add("Point" + (i + 1), Type.GetType("System.String"));
                    dtConsiderDiathesis.Columns.Add("Code" + (i + 1), Type.GetType("System.String"));
                    dtConsiderDiathesis.Columns.Add("GradeMessageCode" + (i + 1), Type.GetType("System.String"));
                    dtConsiderDiathesis.Columns["Point" + (i + 1)].Caption = ProjectRule.GetSupplierName(dtBiddingSupplier.Rows[i]["SupplierCode"].ToString());
                }
            }
            DataRow[] rowArray     = dtConsiderDiathesis.Select(ParentCodeName + "='" + ParentCode.ToString() + "' and BiddingGradeTypeCode='100002'");
            DataTable currentTable = BiddingGradeMessage.GetAllBiddingGradeMessage().CurrentTable;
            string    text         = "";

            for (int j = 0; j < dtBiddingSupplier.Rows.Count; j++)
            {
                if (j != (dtBiddingSupplier.Rows.Count - 1))
                {
                    text = string.Concat(new object[] { text, "'", dtBiddingSupplier.Rows[j]["BiddingReturnCode"], "'," });
                }
                else
                {
                    text = string.Concat(new object[] { text, "'", dtBiddingSupplier.Rows[j]["BiddingReturnCode"], "'" });
                }
            }
            int       num3     = 0;
            string    text2    = "";
            DataTable biddings = new DataTable();

            if (text != "")
            {
                foreach (DataRow row in currentTable.Select("ApplicationCode in (" + text + ") and BiddingGradeTypeCode='100002'"))
                {
                    if (num3 != (currentTable.Select("ApplicationCode in (" + text + ") and BiddingGradeTypeCode='100002'").Length - 1))
                    {
                        text2 = string.Concat(new object[] { text2, "'", row["BiddingGradeMessageCode"], "'," });
                    }
                    else
                    {
                        text2 = string.Concat(new object[] { text2, "'", row["BiddingGradeMessageCode"], "'" });
                    }
                    num3++;
                }
                BiddingGrade grade = new BiddingGrade();
                grade.BiddingGradeMessageCode = text2;
                biddings = grade.GetBiddings();
            }
            int num4 = 1;

            foreach (DataRow row2 in rowArray)
            {
                if (num4 == 1)
                {
                    row2["freeflag"] = "1";
                }
                else
                {
                    row2["freeflag"] = "0";
                }
                row2["ColumnCount"] = dtBiddingSupplier.Rows.Count;
                row2["code"]        = Code + ((num4.ToString().Length < 2) ? ("0" + num4.ToString()) : num4.ToString());
                row2["Percentage"]  = Convert.ToDecimal(row2["Percentage"]) * 100M;
                row2["issubtotal"]  = "0";
                DataRow row3 = returndt.NewRow();
                row3.ItemArray = row2.ItemArray;
                returndt.Rows.Add(row3);
                for (num5 = 0; num5 < dtBiddingSupplier.Rows.Count; num5++)
                {
                    row3["Point" + (num5 + 1)]            = 0;
                    row3["Code" + (num5 + 1)]             = "";
                    row3["GradeMessageCode" + (num5 + 1)] = "";
                }
                int num6 = 0;
                if (text != "")
                {
                    foreach (DataRow row4 in currentTable.Select("ApplicationCode in (" + text + ") and BiddingGradeTypeCode='100002'"))
                    {
                        num6++;
                        row3["GradeMessageCode" + num6] = row4["BiddingGradeMessageCode"];
                        foreach (DataRow row5 in biddings.Select(string.Concat(new object[] { "BiddingGradeMessageCode='", row4["BiddingGradeMessageCode"], "' and BiddingConsiderDiathesisCode='", row2["BiddingConsiderDiathesisCode"], "'" })))
                        {
                            row3["Code" + num6]  = row5["BiddingGradeCode"];
                            row3["Point" + num6] = row5["GradePoint"];
                        }
                    }
                }
            }
            DataRow row6 = returndt.NewRow();

            row6["BiddingConsiderDiathesisCode"] = "";
            row6["BiddingConsiderDiathesis"]     = "总计";
            row6["GradeGuideline"] = "";
            row6["freeflag"]       = "0";
            row6["ColumnCount"]    = dtBiddingSupplier.Rows.Count;
            row6["code"]           = Code + ((num4.ToString().Length < 2) ? ("0" + num4.ToString()) : num4.ToString());
            row6["Percentage"]     = Convert.ToDecimal(1) * 100M;
            row6["issubtotal"]     = "1";
            returndt.Rows.Add(row6);
            for (num5 = 0; num5 < dtBiddingSupplier.Rows.Count; num5++)
            {
                row6["Point" + (num5 + 1)]            = 0;
                row6["Code" + (num5 + 1)]             = "";
                row6["GradeMessageCode" + (num5 + 1)] = "";
            }
            for (int k = 0; k < (returndt.Rows.Count - 1); k++)
            {
                for (int m = 0; m < Convert.ToInt32(returndt.Rows[0]["ColumnCount"]); m++)
                {
                    row6["Point" + (m + 1)] = Convert.ToString((decimal)(Convert.ToDecimal(row6["Point" + (m + 1)]) + ((Convert.ToDecimal(returndt.Rows[k]["Point" + (m + 1)]) * Convert.ToDecimal(returndt.Rows[k]["Percentage"])) / 100M)));
                }
            }
        }