Exemple #1
0
        public static string GetSuplCodeByName(string SuplName, string ProjectCode)
        {
            string text = "";
            object obj2 = null;

            if (SuplName != "")
            {
                QueryAgent agent = new QueryAgent();
                try
                {
                    obj2 = agent.ExecuteScalar("select top 1 SuplCode from SalSupl where SuplName = '" + SuplName + "' and ProjectCode = '" + ProjectCode + "'");
                    if ((obj2 != null) && (obj2 != DBNull.Value))
                    {
                        return(obj2.ToString());
                    }
                    obj2 = agent.ExecuteScalar("select top 1 SuplCode from SalSupl where SuplName = '" + SuplName + "' and isnull(ProjectCode, '') = ''");
                    if ((obj2 != null) && (obj2 != DBNull.Value))
                    {
                        text = obj2.ToString();
                    }
                }
                finally
                {
                    agent.Dispose();
                }
            }
            return(text);
        }
Exemple #2
0
        public static string GetPBSTypeFullName(object PBSTypeCode)
        {
            string text2;

            try
            {
                string text = "";
                if ((PBSTypeCode != null) && (PBSTypeCode.ToString() != ""))
                {
                    QueryAgent agent = new QueryAgent();
                    try
                    {
                        object obj2 = agent.ExecuteScalar(string.Format("select dbo.GetPBSTypeFullName('{0}')", PBSTypeCode));
                        if ((obj2 != null) && (obj2 != DBNull.Value))
                        {
                            text = obj2.ToString();
                        }
                    }
                    finally
                    {
                        agent.Dispose();
                    }
                }
                text2 = text;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text2);
        }
Exemple #3
0
        public static string GetSalCBVoucherCode(string BuildingName, string ProjectCode)
        {
            string text2;

            try
            {
                string     text  = "";
                QueryAgent agent = new QueryAgent();
                try
                {
                    object obj2 = agent.ExecuteScalar(string.Format("select dbo.GetSalCBVoucherCode('{0}', '{1}')", BuildingName, ProjectCode));
                    if ((obj2 != null) && (obj2 != DBNull.Value))
                    {
                        text = obj2.ToString();
                    }
                }
                finally
                {
                    agent.Dispose();
                }
                text2 = text;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text2);
        }
Exemple #4
0
 public static void UpdateUniSalProjectCode(string SalProjectCode, string ProjectCode)
 {
     try
     {
         if (SalProjectCode != "")
         {
             ProjectStrategyBuilder builder = new ProjectStrategyBuilder();
             builder.AddStrategy(new Strategy(ProjectStrategyName.SalProjectCode, SalProjectCode));
             builder.AddStrategy(new Strategy(ProjectStrategyName.ProjectCodeNot, ProjectCode));
             string     queryString = builder.BuildMainQueryString();
             QueryAgent agent       = new QueryAgent();
             EntityData data        = agent.FillEntityData("Project", queryString);
             agent.Dispose();
             if (data.HasRecord())
             {
                 foreach (DataRow row in data.CurrentTable.Rows)
                 {
                     string text2 = row["ProjectCode"].ToString();
                     agent.ExecuteScalar(string.Format("update project set SalProjectCode = '' where ProjectCode = '{0}'", text2));
                 }
             }
             data.Dispose();
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemple #5
0
        public static decimal GetSalTotalAreaByProjectBuilding(string ProjectCode, string BuildingName)
        {
            decimal num2;

            try
            {
                decimal    num   = 0M;
                QueryAgent agent = new QueryAgent();
                try
                {
                    object obj2 = agent.ExecuteScalar(string.Format("select sum(isnull(BuildDim, 0)) from SalContract where ProjectCode = '{0}' and BuildingName = '{1}'", ProjectCode, BuildingName));
                    if ((obj2 != null) && (obj2 != DBNull.Value))
                    {
                        try
                        {
                            num = decimal.Parse(obj2.ToString());
                        }
                        catch
                        {
                        }
                    }
                }
                finally
                {
                    agent.Dispose();
                }
                num2 = num;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(num2);
        }
Exemple #6
0
        public static decimal CalcInvestByVisualProgress(decimal TotalInvest, string VisualProgress, int TotalFloorCount, int CurrFloorCount)
        {
            decimal num2;

            try
            {
                decimal    num   = 0M;
                QueryAgent agent = new QueryAgent();
                try
                {
                    string format = "select dbo.GetTotalCompleteInvestNew({0}, '{1}', {2}, {3})";
                    format = string.Format(format, new object[] { TotalInvest, VisualProgress, TotalFloorCount, CurrFloorCount });
                    num    = ConvertRule.ToDecimal(agent.ExecuteScalar(format));
                }
                finally
                {
                    agent.Dispose();
                }
                num2 = num;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(num2);
        }
Exemple #7
0
        public static decimal GetTotalCost(string projectCode)
        {
            decimal num2;

            try
            {
                decimal    num   = 0M;
                QueryAgent agent = new QueryAgent();
                try
                {
                    string format = "select sum(isnull(money, 0)) as TotalCost from Payout where ProjectCode = '{0}'";
                    num = ConvertRule.ToDecimal(agent.ExecuteScalar(string.Format(format, projectCode)));
                }
                finally
                {
                    agent.Dispose();
                }
                num2 = num;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(num2);
        }
Exemple #8
0
        public static string GetSystemGroupFullSortID(string GroupCode)
        {
            string text2;

            try
            {
                string     text  = "";
                QueryAgent agent = new QueryAgent();
                try
                {
                    object obj2 = agent.ExecuteScalar(string.Format("select dbo.GetSystemGroupFullSortID('{0}')", GroupCode));
                    if ((obj2 != null) && (obj2 != DBNull.Value))
                    {
                        text = obj2.ToString();
                    }
                }
                finally
                {
                    agent.Dispose();
                }
                text2 = text;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text2);
        }
Exemple #9
0
        public static string GetSupplierCodeByName(string SuplName)
        {
            string text2;

            try
            {
                string     text  = "";
                QueryAgent agent = new QueryAgent();
                try
                {
                    object obj2 = agent.ExecuteScalar(string.Format("select SupplierCode from Supplier where SupplierName = '{0}'", SuplName));
                    if ((obj2 != null) && (obj2 != DBNull.Value))
                    {
                        text = obj2.ToString();
                    }
                }
                finally
                {
                    agent.Dispose();
                }
                text2 = text;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text2);
        }
Exemple #10
0
        public static string GetProjectCodeByName(string ProjectName)
        {
            string text2;

            try
            {
                string     text  = "";
                QueryAgent agent = new QueryAgent();
                try
                {
                    object obj2 = agent.ExecuteScalar(string.Format("select ProjectCode from Project where ProjectName like '%{0}%'", ProjectName));
                    if ((obj2 != null) && (obj2 != DBNull.Value))
                    {
                        text = obj2.ToString();
                    }
                }
                finally
                {
                    agent.Dispose();
                }
                text2 = text;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text2);
        }
Exemple #11
0
 public static void DeleteSalSuplByProjectCode(string ProjectCode)
 {
     try
     {
         QueryAgent agent       = new QueryAgent();
         string     queryString = "delete SalSupl where isnull(ProjectCode, '') = '" + ProjectCode + "'";
         agent.ExecuteScalar(queryString);
         agent.Dispose();
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Exemple #12
0
        private string GetInStr(string wbsCode)
        {
            string     queryString = " select  dbo.GetAccessWBSFullCode(" + wbsCode + ") ";
            QueryAgent agent       = new QueryAgent();
            string     strTmp      = (string)agent.ExecuteScalar(queryString);

            if (strTmp.Length > 1)
            {
                strTmp = strTmp.Replace('-', ',');
                strTmp = this.CutRepeat(strTmp);
                return("'" + strTmp.Replace(",", "','") + "'");
            }
            return("''");
        }
Exemple #13
0
        public static string GetConstructPlanCurrYearByProject(string ProjectCode)
        {
            string text3;

            try
            {
                string     queryString = string.Format("select top 1 IYear from ConstructAnnualPlan where ProjectCode = '{0}' order by 1 desc", ProjectCode);
                QueryAgent agent       = new QueryAgent();
                string     text2       = ConvertRule.ToString(agent.ExecuteScalar(queryString));
                agent.Dispose();
                text3 = text2;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text3);
        }
Exemple #14
0
        public static decimal GetProjectArea(string projectCode)
        {
            decimal num2;

            try
            {
                BuildingStrategyBuilder builder = new BuildingStrategyBuilder();
                builder.AddStrategy(new Strategy(BuildingStrategyName.ProjectCode, projectCode));
                string     queryString = builder.BuildQuerySumBuildAreaString();
                QueryAgent agent       = new QueryAgent();
                decimal    num         = (decimal)agent.ExecuteScalar(queryString);
                agent.Dispose();
                num2 = num;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(num2);
        }
Exemple #15
0
        public static string GetSubjectParentCode(string subjectCode, string subjectSetCode)
        {
            string text2;

            try
            {
                string     text  = "";
                QueryAgent agent = new QueryAgent();
                try
                {
                    text = agent.ExecuteScalar(string.Format("select dbo.GetSubjectParent('{0}', '{1}')", subjectCode, subjectSetCode)).ToString();
                }
                finally
                {
                    agent.Dispose();
                }
                text2 = text;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text2);
        }
Exemple #16
0
        public static string GetNextSubjectSetCode()
        {
            string text2;

            try
            {
                string     text  = "";
                QueryAgent agent = new QueryAgent();
                try
                {
                    text = (ConvertRule.ToInt(agent.ExecuteScalar("select max(cast(SubjectSetCode as int)) from SubjectSet where IsNumeric(SubjectSetCode) = 1")) + 1).ToString();
                }
                finally
                {
                    agent.Dispose();
                }
                text2 = text;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text2);
        }
Exemple #17
0
        public static DataTable RepRoomIn(string ProjectCode, int JGYear, string BeginDate, string EndDate)
        {
            DataTable table3;

            try
            {
                DataTable table;
                string    format = "";
                if (BeginDate != "")
                {
                    format = format + " and {0} >= convert(DateTime, '" + BeginDate + "', 121)";
                }
                if (EndDate != "")
                {
                    format = format + " and {0} < convert(DateTime, '" + EndDate + "', 121) + 1";
                }
                string     text2 = "select sum(isnull(r.BuildArea, 0))  from TempRoomOut a     , TempRoomStructure b       left join Room r on r.RoomCode = b.TempRoomCode where a.OutListCode = b.OutListCode   and a.CheckState = 1   and a.ProjectCode = '{0}'   and b.TempBuildingCode = '{1}'   and a.out_state = '{2}'";
                string     text3 = "select sum(isnull(r.YuboArea, 0))  from TempRoomOut a     , TempRoomStructure b       left join Building r on r.BuildingCode = b.TempBuildingCode where a.OutListCode = b.OutListCode   and a.CheckState = 1   and a.ProjectCode = '{0}'   and b.TempBuildingCode = '{1}'   and a.out_state = '{2}'";
                QueryAgent agent = new QueryAgent();
                try
                {
                    string queryString = "select a.BuildingCode, a.ProjectCode, a.BuildingName, p.ProjectName, a.Remark, a.YuBoArea, t.PBSTypeName, t.PBSTypeFullName from Building a left join V_PBSType t on t.PBSTypeCode = a.PBSTypeCode, Project p, PBSUnit u where a.ProjectCode = p.ProjectCode and a.PBSUnitCode = u.PBSUnitCode and a.IsArea = 2";
                    if (ProjectCode != "")
                    {
                        string text5 = StrategyConvert.BuildInStr(ProjectCode);
                        queryString = queryString + " and a.ProjectCode in (" + text5 + ")";
                    }
                    string visualProgressJgInStr = PBSRule.GetVisualProgressJgInStr();
                    queryString = queryString + " and u.VisualProgress in (" + visualProgressJgInStr + ")";
                    if (JGYear > 0)
                    {
                        queryString = queryString + " and convert(varchar(4), u.EndDate, 112) = '" + JGYear.ToString() + "'";
                    }
                    queryString = queryString + " order by p.ProjectName, a.BuildingName";
                    table       = agent.ExecSqlForDataSet(queryString).Tables[0];
                    table.Columns.Add("ChamberName", typeof(string));
                    table.Columns.Add("state", typeof(string));
                    table.Columns.Add("BeforeInvArea", typeof(decimal));
                    table.Columns.Add("InArea", typeof(decimal));
                    table.Columns.Add("OutArea", typeof(decimal));
                    table.Columns.Add("BackInArea", typeof(decimal));
                    table.Columns.Add("InvArea", typeof(decimal));
                    foreach (DataRow row in table.Rows)
                    {
                        string text7  = ConvertRule.ToString(row["BuildingCode"]);
                        string text8  = ConvertRule.ToString(row["ProjectCode"]);
                        string text9  = "";
                        string text10 = "";
                        queryString = "select ChamberName from Chamber where BuildingCode = '" + text7 + "' order by ChamberName";
                        DataTable table2 = agent.ExecSqlForDataSet(queryString).Tables[0];
                        foreach (DataRow row2 in table2.Rows)
                        {
                            if (text9.Length > 0)
                            {
                                text9 = text9 + ",";
                            }
                            text9 = text9 + ConvertRule.ToString(row2["ChamberName"]);
                        }
                        row["ChamberName"] = text9;
                        if (text9.Length > 0)
                        {
                            decimal num  = 0M;
                            decimal num2 = 0M;
                            decimal num3 = 0M;
                            if (BeginDate != "")
                            {
                                queryString = string.Format(text2, text8, text7, "入库") + " and a.Out_Date < convert(DateTime, '" + BeginDate + "', 121)";
                                num         = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                                queryString = string.Format(text2, text8, text7, "出库") + " and a.Out_Date < convert(DateTime, '" + BeginDate + "', 121)";
                                num2        = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                                queryString = string.Format(text2, text8, text7, "退库") + " and a.Out_Date < convert(DateTime, '" + BeginDate + "', 121)";
                                num3        = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                            }
                            row["BeforeInvArea"] = (num + num3) - num2;
                            queryString          = string.Format(text2, text8, text7, "入库") + string.Format(format, "a.Out_Date");
                            row["InArea"]        = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                            queryString          = string.Format(text3, text8, text7, "预拨") + string.Format(format, "a.Out_Date");
                            row["YuboArea"]      = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                            queryString          = string.Format(text2, text8, text7, "出库") + string.Format(format, "a.Out_Date");
                            row["OutArea"]       = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                            queryString          = string.Format(text2, text8, text7, "退库") + string.Format(format, "a.Out_Date");
                            row["BackInArea"]    = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                            row["InvArea"]       = ((ConvertRule.ToDecimal(row["BeforeInvArea"]) + ConvertRule.ToDecimal(row["InArea"])) + ConvertRule.ToDecimal(row["BackInArea"])) - ConvertRule.ToDecimal(row["OutArea"]);
                            if (EndDate == "")
                            {
                                queryString = "select top 1 1 from room where BuildingCode = '" + text7 + "' and isnull(InvState, '') not in ('入库', '出库', '退库')";
                            }
                            else
                            {
                                queryString = "select top 1 1 from room r where BuildingCode = '" + text7 + "' and not exists( select a.*   from TempRoomOut a      , TempRoomStructure b  where a.OutListCode = b.OutListCode    and b.TempRoomCode = r.RoomCode    and a.CheckState = 1    and a.out_state in ('入库', '出库', '退库')    and a.Out_Date < convert(DateTime, '" + EndDate + "', 121) + 1)";
                            }
                            if (ConvertRule.ToString(agent.ExecuteScalar(queryString)) == "")
                            {
                                text10 = "入库";
                            }
                            else
                            {
                                text10 = "未入库";
                            }
                        }
                        row["state"] = text10;
                    }
                }
                finally
                {
                    agent.Dispose();
                }
                table3 = table;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(table3);
        }
Exemple #18
0
        public static string CheckDeleteSystemGroup(string GroupCode)
        {
            string text13;

            try
            {
                string     text = "";
                EntityData systemGroupByCode = SystemManageDAO.GetSystemGroupByCode(GroupCode);
                if (systemGroupByCode.HasRecord())
                {
                    string classCode           = systemGroupByCode.GetString("ClassCode");
                    string parentFullID        = systemGroupByCode.GetString("FullID");
                    string itemInfoByClassCode = SystemClassDescription.GetItemInfoByClassCode(classCode);
                    if (itemInfoByClassCode != "")
                    {
                        EntityData systemGroupIncludeAllChildByParentFullID = SystemManageDAO.GetSystemGroupIncludeAllChildByParentFullID(parentFullID);
                        string     text5 = "";
                        foreach (DataRow row in systemGroupIncludeAllChildByParentFullID.CurrentTable.Rows)
                        {
                            string text6 = row["GroupCode"].ToString();
                            if (text5 != "")
                            {
                                text5 = text5 + ",";
                            }
                            text5 = text5 + "'" + text6 + "'";
                        }
                        string[] textArray = itemInfoByClassCode.Split(",".ToCharArray());
                        foreach (string text7 in textArray)
                        {
                            if (text7 != "")
                            {
                                string[]   textArray2  = text7.Split("|".ToCharArray());
                                string     text8       = textArray2[0];
                                string     text9       = textArray2[1];
                                string     queryString = string.Format("select top 1 {1} from {0} where {1} in ({2})", text8, text9, text5);
                                QueryAgent agent       = new QueryAgent();
                                try
                                {
                                    try
                                    {
                                        string code = ConvertRule.ToString(agent.ExecuteScalar(queryString));
                                        if (code != "")
                                        {
                                            EntityData data3  = SystemManageDAO.GetSystemGroupByCode(code);
                                            string     text12 = data3.GetString("SortID") + " " + data3.GetString("GroupName");
                                            data3.Dispose();
                                            return(string.Format("表 {0} 中已存在类别为 {1} 的记录,不能删除该类别", text8, text12));
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                                finally
                                {
                                    agent.Dispose();
                                }
                            }
                        }
                    }
                }
                systemGroupByCode.Dispose();
                text13 = text;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text13);
        }
        /// <summary>
        /// 保存
        /// </summary>
        private void Save()
        {
            try
            {
                string ProjectCode       = this.txtProjectCode.Value;
                string CostBudgetSetCode = this.txtCostBudgetSetCode.Value;
                string StartYm           = this.txtStartYm.Value;
                string EndYm             = this.txtEndYm.Value;
                int    MonthCount        = BLL.StringRule.GetMonthsBetween(StartYm, EndYm);

                QueryAgent qa = new QueryAgent();
                try
                {
                    //合同付款计划
                    string sql = "select p.*"
                                 + ", a.CostCode"
                                 + ", convert(varchar(6), p.PlanningPayDate, 112) as PlanYm"
                                 + " from ContractCost a"
                                 + ", Contract b"
                                 + ", ContractCostPlan p"
                                 + " where a.ContractCode = b.ContractCode"
                                 + " and a.ContractCostCode = p.ContractCostCode"
                                 + " and b.ProjectCode = '" + ProjectCode + "'"
                                 + " and a.CostBudgetSetCode = '" + CostBudgetSetCode + "'"
                                 + " and convert(varchar(6), p.PlanningPayDate, 112) between '" + StartYm + "' and '" + EndYm + "'"
                    ;
                    EntityData entity = qa.FillEntityData("ContractCostPlan", sql);

                    //招标付款计划
                    sql = "select p.*"
                          + ", a.CostCode"
                          + ", convert(varchar(6), p.PlanningPayDate, 112) as PlanYm"
                          + " from BiddingDtl a"
                          + ", Bidding b"
                          + ", BiddingDtlPlan p"
                          + " where a.BiddingCode = b.BiddingCode"
                          + " and a.BiddingDtlCode = p.BiddingDtlCode"
                          + " and b.ProjectCode = '" + ProjectCode + "'"
                          + " and a.CostBudgetSetCode = '" + CostBudgetSetCode + "'"
                          + " and convert(varchar(6), p.PlanningPayDate, 112) between '" + StartYm + "' and '" + EndYm + "'"
                    ;
                    EntityData entityBidding = qa.FillEntityData("BiddingDtlPlan", sql);

                    //预留金额表头
                    DataRow    drCostBudget     = null;
                    string     CostBudgetCode   = "";
                    EntityData entityCostBudget = BLL.CostBudgetRule.GetValidCostBudget(CostBudgetSetCode, 0, false);
                    if (entityCostBudget.HasRecord())
                    {
                        CostBudgetCode = entityCostBudget.GetString("CostBudgetCode");
                        drCostBudget   = entityCostBudget.CurrentRow;
                    }

                    //预留金额明细
                    EntityData entityCostBudgetDtl = DAL.EntityDAO.CostBudgetDAO.GetCostBudgetDtlByCostBudgetCode(CostBudgetCode);

                    //预留金额付款计划
                    sql = "select b.*"
                          + ", a.CostCode"
                          + ", right('0000' + cast(b.IYear as varchar), 4) + right('00' + cast(b.IMonth as varchar), 2) as PlanYm"
                          + " from CostBudgetDtl a"
                          + ", CostBudgetMonth b"
                          + " where a.CostBudgetDtlCode = b.CostBudgetDtlCode"
                          + " and a.ProjectCode = '" + ProjectCode + "'"
                          + " and a.CostBudgetCode = '" + CostBudgetCode + "'"
                          + " and right('0000' + cast(b.IYear as varchar), 4) + right('00' + cast(b.IMonth as varchar), 2) between '" + StartYm + "' and '" + EndYm + "'"
                    ;
                    EntityData entityCostBudgetMonth = qa.FillEntityData("CostBudgetMonth", sql);

                    foreach (RepeaterItem item in this.dgList.Items)
                    {
                        HtmlInputHidden txtContractCode = (HtmlInputHidden)item.FindControl("txtContractCode");
                        string          ContractCode    = txtContractCode.Value;

                        if (ContractCode != "")
                        {
                            HtmlInputHidden txtCostCode = (HtmlInputHidden)item.FindControl("txtCostCode");
                            string          CostCode    = txtCostCode.Value;
                            string          RecordType  = txtContractCode.Attributes["RecordType"];

                            //取该费用项的预留金额明细
                            DataRow   drCostBudgetDtl  = null;
                            DataRow[] drsCostBudgetDtl = entityCostBudgetDtl.CurrentTable.Select(string.Format("CostCode = '{0}'", CostCode), "", DataViewRowState.CurrentRows);
                            if (drsCostBudgetDtl.Length > 0)
                            {
                                drCostBudgetDtl = drsCostBudgetDtl[0];
                            }

                            //年月循环
                            for (int i = 0; i < MonthCount; i++)
                            {
                                string ym = BLL.StringRule.YmAddMonths(StartYm, i);

                                HtmlInputText txtPlanMoney = (HtmlInputText)item.FindControl("txtPlanMoney_" + ym);
                                decimal       PlanMoney    = BLL.ConvertRule.ToDecimal(txtPlanMoney.Value);

                                if (RecordType == "Bidding") //招标-------------------------------
                                {
                                    string BiddingCode = ContractCode.Substring("Bidding_".Length).Split("#"[0])[0];

                                    //取该招标该费用项该年月的计划
                                    DataRow[] drsPlan = entityBidding.CurrentTable.Select(string.Format("BiddingCode = '{0}' and CostCode = '{1}' and PlanYm = '{2}'", BiddingCode, CostCode, ym), "", DataViewRowState.CurrentRows);
                                    if (PlanMoney == 0)
                                    {
                                        //计划金额为0时,删除计划
                                        for (int j = drsPlan.Length - 1; j >= 0; j--)
                                        {
                                            drsPlan[j].Delete();
                                        }
                                    }
                                    else
                                    {
                                        if (drsPlan.Length == 0)
                                        {
                                            //无计划时,新增计划

                                            //取BiddingDtl中的Code
                                            sql = "select top 1 BiddingDtlCode from BiddingDtl"
                                                  + " where BiddingCode = '" + BiddingCode + "'"
                                                  + " and CostBudgetSetCode = '" + CostBudgetSetCode + "'"
                                                  + " and CostCode = '" + CostCode + "'"
                                            ;
                                            string BiddingDtlCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(sql));

                                            if (BiddingDtlCode != "")
                                            {
                                                DataRow drPlan = entityBidding.CurrentTable.NewRow();

                                                drPlan["BiddingDtlPlanCode"] = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("BiddingDtlPlanCode");
                                                drPlan["BiddingCode"]        = BiddingCode;
                                                drPlan["BiddingDtlCode"]     = BiddingDtlCode;
                                                drPlan["PlanningPayDate"]    = BLL.ConvertRule.ToDate(ym.Substring(0, 4) + "-" + ym.Substring(4, 2) + "-01");
                                                drPlan["Money"] = PlanMoney;

                                                entityBidding.CurrentTable.Rows.Add(drPlan);
                                            }
                                        }
                                        else
                                        {
                                            //总金额改变时才修改
                                            decimal OldMoney = BLL.MathRule.SumColumn(drsPlan, "Money");
                                            if (PlanMoney != OldMoney)
                                            {
                                                //保留计划的第1条,第2条及以后记录删除
                                                if (drsPlan.Length > 1)
                                                {
                                                    for (int j = drsPlan.Length - 1; j >= 1; j--)
                                                    {
                                                        drsPlan[j].Delete();
                                                    }
                                                }

                                                //金额改在第1条计划上
                                                drsPlan[0]["Money"] = PlanMoney;
                                            }
                                        }
                                    }
                                }
                                else if (RecordType == "Balance") //预留金额-------------------------------
                                {
                                    //取该费用项该年月的计划
                                    DataRow[] drsPlan = entityCostBudgetMonth.CurrentTable.Select(string.Format("CostCode = '{0}' and PlanYm = '{1}'", CostCode, ym), "", DataViewRowState.CurrentRows);

                                    if (PlanMoney == 0)
                                    {
                                        //计划金额为0时,删除计划
                                        for (int j = drsPlan.Length - 1; j >= 0; j--)
                                        {
                                            drsPlan[j].Delete();
                                        }

                                        ////若明细的预留金额为0,删除明细
                                        //if ((drDtl != null) && (BLL.ConvertRule.ToDecimal(drDtl["BudgetMoney"]) == 0) && (BLL.ConvertRule.ToString(drDtl["Description"]) == ""))
                                        //    drDtl.Delete();
                                    }
                                    else
                                    {
                                        //新增预留金额表头
                                        if (drCostBudget == null)
                                        {
                                            drCostBudget   = entityCostBudget.CurrentTable.NewRow();
                                            CostBudgetCode = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("CostBudgetCode");
                                            drCostBudget["CostBudgetCode"]      = CostBudgetCode;
                                            drCostBudget["ProjectCode"]         = ProjectCode;
                                            drCostBudget["CostBudgetSetCode"]   = CostBudgetSetCode;
                                            drCostBudget["TargetFlag"]          = 0;
                                            drCostBudget["Status"]              = 1;
                                            drCostBudget["VerID"]               = 0;
                                            drCostBudget["FirstCostBudgetCode"] = drCostBudget["CostBudgetCode"];
                                            drCostBudget["TotalBudgetMoney"]    = 0;
                                            drCostBudget["ModifyDate"]          = DateTime.Now;
                                            drCostBudget["ModifyPerson"]        = user.UserCode;
                                            entityCostBudget.CurrentTable.Rows.Add(drCostBudget);
                                        }

                                        //新增预留金额明细
                                        if (drCostBudgetDtl == null)
                                        {
                                            drCostBudgetDtl = entityCostBudgetDtl.CurrentTable.NewRow();
                                            drCostBudgetDtl["CostBudgetDtlCode"] = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("CostBudgetDtlCode");
                                            drCostBudgetDtl["CostBudgetCode"]    = CostBudgetCode;
                                            drCostBudgetDtl["ProjectCode"]       = ProjectCode;
                                            drCostBudgetDtl["CostCode"]          = CostCode;
                                            drCostBudgetDtl["BudgetMoney"]       = 0;
                                            entityCostBudgetDtl.CurrentTable.Rows.Add(drCostBudgetDtl);
                                        }

                                        DataRow drPlan = null;
                                        if (drsPlan.Length == 0)
                                        {
                                            //无计划时,新增计划
                                            drPlan = entityCostBudgetMonth.CurrentTable.NewRow();

                                            drPlan["CostBudgetMonthCode"] = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("CostBudgetMonthCode");
                                            drPlan["CostBudgetDtlCode"]   = drCostBudgetDtl["CostBudgetDtlCode"];
                                            drPlan["CostBudgetCode"]      = CostBudgetCode;
                                            drPlan["ProjectCode"]         = ProjectCode;
                                            drPlan["IYear"]  = BLL.ConvertRule.ToInt(ym.Substring(0, 4));
                                            drPlan["IMonth"] = BLL.ConvertRule.ToInt(ym.Substring(4, 2));

                                            entityCostBudgetMonth.CurrentTable.Rows.Add(drPlan);
                                        }
                                        else
                                        {
                                            drPlan = drsPlan[0];
                                        }

                                        drPlan["BudgetMoney"] = PlanMoney;
                                    }
                                }
                                else //合同-------------------------------------------------------
                                {
                                    //取该合同该费用项该年月的计划
                                    DataRow[] drsPlan = entity.CurrentTable.Select(string.Format("ContractCode = '{0}' and CostCode = '{1}' and PlanYm = '{2}'", ContractCode, CostCode, ym), "", DataViewRowState.CurrentRows);
                                    if (PlanMoney == 0)
                                    {
                                        //计划金额为0时,删除计划
                                        for (int j = drsPlan.Length - 1; j >= 0; j--)
                                        {
                                            drsPlan[j].Delete();
                                        }
                                    }
                                    else
                                    {
                                        if (drsPlan.Length == 0)
                                        {
                                            //无计划时,新增计划

                                            //取ContractCost中的Code
                                            sql = "select top 1 ContractCostCode from ContractCost"
                                                  + " where ContractCode = '" + ContractCode + "'"
                                                  + " and CostBudgetSetCode = '" + CostBudgetSetCode + "'"
                                                  + " and CostCode = '" + CostCode + "'"
                                            ;
                                            string ContractCostCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(sql));

                                            if (ContractCostCode != "")
                                            {
                                                DataRow drPlan = entity.CurrentTable.NewRow();

                                                drPlan["ContractCostPlanCode"] = DAL.EntityDAO.SystemManageDAO.GetNewSysCode("ContractCostPlanCode");
                                                drPlan["ContractCode"]         = ContractCode;
                                                drPlan["ContractCostCode"]     = ContractCostCode;
                                                drPlan["PlanningPayDate"]      = BLL.ConvertRule.ToDate(ym.Substring(0, 4) + "-" + ym.Substring(4, 2) + "-01");
                                                drPlan["Money"] = PlanMoney;

                                                entity.CurrentTable.Rows.Add(drPlan);
                                            }
                                        }
                                        else
                                        {
                                            //总金额改变时才修改
                                            decimal OldMoney = BLL.MathRule.SumColumn(drsPlan, "Money");
                                            if (PlanMoney != OldMoney)
                                            {
                                                //保留计划的第1条,第2条及以后记录删除
                                                if (drsPlan.Length > 1)
                                                {
                                                    for (int j = drsPlan.Length - 1; j >= 1; j--)
                                                    {
                                                        drsPlan[j].Delete();
                                                    }
                                                }

                                                //金额改在第1条计划上
                                                drsPlan[0]["Money"] = PlanMoney;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    DAL.EntityDAO.ContractDAO.SubmitAllContractCostPlan(entity);
                    DAL.EntityDAO.BiddingDAO.SubmitAllBiddingDtlPlan(entityBidding);
                    DAL.EntityDAO.CostBudgetDAO.SubmitAllCostBudget(entityCostBudget);
                    DAL.EntityDAO.CostBudgetDAO.SubmitAllCostBudgetDtl(entityCostBudgetDtl);
                    DAL.EntityDAO.CostBudgetDAO.SubmitAllCostBudgetMonth(entityCostBudgetMonth);

                    entity.Dispose();
                    entityBidding.Dispose();
                    entityCostBudgetMonth.Dispose();
                    entityCostBudgetDtl.Dispose();
                    entityCostBudget.Dispose();
                }
                finally
                {
                    qa.Dispose();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #20
0
        /// <summary>
        /// 清空
        /// </summary>
        private static void DeleteSingle(string ProjectCode, string VoucherID)
        {
            try
            {
                string VoucherCode = "";

                //取系统的凭证号
                QueryAgent qa = new QueryAgent();
                try
                {
                    VoucherCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(String.Format("select VoucherCode from Voucher where VoucherID = '{0}' and ProjectCode='{1}'", VoucherID, ProjectCode)));
                }
                finally
                {
                    qa.Dispose();
                }

                //删除老的凭证、请款、付款
                //事务处理
                using (StandardEntityDAO dao = new StandardEntityDAO("Voucher"))
                {
                    dao.BeginTrans();
                    try
                    {
                        if (VoucherCode != "")
                        {
                            //删除凭证
                            dao.EntityName = "Standard_Voucher";
                            EntityData entityV = DAL.EntityDAO.PaymentDAO.GetStandard_VoucherByCode(VoucherCode);
                            if (entityV.HasRecord())
                            {
                                dao.DeleteAllRow(entityV);
                                dao.DeleteEntity(entityV);
                            }
                            entityV.Dispose();
                        }

                        //取系统的请款单号
                        string PaymentCode = "";
                        qa = new Rms.ORMap.QueryAgent();
                        try
                        {
                            PaymentCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(String.Format("select PaymentCode from Payment where PaymentID = '{0}' and ProjectCode='{1}'", VoucherID, ProjectCode)));
                        }
                        finally
                        {
                            qa.Dispose();
                        }

                        //删除请款
                        if (PaymentCode != "")
                        {
                            dao.EntityName = "Standard_Payment";
                            EntityData entityP = DAL.EntityDAO.PaymentDAO.GetStandard_PaymentByCode(PaymentCode);
                            if (entityP.HasRecord())
                            {
                                dao.DeleteAllRow(entityP);
                                dao.DeleteEntity(entityP);
                            }
                            entityP.Dispose();
                        }

                        //取系统的付款单号
                        string PayoutCode = "";
                        qa = new Rms.ORMap.QueryAgent();
                        try
                        {
                            PayoutCode = BLL.ConvertRule.ToString(qa.ExecuteScalar(String.Format("select PayoutCode from Payout where PayoutID = '{0}' and ProjectCode='{1}'", VoucherID, ProjectCode)));
                        }
                        finally
                        {
                            qa.Dispose();
                        }

                        //删除付款
                        if (PayoutCode != "")
                        {
                            dao.EntityName = "Standard_Payout";
                            EntityData entityP = DAL.EntityDAO.PaymentDAO.GetStandard_PayoutByCode(PayoutCode);
                            if (entityP.HasRecord())
                            {
                                dao.DeleteAllRow(entityP);
                                dao.DeleteEntity(entityP);
                            }
                            entityP.Dispose();
                        }

                        dao.CommitTrans();
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            //RollBackTrans会报错:此 SqlTransaction 已完成;它再也无法使用
                            dao.RollBackTrans();
                        }
                        catch
                        {
                        }

                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #21
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.tbPlan.Select("RecordType = 'Contract'");
         length   = rowArray.Length;
         for (index = length - 1; index >= 0; index--)
         {
             this.tbPlan.Rows.Remove(rowArray[index]);
         }
         QueryAgent agent = new QueryAgent();
         try
         {
             string    queryString = "select c.FullCode, s.SupplierName, a.*, b.* from ContractCost a left join CBS c on c.CostCode = a.CostCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode where a.ContractCode = b.ContractCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and b.Status in (0, 2) and not exists (select * from ContractChange g where g.ContractCode = b.ContractCode)";
             DataTable tbSrc       = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractMoney");
             queryString = "select c.FullCode, a.Money as Money, s.SupplierName, a.*, b.* from ContractCostChange a left join CBS c on c.CostCode = a.CostCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode where a.ContractCode = b.ContractCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' 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)";
             tbSrc       = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractMoney");
             queryString = "select c.FullCode, a.ChangeMoney as Money, s.SupplierName, a.*, b.* from ContractCostChange a left join CBS c on c.CostCode = a.CostCode, 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 a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and b.Status not in (3) and g.Status in (0) and a.ChangeMoney <> 0";
             tbSrc       = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractChangeMoney");
             queryString = "select c.FullCode, s.SupplierName, a.*, b.* from ContractCost a left join CBS c on c.CostCode = a.CostCode, Contract b left join Supplier s on s.SupplierCode = b.SupplierCode where a.ContractCode = b.ContractCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and b.Status in (1, 7)";
             tbSrc       = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractApplyMoney");
             queryString = "select c.FullCode, s.SupplierName, a.ChangeMoney as Money, a.*, b.* from ContractCostChange a left join CBS c on c.CostCode = a.CostCode, 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 a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and b.Status not in (3) and g.Status in (1, 2) and a.ChangeMoney <> 0";
             tbSrc       = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.AddRelationContractRow(this.tbContract, tbSrc, "Contract", "ContractApplyMoney");
             queryString = "select c.FullCode, 'Contract' as RecordType, a.CostCode, a.ContractCode, convert(varchar(6), p.PlanningPayDate, 112) as PlanYm, sum(isnull(p.Money, 0)) as PlanMoney from ContractCost a left join CBS c on c.CostCode = a.CostCode, Contract b, ContractCostPlan p where a.ContractCode = b.ContractCode and a.ContractCostCode = p.ContractCostCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and convert(varchar(6), p.PlanningPayDate, 112) between '" + this.StartYm + "' and '" + this.EndYm + "' group by c.FullCode, a.CostCode, a.ContractCode, convert(varchar(6), p.PlanningPayDate, 112)";
             tbSrc       = agent.ExecSqlForDataSet(queryString).Tables[0];
             this.AddPlan(tbSrc, "");
             foreach (DataRow row in this.tbContract.Rows)
             {
                 string text2 = ConvertRule.ToString(row["ContractCode"]);
                 if (ConvertRule.ToString(row["AllContractCode"]) != "")
                 {
                     queryString        = "select sum(isnull(a.ItemMoney, 0)) from PaymentItem a, Payment b where a.PaymentCode = b.PaymentCode and b.ProjectCode = '" + this.ProjectCode + "' and a.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and b.Status in (1, 2) and b.ContractCode in (" + ConvertRule.ToString(row["AllContractCode"]) + ") and a.CostCode = '" + ConvertRule.ToString(row["CostCode"]) + "'";
                     row["ContractPay"] = ConvertRule.ToDecimal(agent.ExecuteScalar(queryString));
                     queryString        = "select a.PayoutCode, b.PayoutDate, a.PayoutMoney as Money, '" + text2 + "' as ContractCode, mi.CostCode, c.FullCode from PayoutItem a inner join Payout b on b.PayoutCode = a.PayoutCode, PaymentItem mi left join CBS c on c.CostCode = mi.CostCode, Payment m where a.PaymentItemCode = mi.PaymentItemCode and mi.PaymentCode = m.PaymentCode and m.ProjectCode = '" + this.ProjectCode + "' and mi.CostBudgetSetCode = '" + this.CostBudgetSetCode + "' and m.ContractCode in (" + ConvertRule.ToString(row["AllContractCode"]) + ") and mi.CostCode = '" + ConvertRule.ToString(row["CostCode"]) + "'";
                     tbSrc = agent.ExecSqlForDataSet(queryString).Tables[0];
                     row["ContractPayReal"] = MathRule.SumColumn(tbSrc, "Money");
                 }
             }
             CostBudgetPageRule.CostBudgetDtlCalcAllRow(this.tbContract, CostBudgetPageRule.m_DynamicRowType.Contract, null, 0, 0);
         }
         finally
         {
             agent.Dispose();
         }
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }