public static BG_BudItems AddBG_BudItems(BG_BudItems bG_BudItems)
        {
            string sql =
                "INSERT BG_BudItems (BIProType, BIFunSub, BICode, PPID, PIID, BIPlanHz, BIStaTime, BIEndTime, BICharger, BIAttr, BIAppReaCon, BIExpGistExp, BILongGoal, BIYearGoal, BIMon, BIAppConMon, BIMonSou, BIFinAllo, BILastYearCarry, BIOthFun, BIOthExpProb, BIBudSta, BudSta, BICause, DepID, BIProName, BIReportTime, BIConNum, BIProDescrip, BIProCategory, BIYear)" +
                "VALUES (@BIProType, @BIFunSub, @BICode, @PPID, @PIID, @BIPlanHz, @BIStaTime, @BIEndTime, @BICharger, @BIAttr, @BIAppReaCon, @BIExpGistExp, @BILongGoal, @BIYearGoal, @BIMon, @BIAppConMon, @BIMonSou, @BIFinAllo, @BILastYearCarry, @BIOthFun, @BIOthExpProb, @BIBudSta, @BudSta, @BICause, @DepID, @BIProName, @BIReportTime, @BIConNum, @BIProDescrip, @BIProCategory, @BIYear)";

            sql += " ; SELECT @@IDENTITY";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@BIProType", bG_BudItems.BIProType),
                    new SqlParameter("@BIFunSub", bG_BudItems.BIFunSub),
                    new SqlParameter("@BICode", bG_BudItems.BICode),
                    new SqlParameter("@PPID", bG_BudItems.PPID),
                    new SqlParameter("@PIID", bG_BudItems.PIID),
                    new SqlParameter("@BIPlanHz", bG_BudItems.BIPlanHz),
                    new SqlParameter("@BIStaTime", bG_BudItems.BIStaTime),
                    new SqlParameter("@BIEndTime", bG_BudItems.BIEndTime),
                    new SqlParameter("@BICharger", bG_BudItems.BICharger),
                    new SqlParameter("@BIAttr", bG_BudItems.BIAttr),
                    new SqlParameter("@BIAppReaCon", bG_BudItems.BIAppReaCon),
                    new SqlParameter("@BIExpGistExp", bG_BudItems.BIExpGistExp),
                    new SqlParameter("@BILongGoal", bG_BudItems.BILongGoal),
                    new SqlParameter("@BIYearGoal", bG_BudItems.BIYearGoal),
                    new SqlParameter("@BIMon", bG_BudItems.BIMon),
                    new SqlParameter("@BIAppConMon", bG_BudItems.BIAppConMon),
                    new SqlParameter("@BIMonSou", bG_BudItems.BIMonSou),
                    new SqlParameter("@BIFinAllo", bG_BudItems.BIFinAllo),
                    new SqlParameter("@BILastYearCarry", bG_BudItems.BILastYearCarry),
                    new SqlParameter("@BIOthFun", bG_BudItems.BIOthFun),
                    new SqlParameter("@BIOthExpProb", bG_BudItems.BIOthExpProb),
                    new SqlParameter("@BIBudSta", bG_BudItems.BIBudSta),
                    new SqlParameter("@BudSta", bG_BudItems.BudSta),
                    new SqlParameter("@BICause", bG_BudItems.BICause),
                    new SqlParameter("@DepID", bG_BudItems.DepID),
                    new SqlParameter("@BIProName", bG_BudItems.BIProName),
                    new SqlParameter("@BIReportTime", bG_BudItems.BIReportTime),
                    new SqlParameter("@BIConNum", bG_BudItems.BIConNum),
                    new SqlParameter("@BIProDescrip", bG_BudItems.BIProDescrip),
                    new SqlParameter("@BIProCategory", bG_BudItems.BIProCategory),
                    new SqlParameter("@BIYear", bG_BudItems.BIYear)
                };

                string IdStr = DBUnity.ExecuteScalar(CommandType.Text, sql, para);
                int newId = Convert.ToInt32(IdStr);
                return GetBG_BudItemsByBudID(newId);

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
        /// <summary>
        /// 添加一条预算项目信息
        /// </summary>
        /// <param name="budItems">一条预算项目实例</param>
        /// <returns>bool</returns>
        public static bool AddbudItems(BG_BudItems budItems)
        {
            bool flag = false;
            try
            {
                string sqlStr = @"insert into BG_BudItems(BIProType,BIFunSub,BICode,PPID,PIID,BIPlanHz,BIStaTime,BIEndTime,BICharger,BIAttr,BIAppReaCon,
                                 BIExpGistExp,BILongGoal,BIYearGoal,BIMon,BIAppConMon,BIMonSou,BIFinAllo,BILastYearCarry,BIOthFun,BIOthExpProb,BIBudSta,BudSta,BICause,DepID,BIProName,BIReportTime,BIConNum,BIProDescrip,BIProCategory)
                                values(@BIProType,@BIFunSub,@BICode,@PPID,@PIID,@BIPlanHz,@BIStaTime,@BIEndTime,@BICharger,@BIAttr,@BIAppReaCon,@BIExpGistExp,@BILongGoal,
                                 @BIYearGoal,@BIMon,@BIAppConMon,@BIMonSou,@BIFinAllo,@BILastYearCarry,@BIOthFun,@BIOthExpProb,@BIBudSta,@BudSta,@BICause,@DepID,@BIProName,@BIReportTime,@BIConNum,@BIProDescrip,@BIProCategory)";

                SqlParameter[] Pars = new SqlParameter[]{
                        new SqlParameter("@BIProType",budItems.BIProType),
                        new SqlParameter("@BIFunSub",budItems.BIFunSub),
                        new SqlParameter("@BICode",budItems.BICode),
                        new SqlParameter("@PPID",budItems.PPID),
                        new SqlParameter("@PIID",budItems.PIID),
                        new SqlParameter("@BIPlanHz",budItems.BIPlanHz),
                        new SqlParameter("@BIStaTime",budItems.BIStaTime),
                        new SqlParameter("@BIEndTime",budItems.BIEndTime),
                        new SqlParameter("@BICharger",budItems.BICharger),
                        new SqlParameter("@BIAttr",budItems .BIAttr ),
                        new SqlParameter("@BIAppReaCon",budItems.BIAppReaCon),
                        new SqlParameter("@BIExpGistExp",budItems.BIExpGistExp),
                        new SqlParameter("@BILongGoal",budItems.BILongGoal),
                        new SqlParameter("@BIYearGoal",budItems.BIYearGoal),
                        new SqlParameter("@BIMon",budItems.BIMon),
                        new SqlParameter("@BIAppConMon",budItems.BIAppConMon),
                        new SqlParameter("@BIMonSou",budItems .BIMonSou ),
                        new SqlParameter("@BIFinAllo",budItems .BIFinAllo ),
                        new SqlParameter("@BILastYearCarry",budItems.BILastYearCarry),
                        new SqlParameter("@BIOthFun",budItems.BIOthFun),
                        new SqlParameter("@BIOthExpProb",budItems.BIOthExpProb),
                        new SqlParameter("@BIBudSta",budItems.BIBudSta),
                        new SqlParameter("@BudSta",budItems.BudSta),
                        new SqlParameter("@BICause",budItems.BICause),
                        new SqlParameter("@DepID",budItems.DepID),
                        new SqlParameter("@BIProName",budItems.BIProName),
                        new SqlParameter("@BIReportTime",budItems.BIReportTime),
                        new SqlParameter("@BIConNum",budItems.BIConNum),
                        new SqlParameter("@BIProDescrip",budItems.BIProDescrip),
                        new SqlParameter("@BIProCategory",budItems.BIProCategory)
                        };
                flag = DBUnity.ExecuteNonQuery(CommandType.Text, sqlStr, Pars) > 0;
            }
            catch (Exception ex)
            {
                flag = false;
                Log.WriteLog(ex.Message, "BGBudItemsService--AddbudItems");
            }
            return flag;
        }
 public static bool ModifyBG_BudItems(BG_BudItems bG_BudItems)
 {
     return BG_BudItemsService.ModifyBG_BudItems(bG_BudItems);
 }
 public static bool DeleteBG_BudItems(BG_BudItems bG_BudItems)
 {
     return BG_BudItemsService.DeleteBG_BudItems(bG_BudItems);
 }
 public static BG_BudItems AddBG_BudItems(BG_BudItems bG_BudItems)
 {
     return BG_BudItemsService.AddBG_BudItems(bG_BudItems);
 }
        /// <summary>
        /// 添加BGBudItems并返回其ID
        /// </summary>
        /// <param name="budItems"></param>
        /// <returns>int</returns>
        public static int AddBudItemsBackbuid(BG_BudItems budItems)
        {
            int biid = 0;
            try
            {
                string sqlStr = @"insert into BG_BudItems(BIProType,BIFunSub,BICode,PPID,PIID,BIPlanHz,BIStaTime,BIEndTime,BICharger,BIAttr,BIAppReaCon,
                                 BIExpGistExp,BILongGoal,BIYearGoal,BIMon,BIAppConMon,BIMonSou,BIFinAllo,BILastYearCarry,BIOthFun,BIOthExpProb,BIBudSta,BudSta,BICause,DepID,BIProName,BIReportTime,BIConNum,BIProDescrip,BIProCategory)
                                values(@BIProType,@BIFunSub,@BICode,@PPID,@PIID,@BIPlanHz,@BIStaTime,@BIEndTime,@BICharger,@BIAttr,@BIAppReaCon,@BIExpGistExp,@BILongGoal,
                                 @BIYearGoal,@BIMon,@BIAppConMon,@BIMonSou,@BIFinAllo,@BILastYearCarry,@BIOthFun,@BIOthExpProb,@BIBudSta,@BudSta,@BICause,@DepID,@BIProName,@BIReportTime,@BIConNum,@BIProDescrip,@BIProCategory);SELECT SCOPE_IDENTITY()";

                SqlParameter[] Pars = new SqlParameter[]{
                        new SqlParameter("@BIProType",budItems.BIProType),
                        new SqlParameter("@BIFunSub",budItems.BIFunSub),
                        new SqlParameter("@BICode",budItems.BICode),
                        new SqlParameter("@PPID",budItems.PPID),
                        new SqlParameter("@PIID",budItems.PIID),
                        new SqlParameter("@BIPlanHz",budItems.BIPlanHz),
                        new SqlParameter("@BIStaTime",budItems.BIStaTime),
                        new SqlParameter("@BIEndTime",budItems.BIEndTime),
                        new SqlParameter("@BICharger",budItems.BICharger),
                        new SqlParameter("@BIAttr",budItems .BIAttr ),
                        new SqlParameter("@BIAppReaCon",budItems.BIAppReaCon),
                        new SqlParameter("@BIExpGistExp",budItems.BIExpGistExp),
                        new SqlParameter("@BILongGoal",budItems.BILongGoal),
                        new SqlParameter("@BIYearGoal",budItems.BIYearGoal),
                        new SqlParameter("@BIMon",budItems.BIMon),
                        new SqlParameter("@BIAppConMon",budItems.BIAppConMon),
                        new SqlParameter("@BIMonSou",budItems .BIMonSou ),
                        new SqlParameter("@BIFinAllo",budItems .BIFinAllo ),
                        new SqlParameter("@BILastYearCarry",budItems.BILastYearCarry),
                        new SqlParameter("@BIOthFun",budItems.BIOthFun),
                        new SqlParameter("@BIOthExpProb",budItems.BIOthExpProb),
                        new SqlParameter("@BIBudSta",budItems.BIBudSta),
                        new SqlParameter("@BudSta",budItems.BudSta),
                        new SqlParameter("@BICause",budItems.BICause),
                        new SqlParameter("@DepID",budItems.DepID),
                        new SqlParameter("@BIProName",budItems.BIProName),
                        new SqlParameter("@BIReportTime",budItems.BIReportTime),
                        new SqlParameter("@BIConNum",budItems.BIConNum),
                        new SqlParameter("@BIProDescrip",budItems.BIProDescrip),
                         new SqlParameter("@BIProCategory",budItems.BIProCategory)
                        };
                biid = common.IntSafeConvert(DBUnity.ExecuteScalar(CommandType.Text, sqlStr, Pars));
            }
            catch (Exception ex)
            {
                biid = 0;
                Log.WriteLog(ex.Message, "BGBudItemsService--AddbudItems");
            }
            return biid;
        }
 /// <summary>
 /// 修改指定预算项目信息
 /// </summary>
 /// <param name="budItems">BGBudItems</param>
 /// <returns>bool</returns>
 public static bool UpdBudItems(BG_BudItems budItems)
 {
     bool flag = false;
     try
     {
         string sqlStr = @"update BG_BudItems set BIProType=@BIProType,BIFunSub=@BIFunSub,
         BICode=@BICode,PPID=@PPID,PIID=@PIID,BIPlanHz=@BIPlanHz,BIStaTime=@BIStaTime,BIEndTime=@BIEndTime,
         BICharger=@BICharger,BIAttr=@BIAttr,BIAppReaCon=@BIAppReaCon,BIExpGistExp=@BIExpGistExp,BILongGoal=@BILongGoal,
         BIYearGoal=@BIYearGoal,BIMon=@BIMon,BIAppConMon=@BIAppConMon,BIMonSou=@BIMonSou,BIFinAllo=@BIFinAllo,
         BILastYearCarry=@BILastYearCarry,BIOthFun=@BIOthFun,BIOthExpProb=@BIOthExpProb,BIBudSta=@BIBudSta,
         BudSta=@BudSta,BICause=@BICause ,BIProName=@BIProName,BIReportTime=@BIReportTime,BIConNum=@BIConNum,BIProDescrip=@BIProDescrip,BIProCategory =@BIProCategory  where BudID = @BudID";
         SqlParameter[] Pars = new SqlParameter[]{
                new SqlParameter("@BudID",budItems.BudID),
                 new SqlParameter("@BIProType",budItems.BIProType),
                 new SqlParameter("@BIFunSub",budItems.BIFunSub),
                 new SqlParameter("@BICode",budItems.BICode),
                 new SqlParameter("@PPID",budItems.PPID),
                 new SqlParameter("@PIID",budItems.PIID),
                 new SqlParameter("@BIPlanHz",budItems.BIPlanHz),
                 new SqlParameter("@BIStaTime",budItems.BIStaTime),
                 new SqlParameter("@BIEndTime",budItems.BIEndTime),
                 new SqlParameter("@BICharger",budItems.BICharger),
                 new SqlParameter("@BIAttr",budItems .BIAttr ),
                 new SqlParameter("@BIAppReaCon",budItems.BIAppReaCon),
                 new SqlParameter("@BIExpGistExp",budItems.BIExpGistExp),
                 new SqlParameter("@BILongGoal",budItems.BILongGoal),
                 new SqlParameter("@BIYearGoal",budItems.BIYearGoal),
                 new SqlParameter("@BIMon",budItems.BIMon),
                 new SqlParameter("@BIAppConMon",budItems.BIAppConMon),
                 new SqlParameter("@BIMonSou",budItems .BIMonSou ),
                 new SqlParameter("@BIFinAllo",budItems .BIFinAllo ),
                 new SqlParameter("@BILastYearCarry",budItems.BILastYearCarry),
                 new SqlParameter("@BIOthFun",budItems.BIOthFun),
                 new SqlParameter("@BIOthExpProb",budItems.BIOthExpProb),
                 new SqlParameter("@BIBudSta",budItems.BIBudSta),
                 new SqlParameter("@BudSta",budItems.BudSta),
                 new SqlParameter("@BICause",budItems.BICause),
                 new SqlParameter("@BIProName",budItems.BIProName),
                 new SqlParameter("@BIReportTime",budItems.BIReportTime),
                 new SqlParameter("@BIConNum",budItems.BIConNum),
                 new SqlParameter("@BIProDescrip",budItems.BIProDescrip),
                  new SqlParameter("@BIProCategory",budItems.BIProCategory)
                };
         flag = DBUnity.ExecuteNonQuery(CommandType.Text, sqlStr, Pars) > 0;
     }
     catch (Exception ex)
     {
         Log.WriteLog(ex.Message, "BGBudItemsService--UpdBudItems");
     }
     return flag;
 }
 /// <summary>
 /// 根据Budid获取单条BGBudItems记录
 /// </summary>
 /// <param name="biid"></param>
 /// <returns></returns>
 public static BG_BudItems GetBudItemsByBudid(int Budid)
 {
     BG_BudItems budItems = new BG_BudItems();
     string sqlStr = "select * from BG_BudItems where BudID=@BudID";
     SqlParameter[] Pars = new SqlParameter[]{
            new SqlParameter("@BudID",Budid)};
     try
     {
         SqlDataReader dr = DBUnity.ExecuteReader(CommandType.Text, sqlStr, Pars);
         while (dr.Read())
         {
             budItems.BudID = common.IntSafeConvert(dr["BudID"]);
             budItems.BIProType = dr["BIProType"].ToString();
             budItems.BIFunSub = dr["BIFunSub"].ToString();
             budItems.BICode = dr["BICode"].ToString();
             budItems.PPID = common.IntSafeConvert(dr["PPID"]);
             budItems.PIID = common.IntSafeConvert(dr["PIID"]);
             budItems.BIPlanHz = dr["BIPlanHz"].ToString();
             budItems.BIStaTime = ParseUtil.ToDateTime(dr["BIStaTime"].ToString(), DateTime.Now);
             budItems.BIEndTime = ParseUtil.ToDateTime(dr["BIEndTime"].ToString(), DateTime.Now);
             budItems.BICharger = dr["BICharger"].ToString();
             budItems.BIAttr = dr["BIAttr"].ToString();
             budItems.BIAppReaCon = dr["BIAppReaCon"].ToString();
             budItems.BIExpGistExp = dr["BIExpGistExp"].ToString();
             budItems.BILongGoal = dr["BILongGoal"].ToString();
             budItems.BIYearGoal = dr["BIYearGoal"].ToString();
             budItems.BIMon = ParseUtil.ToDecimal(dr["BIMon"].ToString(),0);
             budItems.BIAppConMon = ParseUtil.ToDecimal(dr["BIAppConMon"].ToString(),0);
             budItems.BIMonSou = dr["BIMonSou"].ToString();
             budItems.BIFinAllo = ParseUtil.ToDecimal(dr["BIFinAllo"].ToString(),0);
             budItems.BILastYearCarry = ParseUtil.ToDecimal(dr["BILastYearCarry"].ToString(),0);
             budItems.BIOthFun = ParseUtil.ToDecimal(dr["BIOthFun"].ToString(),0);
             budItems.BIOthExpProb = dr["BIOthExpProb"].ToString();
             budItems.BIBudSta = dr["BIBudSta"].ToString();
             budItems.BudSta = dr["BudSta"].ToString();
             budItems.BICause = dr["BICause"].ToString();
             budItems.DepID =common.IntSafeConvert(dr["DepID"]);
             budItems.BIProName = dr["BIProName"].ToString();
             budItems.BIReportTime = ParseUtil.ToDateTime(dr["BIReportTime"].ToString(),DateTime.Now);
             budItems.BIConNum = ParseUtil.ToDecimal(dr["BIConNum"].ToString(),0);
             budItems.BIProDescrip = dr["BIProDescrip"].ToString();
             budItems.BIProCategory = dr["BIProCategory"].ToString();
         }
         dr.Close();
     }
     catch (Exception ex)
     {
         budItems = null;
         Log.WriteLog(ex.Message, "BGBudItemsService--GetBudItemsByBiid");
     }
     return budItems;
 }
 /// <summary>
 /// 添加BGBudItems并返回其ID
 /// </summary>
 /// <param name="budItems"></param>
 /// <returns>int</returns>
 public static int AddBudItemsBackbuid(BG_BudItems budItems)
 {
     return BGBudItemsService.AddBudItemsBackbuid(budItems);
 }
 /// <summary>
 /// 添加一条预算项目信息
 /// </summary>
 /// <param name="budItems">一条预算项目实例</param>
 /// <returns>bool</returns>
 public static bool AddbudItems(BG_BudItems budItems)
 {
     return BGBudItemsService.AddbudItems(budItems);
 }
 /// <summary>
 /// 修改指定预算项目信息
 /// </summary>
 /// <param name="budItems">BGBudItems</param>
 /// <returns>bool</returns>
 public static bool UpdBudItems(BG_BudItems budItems)
 {
     return BGBudItemsService.UpdBudItems(budItems);
 }
 public static bool DeleteBG_BudItems(BG_BudItems bG_BudItems)
 {
     return DeleteBG_BudItemsByBudID( bG_BudItems.BudID );
 }
        public static bool ModifyBG_BudItems(BG_BudItems bG_BudItems)
        {
            string sql =
                "UPDATE BG_BudItems " +
                "SET " +
                    "BIProType = @BIProType, " +
                    "BIFunSub = @BIFunSub, " +
                    "BICode = @BICode, " +
                    "PPID = @PPID, " +
                    "PIID = @PIID, " +
                    "BIPlanHz = @BIPlanHz, " +
                    "BIStaTime = @BIStaTime, " +
                    "BIEndTime = @BIEndTime, " +
                    "BICharger = @BICharger, " +
                    "BIAttr = @BIAttr, " +
                    "BIAppReaCon = @BIAppReaCon, " +
                    "BIExpGistExp = @BIExpGistExp, " +
                    "BILongGoal = @BILongGoal, " +
                    "BIYearGoal = @BIYearGoal, " +
                    "BIMon = @BIMon, " +
                    "BIAppConMon = @BIAppConMon, " +
                    "BIMonSou = @BIMonSou, " +
                    "BIFinAllo = @BIFinAllo, " +
                    "BILastYearCarry = @BILastYearCarry, " +
                    "BIOthFun = @BIOthFun, " +
                    "BIOthExpProb = @BIOthExpProb, " +
                    "BIBudSta = @BIBudSta, " +
                    "BudSta = @BudSta, " +
                    "BICause = @BICause, " +
                    "DepID = @DepID, " +
                    "BIProName = @BIProName, " +
                    "BIReportTime = @BIReportTime, " +
                    "BIConNum = @BIConNum, " +
                    "BIProDescrip = @BIProDescrip, " +
                    "BIProCategory = @BIProCategory, " +
                    "BIYear = @BIYear " +
                "WHERE BudID = @BudID";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@BudID", bG_BudItems.BudID),
                    new SqlParameter("@BIProType", bG_BudItems.BIProType),
                    new SqlParameter("@BIFunSub", bG_BudItems.BIFunSub),
                    new SqlParameter("@BICode", bG_BudItems.BICode),
                    new SqlParameter("@PPID", bG_BudItems.PPID),
                    new SqlParameter("@PIID", bG_BudItems.PIID),
                    new SqlParameter("@BIPlanHz", bG_BudItems.BIPlanHz),
                    new SqlParameter("@BIStaTime", bG_BudItems.BIStaTime),
                    new SqlParameter("@BIEndTime", bG_BudItems.BIEndTime),
                    new SqlParameter("@BICharger", bG_BudItems.BICharger),
                    new SqlParameter("@BIAttr", bG_BudItems.BIAttr),
                    new SqlParameter("@BIAppReaCon", bG_BudItems.BIAppReaCon),
                    new SqlParameter("@BIExpGistExp", bG_BudItems.BIExpGistExp),
                    new SqlParameter("@BILongGoal", bG_BudItems.BILongGoal),
                    new SqlParameter("@BIYearGoal", bG_BudItems.BIYearGoal),
                    new SqlParameter("@BIMon", bG_BudItems.BIMon),
                    new SqlParameter("@BIAppConMon", bG_BudItems.BIAppConMon),
                    new SqlParameter("@BIMonSou", bG_BudItems.BIMonSou),
                    new SqlParameter("@BIFinAllo", bG_BudItems.BIFinAllo),
                    new SqlParameter("@BILastYearCarry", bG_BudItems.BILastYearCarry),
                    new SqlParameter("@BIOthFun", bG_BudItems.BIOthFun),
                    new SqlParameter("@BIOthExpProb", bG_BudItems.BIOthExpProb),
                    new SqlParameter("@BIBudSta", bG_BudItems.BIBudSta),
                    new SqlParameter("@BudSta", bG_BudItems.BudSta),
                    new SqlParameter("@BICause", bG_BudItems.BICause),
                    new SqlParameter("@DepID", bG_BudItems.DepID),
                    new SqlParameter("@BIProName", bG_BudItems.BIProName),
                    new SqlParameter("@BIReportTime", bG_BudItems.BIReportTime),
                    new SqlParameter("@BIConNum", bG_BudItems.BIConNum),
                    new SqlParameter("@BIProDescrip", bG_BudItems.BIProDescrip),
                    new SqlParameter("@BIProCategory", bG_BudItems.BIProCategory),
                    new SqlParameter("@BIYear", bG_BudItems.BIYear)
                };

                int t = DBUnity.ExecuteNonQuery(CommandType.Text, sql, para);
                if(t>0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
        public static BG_BudItems GetBG_BudItemsByBudID(int budID)
        {
            string sql = "SELECT * FROM BG_BudItems WHERE BudID = @BudID";

            try
            {
                SqlParameter para = new SqlParameter("@BudID", budID);
                DataTable dt = DBUnity.AdapterToTab(sql, para);

                if(dt.Rows.Count > 0)
                {
                    BG_BudItems bG_BudItems = new BG_BudItems();

                    bG_BudItems.BudID = dt.Rows[0]["BudID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["BudID"];
                    bG_BudItems.BIProType = dt.Rows[0]["BIProType"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIProType"];
                    bG_BudItems.BIFunSub = dt.Rows[0]["BIFunSub"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIFunSub"];
                    bG_BudItems.BICode = dt.Rows[0]["BICode"] == DBNull.Value ? "" : (string)dt.Rows[0]["BICode"];
                    bG_BudItems.PPID = dt.Rows[0]["PPID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["PPID"];
                    bG_BudItems.PIID = dt.Rows[0]["PIID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["PIID"];
                    bG_BudItems.BIPlanHz = dt.Rows[0]["BIPlanHz"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIPlanHz"];
                    bG_BudItems.BIStaTime = dt.Rows[0]["BIStaTime"] == DBNull.Value ? DateTime.MinValue : (DateTime)dt.Rows[0]["BIStaTime"];
                    bG_BudItems.BIEndTime = dt.Rows[0]["BIEndTime"] == DBNull.Value ? DateTime.MinValue : (DateTime)dt.Rows[0]["BIEndTime"];
                    bG_BudItems.BICharger = dt.Rows[0]["BICharger"] == DBNull.Value ? "" : (string)dt.Rows[0]["BICharger"];
                    bG_BudItems.BIAttr = dt.Rows[0]["BIAttr"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIAttr"];
                    bG_BudItems.BIAppReaCon = dt.Rows[0]["BIAppReaCon"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIAppReaCon"];
                    bG_BudItems.BIExpGistExp = dt.Rows[0]["BIExpGistExp"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIExpGistExp"];
                    bG_BudItems.BILongGoal = dt.Rows[0]["BILongGoal"] == DBNull.Value ? "" : (string)dt.Rows[0]["BILongGoal"];
                    bG_BudItems.BIYearGoal = dt.Rows[0]["BIYearGoal"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIYearGoal"];
                    bG_BudItems.BIMon = dt.Rows[0]["BIMon"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["BIMon"];
                    bG_BudItems.BIAppConMon = dt.Rows[0]["BIAppConMon"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["BIAppConMon"];
                    bG_BudItems.BIMonSou = dt.Rows[0]["BIMonSou"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIMonSou"];
                    bG_BudItems.BIFinAllo = dt.Rows[0]["BIFinAllo"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["BIFinAllo"];
                    bG_BudItems.BILastYearCarry = dt.Rows[0]["BILastYearCarry"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["BILastYearCarry"];
                    bG_BudItems.BIOthFun = dt.Rows[0]["BIOthFun"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["BIOthFun"];
                    bG_BudItems.BIOthExpProb = dt.Rows[0]["BIOthExpProb"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIOthExpProb"];
                    bG_BudItems.BIBudSta = dt.Rows[0]["BIBudSta"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIBudSta"];
                    bG_BudItems.BudSta = dt.Rows[0]["BudSta"] == DBNull.Value ? "" : (string)dt.Rows[0]["BudSta"];
                    bG_BudItems.BICause = dt.Rows[0]["BICause"] == DBNull.Value ? "" : (string)dt.Rows[0]["BICause"];
                    bG_BudItems.DepID = dt.Rows[0]["DepID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["DepID"];
                    bG_BudItems.BIProName = dt.Rows[0]["BIProName"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIProName"];
                    bG_BudItems.BIReportTime = dt.Rows[0]["BIReportTime"] == DBNull.Value ? DateTime.MinValue : (DateTime)dt.Rows[0]["BIReportTime"];
                    bG_BudItems.BIConNum = dt.Rows[0]["BIConNum"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["BIConNum"];
                    bG_BudItems.BIProDescrip = dt.Rows[0]["BIProDescrip"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIProDescrip"];
                    bG_BudItems.BIProCategory = dt.Rows[0]["BIProCategory"] == DBNull.Value ? "" : (string)dt.Rows[0]["BIProCategory"];
                    bG_BudItems.BIYear = dt.Rows[0]["BIYear"] == DBNull.Value ? 0 : (int)dt.Rows[0]["BIYear"];

                    return bG_BudItems;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
 /// <summary>
 /// 添加一条预算项目历史实例
 /// </summary>
 /// <param name="budItems"></param>
 /// <returns></returns>
 public static bool InsertBudItemHis(BG_BudItems budItems)
 {
     return BGBudItemHisService.InsertBudItemHis(budItems);
 }
    protected void btnSure_Click(object sender, EventArgs e)
    {
        BG_BudItems bi = new BG_BudItems();
        bi.BIAppConMon = 0;// decimal.Parse(txtBudConNumber.Text.Trim());审批控制金额,应该是预算控制数
        bi.BIAppReaCon = txtBIAppReaCon.Text.Trim();
        bi.BIAttr = ddlProProper.SelectedValue;
        bi.BIBudSta = "等下对接"; //Session[Constant.UserName].ToString();
        bi.BICause = "";//退回原因
        bi.BICharger = txtBICharger.Text.Trim();
        bi.BICode = txtItemNumber.Text.Trim(); //项目编号
        bi.BIEndTime = DateTime.Parse(txtBIEndTime.Text.Trim());
        bi.BIExpGistExp = txtBIExpGistExp.Text.Trim();
        bi.BIFinAllo = 0;// decimal.Parse(txtBudConNumber.Text.Trim());财政拨款
        bi.BIFunSub = ddlFunSub.Text.Trim();
        bi.BILastYearCarry = 0;// decimal.Parse(txtBudConNumber.Text.Trim());上年结账
        bi.BILongGoal = txtBILongGoal.Text.Trim();
        bi.BIMon = common.IntSafeConvert(HidMonTotal.Value);      //GetBIMon(coll.GetValues("txt4"));
        bi.BIMonSou = "";//资金来源
        bi.BIOthExpProb = txtBIOthExpProb.Text.Trim();
        bi.BIOthFun = 0;// decimal.Parse(txtBudConNumber.Text.Trim());其他资金
        bi.BIPlanHz = ddlBIPlanHz.SelectedValue; //项目频度
        bi.BIProType = ddlPayProType.SelectedItem.Text;
        bi.BIStaTime = DateTime.Parse(txtBIStaTime.Text.Trim());
        bi.BIYearGoal = txtBIYearGoal.Text.Trim();
        bi.PPID = common.IntSafeConvert(ddlPayProType.SelectedValue);//
        bi.BudSta = "未提交";//
        bi.PIID = BG_PayProjectManager.GetBG_PayProjectByPPID(bi.PPID).PIID; //common.IntSafeConvert(ddlFunSub.SelectedValue);//yj
        bi.BIProName = txtProName.Text.Trim();
        bi.BIReportTime = ParseUtil.ToDateTime(txtBITime.Text.Trim(), DateTime.Now);
        bi.BIConNum = 0;//预算控制数
        bi.BIProDescrip = txtProDesc.Text.Trim();
        bi.DepID = common.IntSafeConvert(HidDepid.Value);
        bi.BIProCategory = ddlProType.SelectedItem.Text;
        bi.BIYear = common.IntSafeConvert(txtyear.Text);
        int buid = BG_BudItemsManager.AddBG_BudItems(bi).BudID;//yj
        if (buid > 0)
        {

            BG_BudItemHis hisbi = new BG_BudItemHis();
            hisbi.BudID = buid;
            hisbi.BIAppConMon = 0;// decimal.Parse(txtBudConNumber.Text.Trim());审批控制金额,应该是预算控制数
            hisbi.BIAppReaCon = txtBIAppReaCon.Text.Trim();
            hisbi.BIAttr = ddlProProper.SelectedValue;
            hisbi.BIBudSta = "等下对接"; //Session[Constant.UserName].ToString();
            hisbi.BICause = "";//退回原因
            hisbi.BICharger = txtBICharger.Text.Trim();
            hisbi.BICode = txtItemNumber.Text.Trim(); //项目编号
            hisbi.BIEndTime = DateTime.Parse(txtBIEndTime.Text.Trim());
            hisbi.BIExpGistExp = txtBIExpGistExp.Text.Trim();
            hisbi.BIFinAllo = 0;// decimal.Parse(txtBudConNumber.Text.Trim());财政拨款
            hisbi.BIFunSub = ddlFunSub.Text.Trim();
            hisbi.BILastYearCarry = 0;// decimal.Parse(txtBudConNumber.Text.Trim());上年结账
            hisbi.BILongGoal = txtBILongGoal.Text.Trim();
            hisbi.BIMon = common.IntSafeConvert(HidMonTotal.Value);      //GetBIMon(coll.GetValues("txt4"));
            hisbi.BIMonSou = "";//资金来源
            hisbi.BIOthExpProb = txtBIOthExpProb.Text.Trim();
            hisbi.BIOthFun = 0;// decimal.Parse(txtBudConNumber.Text.Trim());其他资金
            hisbi.BIPlanHz = ddlBIPlanHz.SelectedValue; //项目频度
            hisbi.BIProType = ddlPayProType.SelectedItem.Text;
            hisbi.BIStaTime = DateTime.Parse(txtBIStaTime.Text.Trim());
            hisbi.BIYearGoal = txtBIYearGoal.Text.Trim();
            hisbi.PPID = common.IntSafeConvert(ddlPayProType.SelectedValue);//
            hisbi.BudSta = "未提交";//
            hisbi.PIID = BG_PayProjectManager.GetBG_PayProjectByPPID(bi.PPID).PIID; //common.IntSafeConvert(ddlFunSub.SelectedValue);//yj
            hisbi.BIProName = txtProName.Text.Trim();
            hisbi.BIReportTime = ParseUtil.ToDateTime(txtBITime.Text.Trim(), DateTime.Now);
            hisbi.BIConNum = 0;//预算控制数
            hisbi.BIProDescrip = txtProDesc.Text.Trim();
            hisbi.DepID = common.IntSafeConvert(HidDepid.Value);
            hisbi.BIProCategory = ddlProType.SelectedItem.Text;
            hisbi.BIYear = common.IntSafeConvert(txtyear.Text);
            int flaid= BG_BudItemHisManager.AddBG_BudItemHis(hisbi).BudHisID;

            NameValueCollection coll = Request.Form;
            string[] txt1 = coll.GetValues("txt1"); //行号
            string[] txt2 = coll.GetValues("txt2"); //当前年度
            string[] txt3 = coll.GetValues("ddlIncome"); //经济科目
            string[] txt4 = coll.GetValues("txt4"); //总计
            string[] txt5 = coll.GetValues("txt5"); //小计(财政拨款)
            string[] txt6 = coll.GetValues("txt6"); //小计(经费)
            string[] txt7 = coll.GetValues("txt7"); //内部开支(经费)
            string[] txt8 = coll.GetValues("txt8"); //外部拨款(经费)
            int rowCount = common.IntSafeConvert(HidRowCount.Value);
            bool flag = false;
            if (rowCount > 0 && flaid>0)
            {
                for (int j = 0; j < rowCount; j++)
                {
                    BG_BudCostPro bcp = new BG_BudCostPro();
                    bcp.BudID = buid;
                    bcp.BCPCurrYear = common.IntSafeConvert(txt2[j]);
                    bcp.BCPRemark = "";
                    DataTable dtpiid = BG_PayIncomeLogic.GetBG_PayIncomeByname(txt3[j]);
                    int piid = common.IntSafeConvert(dtpiid.Rows[0]["PIID"]);
                    bcp.PIID = piid;
                    bcp.BCPTotal = ParseUtil.ToDecimal(txt4[j], 0);
                    bcp.BCPSubtFinAllo = ParseUtil.ToDecimal(txt5[j], 0);
                    bcp.BCPSubtExp = ParseUtil.ToDecimal(txt6[j], 0);
                    bcp.BCInExpenses = ParseUtil.ToDecimal(txt7[j], 0);
                    bcp.BCOutFunding = ParseUtil.ToDecimal(txt8[j], 0);
                    flag = BGBudCostProManager.AddBGBudCostPro(bcp);//yj
                }
            }
            if (flag)
            {
                lblShowResult.Text = "添加成功";
                //BGBudItemHisManage.InsertBudItemHis(bi);
                string PostUrl = "BudgetEditList.aspx?depid=" + HidDepid.Value;
                string PostUrl1 = "BudgetEditAddPage.aspx?depid=" + HidDepid.Value;
                Response.Write("<script language='javascript'>if(confirm('是否继续添加?')){window.location.href='" + PostUrl1 + "';}else{window.location.href='" + PostUrl + "';}</script>");
            }
            else
            {
                lblShowResult.Text = "操作失败、请检查数据后重试";
            }
        }
        else
        {
            lblShowResult.Text = "操作失败、请检查数据后重试";
        }
    }