public static BG_BudItemHis AddBG_BudItemHis(BG_BudItemHis bG_BudItemHis)
        {
            string sql =
                "INSERT BG_BudItemHis (BudID, 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 (@BudID, @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("@BudID", bG_BudItemHis.BudID),
                    new SqlParameter("@BIProType", bG_BudItemHis.BIProType),
                    new SqlParameter("@BIFunSub", bG_BudItemHis.BIFunSub),
                    new SqlParameter("@BICode", bG_BudItemHis.BICode),
                    new SqlParameter("@PPID", bG_BudItemHis.PPID),
                    new SqlParameter("@PIID", bG_BudItemHis.PIID),
                    new SqlParameter("@BIPlanHz", bG_BudItemHis.BIPlanHz),
                    new SqlParameter("@BIStaTime", bG_BudItemHis.BIStaTime),
                    new SqlParameter("@BIEndTime", bG_BudItemHis.BIEndTime),
                    new SqlParameter("@BICharger", bG_BudItemHis.BICharger),
                    new SqlParameter("@BIAttr", bG_BudItemHis.BIAttr),
                    new SqlParameter("@BIAppReaCon", bG_BudItemHis.BIAppReaCon),
                    new SqlParameter("@BIExpGistExp", bG_BudItemHis.BIExpGistExp),
                    new SqlParameter("@BILongGoal", bG_BudItemHis.BILongGoal),
                    new SqlParameter("@BIYearGoal", bG_BudItemHis.BIYearGoal),
                    new SqlParameter("@BIMon", bG_BudItemHis.BIMon),
                    new SqlParameter("@BIAppConMon", bG_BudItemHis.BIAppConMon),
                    new SqlParameter("@BIMonSou", bG_BudItemHis.BIMonSou),
                    new SqlParameter("@BIFinAllo", bG_BudItemHis.BIFinAllo),
                    new SqlParameter("@BILastYearCarry", bG_BudItemHis.BILastYearCarry),
                    new SqlParameter("@BIOthFun", bG_BudItemHis.BIOthFun),
                    new SqlParameter("@BIOthExpProb", bG_BudItemHis.BIOthExpProb),
                    new SqlParameter("@BIBudSta", bG_BudItemHis.BIBudSta),
                    new SqlParameter("@BudSta", bG_BudItemHis.BudSta),
                    new SqlParameter("@BICause", bG_BudItemHis.BICause),
                    new SqlParameter("@DepID", bG_BudItemHis.DepID),
                    new SqlParameter("@BIProName", bG_BudItemHis.BIProName),
                    new SqlParameter("@BIReportTime", bG_BudItemHis.BIReportTime),
                    new SqlParameter("@BIConNum", bG_BudItemHis.BIConNum),
                    new SqlParameter("@BIProDescrip", bG_BudItemHis.BIProDescrip),
                    new SqlParameter("@BIProCategory", bG_BudItemHis.BIProCategory),
                    new SqlParameter("@BIYear", bG_BudItemHis.BIYear)
                };

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

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
 protected void btnElimin_Click(object sender, EventArgs e)
 {
     string message = "被淘汰的项目不可以恢复,是否淘汰?";
     Response.Write("<script language=javascript>alert(\"" + message.Trim() + "\");window.top.close();</script>");
     BG_BudItems bi = BGBudItemsManager.GetBudItemsByBudid(budid);
     bi.BudSta = "淘汰";
     bi.BIConNum = ParseUtil.ToDecimal(txtBudConNumber.Text.Trim(), 0);
     bi.BICause = txtBackReason.Text.Trim();
     if (BGBudItemsManager.UpdBudItems(bi))
     {
         BG_BudItemHis hisbi = new BG_BudItemHis();
         hisbi.BudID = budid;
         hisbi.BIAppConMon = bi.BIAppConMon;
         hisbi.BIAppReaCon = bi.BIAppReaCon;
         hisbi.BIAttr = bi.BIAttr;
         hisbi.BIBudSta = bi.BIBudSta;
         hisbi.BICause = bi.BICause;
         hisbi.BICharger = bi.BICharger;
         hisbi.BICode = bi.BICode;
         hisbi.BIEndTime = bi.BIEndTime;
         hisbi.BIExpGistExp = bi.BIExpGistExp;
         hisbi.BIFinAllo = bi.BIFinAllo;
         hisbi.BIFunSub = bi.BIFunSub;
         hisbi.BILastYearCarry = bi.BILastYearCarry;
         hisbi.BILongGoal = bi.BILongGoal;
         hisbi.BIMon = bi.BIMon;
         hisbi.BIMonSou = bi.BIMonSou;
         hisbi.BIOthExpProb = bi.BIOthExpProb;
         hisbi.BIOthFun = bi.BIOthFun;
         hisbi.BIPlanHz = bi.BIPlanHz;
         hisbi.BIProType = bi.BIProType;
         hisbi.BIStaTime = bi.BIStaTime;
         hisbi.BIYearGoal = bi.BIYearGoal;
         hisbi.PPID = bi.PPID;
         hisbi.BudSta = bi.BudSta;
         hisbi.PIID = bi.PIID;
         hisbi.BIProName = bi.BIProName;
         hisbi.BIReportTime = bi.BIReportTime;
         hisbi.BIConNum = bi.BIConNum;
         hisbi.BIProDescrip = bi.BIProDescrip;
         hisbi.DepID = bi.DepID;
         hisbi.BIProCategory = bi.BIProCategory;
         BG_BudItemHisManager.AddBG_BudItemHis(hisbi);
         btnAppo.ForeColor = Color.Gray;
         btnAppo.Enabled = false;
         btnReturn.ForeColor = Color.Gray;
         btnReturn.Enabled = false;
         lblShowResult.Text = "项目已淘汰";
     }
     else
     {
         lblShowResult.Text = "操作失败、请重试";
     }
 }
    protected void btnReturn_Click(object sender, EventArgs e)
    {
        BG_BudItems bi = BGBudItemsManager.GetBudItemsByBudid(budid);
        bi.BudSta = "退回";
        bi.BICause = txtBackReason.Text.Trim();

        BG_BudItemHis hisbi = new BG_BudItemHis();
        hisbi.BudID =budid ;
        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 = txtBackReason.Text.Trim();//退回原因
        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(txtBIMon.Text);      //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;
        int flaid = BG_BudItemHisManager.AddBG_BudItemHis(hisbi).BudHisID;
        if (BGBudItemsManager.UpdBudItems(bi)&&flaid>0)
        {

            //BGBudItemHisManage.InsertBudItemHis(bi);
            btnExam.ForeColor = Color.Gray;
            btnExam.Enabled = false;
            lblShowResult.Text = "项目已退回";
        }
        else
        {
            lblShowResult.Text = "操作失败、请重试";
        }
    }
 protected void btnAppo_Click(object sender, EventArgs e)
 {
     bool flag = BGBudItemsManager.UpdBudSta(budid, "审核通过");
     if (flag)
     {
         BG_BudItems bi = BGBudItemsManager.GetBudItemsByBudid(budid);
         BG_BudItemHis hisbi = new BG_BudItemHis();
         hisbi.BudID = budid;
         hisbi.BIAppConMon = bi.BIAppConMon;
         hisbi.BIAppReaCon = bi.BIAppReaCon;
         hisbi.BIAttr = bi.BIAttr;
         hisbi.BIBudSta = bi.BIBudSta;
         hisbi.BICause = bi.BICause;
         hisbi.BICharger = bi.BICharger;
         hisbi.BICode = bi.BICode;
         hisbi.BIEndTime = bi.BIEndTime;
         hisbi.BIExpGistExp = bi.BIExpGistExp;
         hisbi.BIFinAllo = bi.BIFinAllo;
         hisbi.BIFunSub = bi.BIFunSub;
         hisbi.BILastYearCarry = bi.BILastYearCarry;
         hisbi.BILongGoal = bi.BILongGoal;
         hisbi.BIMon = bi.BIMon;
         hisbi.BIConNum = ParseUtil.ToDecimal(txtBudConNumber.Text, 0);
         hisbi.BIMonSou = bi.BIMonSou;
         hisbi.BIOthExpProb = bi.BIOthExpProb;
         hisbi.BIOthFun = bi.BIOthFun;
         hisbi.BIPlanHz = bi.BIPlanHz;
         hisbi.BIProType = bi.BIProType;
         hisbi.BIStaTime = bi.BIStaTime;
         hisbi.BIYearGoal = bi.BIYearGoal;
         hisbi.PPID = bi.PPID;
         hisbi.BudSta = bi.BudSta;
         hisbi.PIID = bi.PIID;
         hisbi.BIProName = bi.BIProName;
         hisbi.BIReportTime = bi.BIReportTime;
         hisbi.BIProDescrip = bi.BIProDescrip;
         hisbi.DepID = bi.DepID;
         hisbi.BIProCategory = bi.BIProCategory;
         BG_BudItemHisManager.AddBG_BudItemHis(hisbi);
         btnElimin.ForeColor = Color.Gray;
         btnElimin.Enabled = false;
         btnReturn.ForeColor = Color.Gray;
         btnReturn.Enabled = false;
         lblShowResult.Text = "项目上报成功";
     }
     else
     {
         lblShowResult.Text = "操作失败、请重试";
     }
 }
 public void Report_Handler(int budId)
 {
     if (BGBudItemsManager.UpdBudSta(budId, "已上报"))
     {
         Bind();
         BG_BudItems bi = BGBudItemsManager.GetBudItemsByBudid(budId);
         BG_BudItemHis hisbi = new BG_BudItemHis();
         hisbi.BudID = budId ;
         hisbi.BIAppConMon = bi.BIAppConMon;
         hisbi.BIAppReaCon = bi.BIAppReaCon;
         hisbi.BIAttr = bi.BIAttr;
         hisbi.BIBudSta = bi.BIBudSta;
         hisbi.BICause = bi.BICause;
         hisbi.BICharger = bi.BICharger;
         hisbi.BICode = bi.BICode;
         hisbi.BIEndTime = bi.BIEndTime;
         hisbi.BIExpGistExp = bi.BIExpGistExp;
         hisbi.BIFinAllo = bi.BIFinAllo;
         hisbi.BIFunSub = bi.BIFunSub;
         hisbi.BILastYearCarry = bi.BILastYearCarry;
         hisbi.BILongGoal = bi.BILongGoal;
         hisbi.BIMon = bi.BIMon;
         hisbi.BIMonSou = bi.BIMonSou;
         hisbi.BIOthExpProb = bi.BIOthExpProb;
         hisbi.BIOthFun = bi.BIOthFun;
         hisbi.BIPlanHz = bi.BIPlanHz;
         hisbi.BIProType = bi.BIProType;
         hisbi.BIStaTime = bi.BIStaTime;
         hisbi.BIYearGoal = bi.BIYearGoal;
         hisbi.PPID = bi.PPID;
         hisbi.BudSta = bi.BudSta;
         hisbi.PIID = bi.PIID;
         hisbi.BIProName = bi.BIProName;
         hisbi.BIReportTime = bi.BIReportTime;
         hisbi.BIConNum = bi.BIConNum;
         hisbi.BIProDescrip = bi.BIProDescrip;
         hisbi.DepID = bi.DepID;
         hisbi.BIProCategory = bi.BIProCategory;
         BG_BudItemHisManager.AddBG_BudItemHis(hisbi);
     }
 }
 public static bool ModifyBG_BudItemHis(BG_BudItemHis bG_BudItemHis)
 {
     return BG_BudItemHisService.ModifyBG_BudItemHis(bG_BudItemHis);
 }
 public static bool DeleteBG_BudItemHis(BG_BudItemHis bG_BudItemHis)
 {
     return BG_BudItemHisService.DeleteBG_BudItemHis(bG_BudItemHis);
 }
 public static BG_BudItemHis AddBG_BudItemHis(BG_BudItemHis bG_BudItemHis)
 {
     return BG_BudItemHisService.AddBG_BudItemHis(bG_BudItemHis);
 }
    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 = "操作失败、请检查数据后重试";
        }
    }
 public static bool DeleteBG_BudItemHis(BG_BudItemHis bG_BudItemHis)
 {
     return DeleteBG_BudItemHisByBudHisID( bG_BudItemHis.BudHisID );
 }
        public static bool ModifyBG_BudItemHis(BG_BudItemHis bG_BudItemHis)
        {
            string sql =
                "UPDATE BG_BudItemHis " +
                "SET " +
                    "BudID = @BudID, " +
                    "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 BudHisID = @BudHisID";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@BudHisID", bG_BudItemHis.BudHisID),
                    new SqlParameter("@BudID", bG_BudItemHis.BudID),
                    new SqlParameter("@BIProType", bG_BudItemHis.BIProType),
                    new SqlParameter("@BIFunSub", bG_BudItemHis.BIFunSub),
                    new SqlParameter("@BICode", bG_BudItemHis.BICode),
                    new SqlParameter("@PPID", bG_BudItemHis.PPID),
                    new SqlParameter("@PIID", bG_BudItemHis.PIID),
                    new SqlParameter("@BIPlanHz", bG_BudItemHis.BIPlanHz),
                    new SqlParameter("@BIStaTime", bG_BudItemHis.BIStaTime),
                    new SqlParameter("@BIEndTime", bG_BudItemHis.BIEndTime),
                    new SqlParameter("@BICharger", bG_BudItemHis.BICharger),
                    new SqlParameter("@BIAttr", bG_BudItemHis.BIAttr),
                    new SqlParameter("@BIAppReaCon", bG_BudItemHis.BIAppReaCon),
                    new SqlParameter("@BIExpGistExp", bG_BudItemHis.BIExpGistExp),
                    new SqlParameter("@BILongGoal", bG_BudItemHis.BILongGoal),
                    new SqlParameter("@BIYearGoal", bG_BudItemHis.BIYearGoal),
                    new SqlParameter("@BIMon", bG_BudItemHis.BIMon),
                    new SqlParameter("@BIAppConMon", bG_BudItemHis.BIAppConMon),
                    new SqlParameter("@BIMonSou", bG_BudItemHis.BIMonSou),
                    new SqlParameter("@BIFinAllo", bG_BudItemHis.BIFinAllo),
                    new SqlParameter("@BILastYearCarry", bG_BudItemHis.BILastYearCarry),
                    new SqlParameter("@BIOthFun", bG_BudItemHis.BIOthFun),
                    new SqlParameter("@BIOthExpProb", bG_BudItemHis.BIOthExpProb),
                    new SqlParameter("@BIBudSta", bG_BudItemHis.BIBudSta),
                    new SqlParameter("@BudSta", bG_BudItemHis.BudSta),
                    new SqlParameter("@BICause", bG_BudItemHis.BICause),
                    new SqlParameter("@DepID", bG_BudItemHis.DepID),
                    new SqlParameter("@BIProName", bG_BudItemHis.BIProName),
                    new SqlParameter("@BIReportTime", bG_BudItemHis.BIReportTime),
                    new SqlParameter("@BIConNum", bG_BudItemHis.BIConNum),
                    new SqlParameter("@BIProDescrip", bG_BudItemHis.BIProDescrip),
                    new SqlParameter("@BIProCategory", bG_BudItemHis.BIProCategory),
                    new SqlParameter("@BIYear", bG_BudItemHis.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_BudItemHis GetBG_BudItemHisByBudHisID(int budHisID)
        {
            string sql = "SELECT * FROM BG_BudItemHis WHERE BudHisID = @BudHisID";

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

                if(dt.Rows.Count > 0)
                {
                    BG_BudItemHis bG_BudItemHis = new BG_BudItemHis();

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

                    return bG_BudItemHis;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }