public static BG_ProBasiPubPay AddBG_ProBasiPubPay(BG_ProBasiPubPay bG_ProBasiPubPay)
        {
            string sql =
                "INSERT BG_ProBasiPubPay (DepID, PBYear, PBOE, PBUtilities, PBPF, OBCFE, PBTravelE, PBRE, PBME, PBTrainE, OBRE, PBAE, LUMD, PBWE, PBOCE, OOPE, OCASE, PBIDTitol)" +
                "VALUES (@DepID, @PBYear, @PBOE, @PBUtilities, @PBPF, @OBCFE, @PBTravelE, @PBRE, @PBME, @PBTrainE, @OBRE, @PBAE, @LUMD, @PBWE, @PBOCE, @OOPE, @OCASE, @PBIDTitol)";

            sql += " ; SELECT @@IDENTITY";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@DepID", bG_ProBasiPubPay.DepID),
                    new SqlParameter("@PBYear", bG_ProBasiPubPay.PBYear),
                    new SqlParameter("@PBOE", bG_ProBasiPubPay.PBOE),
                    new SqlParameter("@PBUtilities", bG_ProBasiPubPay.PBUtilities),
                    new SqlParameter("@PBPF", bG_ProBasiPubPay.PBPF),
                    new SqlParameter("@OBCFE", bG_ProBasiPubPay.OBCFE),
                    new SqlParameter("@PBTravelE", bG_ProBasiPubPay.PBTravelE),
                    new SqlParameter("@PBRE", bG_ProBasiPubPay.PBRE),
                    new SqlParameter("@PBME", bG_ProBasiPubPay.PBME),
                    new SqlParameter("@PBTrainE", bG_ProBasiPubPay.PBTrainE),
                    new SqlParameter("@OBRE", bG_ProBasiPubPay.OBRE),
                    new SqlParameter("@PBAE", bG_ProBasiPubPay.PBAE),
                    new SqlParameter("@LUMD", bG_ProBasiPubPay.LUMD),
                    new SqlParameter("@PBWE", bG_ProBasiPubPay.PBWE),
                    new SqlParameter("@PBOCE", bG_ProBasiPubPay.PBOCE),
                    new SqlParameter("@OOPE", bG_ProBasiPubPay.OOPE),
                    new SqlParameter("@OCASE", bG_ProBasiPubPay.OCASE),
                    new SqlParameter("@PBIDTitol", bG_ProBasiPubPay.PBIDTitol)
                };

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

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
    private void IsnotBG_ProBasiPerPay()
    {
        byte[] bt;
        DataTable dt1 = new DataTable();
        DataTable dt2 = new DataTable();
        DataTable dt3 = new DataTable();
        DataTable dt4 = new DataTable();

        if (FUFEXC.HasFile)
        {
            bt = FUFEXC.FileBytes;
            dt1 = ImportFinaDataLogic.GetDTBySheetname("基人一", bt, 9, 10);
            dt2 = ImportFinaDataLogic.GetDTBySheetname("基人二", bt, 10, 12);
            dt3 = ImportFinaDataLogic.GetDTBySheetname("基公", bt, 9, 21);
            dt4 = ImportFinaDataLogic.GetDTBySheetname("项目支出", bt, 9, 15);
        }
        else
        {
            Response.Write("没有数据");
        }
        bt = null;

        DateTime dtime = Convert.ToDateTime(CurrentYear + "-" + "01-" + "01");
        BG_ProBasiPerPayOne PBPPOM = new BG_ProBasiPerPayOne();
        PBPPOM.POBS = ParToDecimal.ParToDel(dt1.Rows[0][4].ToString());
        PBPPOM.POAS = ParToDecimal.ParToDel(dt1.Rows[0][5].ToString());
        PBPPOM.POBonus = ParToDecimal.ParToDel(dt1.Rows[0][6].ToString());
        PBPPOM.POPS = ParToDecimal.ParToDel(dt1.Rows[0][7].ToString());
        PBPPOM.POSE = ParToDecimal.ParToDel(dt1.Rows[0][8].ToString());
        PBPPOM.POOther = ParToDecimal.ParToDel(dt1.Rows[0][9].ToString());
        PBPPOM.POTitol = ParToDecimal.ParToDel(dt1.Rows[0][3].ToString());
        PBPPOM.POYear = dtime;
        PBPPOM.DepID = AreaDepID;
        BG_ProBasiPerPayOneManager.AddBG_ProBasiPerPayOne(PBPPOM);

        BG_ProBasiPerPayTwo PBPPT = new BG_ProBasiPerPayTwo();
        PBPPT.RetiredPerP = ParToDecimal.ParToDel(dt2.Rows[0][5].ToString());
        PBPPT.RetiredPubP = ParToDecimal.ParToDel(dt2.Rows[0][6].ToString());
        PBPPT.RetirementPerP = ParToDecimal.ParToDel(dt2.Rows[0][9].ToString());
        PBPPT.RetirementPubP = ParToDecimal.ParToDel(dt2.Rows[0][8].ToString());
        PBPPT.PTME = ParToDecimal.ParToDel(dt2.Rows[0][10].ToString());
        PBPPT.PTOther = ParToDecimal.ParToDel(dt2.Rows[0][11].ToString());
        PBPPT.PTTitol = ParToDecimal.ParToDel(dt2.Rows[0][3].ToString());
        PBPPT.PTYear = dtime;
        PBPPT.DepID = AreaDepID;
        BG_ProBasiPerPayTwoManager.AddBG_ProBasiPerPayTwo(PBPPT);

        BG_ProBasiPubPay PBPP = new BG_ProBasiPubPay();

        PBPP.PBOE = ParToDecimal.ParToDel(dt3.Rows[0][5].ToString());
        PBPP.PBUtilities = ParToDecimal.ParToDel(dt3.Rows[0][6].ToString());
        PBPP.PBPF = ParToDecimal.ParToDel(dt3.Rows[0][7].ToString());
        PBPP.OBCFE = ParToDecimal.ParToDel(dt3.Rows[0][8].ToString());
        PBPP.PBTravelE = ParToDecimal.ParToDel(dt3.Rows[0][9].ToString());
        PBPP.PBRE = ParToDecimal.ParToDel(dt3.Rows[0][10].ToString());
        PBPP.PBME = ParToDecimal.ParToDel(dt3.Rows[0][11].ToString());
        PBPP.PBTrainE = ParToDecimal.ParToDel(dt3.Rows[0][12].ToString());
        PBPP.OBRE = ParToDecimal.ParToDel(dt3.Rows[0][13].ToString());
        PBPP.PBAE = ParToDecimal.ParToDel(dt3.Rows[0][14].ToString());
        PBPP.LUMD = ParToDecimal.ParToDel(dt3.Rows[0][15].ToString());
        PBPP.PBWE = ParToDecimal.ParToDel(dt3.Rows[0][16].ToString());
        PBPP.PBOCE = ParToDecimal.ParToDel(dt3.Rows[0][17].ToString());
        PBPP.OCASE = ParToDecimal.ParToDel(dt3.Rows[0][19].ToString());
        PBPP.PBIDTitol = ParToDecimal.ParToDel(dt3.Rows[0][3].ToString());
        PBPP.PBYear = dtime;
        PBPP.DepID = AreaDepID;
        BG_ProBasiPubPayManager.AddBG_ProBasiPubPay(PBPP);

        for (int i = 0; i < dt4.Rows.Count; i++)
        {
            if (string.IsNullOrEmpty(dt4.Rows[i][3].ToString()))
            {
                return;
            }
            BG_ProPay PP = new BG_ProPay();
            PP.PPID = dt4.Rows[i][3].ToString().Trim();
            PP.ProPA0M = ParToDecimal.ParToDel(dt4.Rows[i][4].ToString());
            PP.ProPYear = dtime;
            PP.DepID = AreaDepID;
            BG_ProPayManager.AddBG_ProPay(PP);
        }
        X.Msg.Alert("提示", "导入成功.").Show();
    }
 public static bool ModifyBG_ProBasiPubPay(BG_ProBasiPubPay bG_ProBasiPubPay)
 {
     return BG_ProBasiPubPayService.ModifyBG_ProBasiPubPay(bG_ProBasiPubPay);
 }
 public static bool DeleteBG_ProBasiPubPay(BG_ProBasiPubPay bG_ProBasiPubPay)
 {
     return BG_ProBasiPubPayService.DeleteBG_ProBasiPubPay(bG_ProBasiPubPay);
 }
 public static BG_ProBasiPubPay AddBG_ProBasiPubPay(BG_ProBasiPubPay bG_ProBasiPubPay)
 {
     return BG_ProBasiPubPayService.AddBG_ProBasiPubPay(bG_ProBasiPubPay);
 }
 public static bool DeleteBG_ProBasiPubPay(BG_ProBasiPubPay bG_ProBasiPubPay)
 {
     return DeleteBG_ProBasiPubPayByPBID( bG_ProBasiPubPay.PBID );
 }
        public static bool ModifyBG_ProBasiPubPay(BG_ProBasiPubPay bG_ProBasiPubPay)
        {
            string sql =
                "UPDATE BG_ProBasiPubPay " +
                "SET " +
                    "DepID = @DepID, " +
                    "PBYear = @PBYear, " +
                    "PBOE = @PBOE, " +
                    "PBUtilities = @PBUtilities, " +
                    "PBPF = @PBPF, " +
                    "OBCFE = @OBCFE, " +
                    "PBTravelE = @PBTravelE, " +
                    "PBRE = @PBRE, " +
                    "PBME = @PBME, " +
                    "PBTrainE = @PBTrainE, " +
                    "OBRE = @OBRE, " +
                    "PBAE = @PBAE, " +
                    "LUMD = @LUMD, " +
                    "PBWE = @PBWE, " +
                    "PBOCE = @PBOCE, " +
                    "OOPE = @OOPE, " +
                    "OCASE = @OCASE, " +
                    "PBIDTitol = @PBIDTitol " +
                "WHERE PBID = @PBID";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@PBID", bG_ProBasiPubPay.PBID),
                    new SqlParameter("@DepID", bG_ProBasiPubPay.DepID),
                    new SqlParameter("@PBYear", bG_ProBasiPubPay.PBYear),
                    new SqlParameter("@PBOE", bG_ProBasiPubPay.PBOE),
                    new SqlParameter("@PBUtilities", bG_ProBasiPubPay.PBUtilities),
                    new SqlParameter("@PBPF", bG_ProBasiPubPay.PBPF),
                    new SqlParameter("@OBCFE", bG_ProBasiPubPay.OBCFE),
                    new SqlParameter("@PBTravelE", bG_ProBasiPubPay.PBTravelE),
                    new SqlParameter("@PBRE", bG_ProBasiPubPay.PBRE),
                    new SqlParameter("@PBME", bG_ProBasiPubPay.PBME),
                    new SqlParameter("@PBTrainE", bG_ProBasiPubPay.PBTrainE),
                    new SqlParameter("@OBRE", bG_ProBasiPubPay.OBRE),
                    new SqlParameter("@PBAE", bG_ProBasiPubPay.PBAE),
                    new SqlParameter("@LUMD", bG_ProBasiPubPay.LUMD),
                    new SqlParameter("@PBWE", bG_ProBasiPubPay.PBWE),
                    new SqlParameter("@PBOCE", bG_ProBasiPubPay.PBOCE),
                    new SqlParameter("@OOPE", bG_ProBasiPubPay.OOPE),
                    new SqlParameter("@OCASE", bG_ProBasiPubPay.OCASE),
                    new SqlParameter("@PBIDTitol", bG_ProBasiPubPay.PBIDTitol)
                };

                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_ProBasiPubPay GetBG_ProBasiPubPayByPBID(int pBID)
        {
            string sql = "SELECT * FROM BG_ProBasiPubPay WHERE PBID = @PBID";

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

                if(dt.Rows.Count > 0)
                {
                    BG_ProBasiPubPay bG_ProBasiPubPay = new BG_ProBasiPubPay();

                    bG_ProBasiPubPay.PBID = dt.Rows[0]["PBID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["PBID"];
                    bG_ProBasiPubPay.DepID = dt.Rows[0]["DepID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["DepID"];
                    bG_ProBasiPubPay.PBYear = dt.Rows[0]["PBYear"] == DBNull.Value ? DateTime.MinValue : (DateTime)dt.Rows[0]["PBYear"];
                    bG_ProBasiPubPay.PBOE = dt.Rows[0]["PBOE"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["PBOE"];
                    bG_ProBasiPubPay.PBUtilities = dt.Rows[0]["PBUtilities"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["PBUtilities"];
                    bG_ProBasiPubPay.PBPF = dt.Rows[0]["PBPF"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["PBPF"];
                    bG_ProBasiPubPay.OBCFE = dt.Rows[0]["OBCFE"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["OBCFE"];
                    bG_ProBasiPubPay.PBTravelE = dt.Rows[0]["PBTravelE"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["PBTravelE"];
                    bG_ProBasiPubPay.PBRE = dt.Rows[0]["PBRE"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["PBRE"];
                    bG_ProBasiPubPay.PBME = dt.Rows[0]["PBME"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["PBME"];
                    bG_ProBasiPubPay.PBTrainE = dt.Rows[0]["PBTrainE"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["PBTrainE"];
                    bG_ProBasiPubPay.OBRE = dt.Rows[0]["OBRE"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["OBRE"];
                    bG_ProBasiPubPay.PBAE = dt.Rows[0]["PBAE"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["PBAE"];
                    bG_ProBasiPubPay.LUMD = dt.Rows[0]["LUMD"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["LUMD"];
                    bG_ProBasiPubPay.PBWE = dt.Rows[0]["PBWE"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["PBWE"];
                    bG_ProBasiPubPay.PBOCE = dt.Rows[0]["PBOCE"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["PBOCE"];
                    bG_ProBasiPubPay.OOPE = dt.Rows[0]["OOPE"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["OOPE"];
                    bG_ProBasiPubPay.OCASE = dt.Rows[0]["OCASE"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["OCASE"];
                    bG_ProBasiPubPay.PBIDTitol = dt.Rows[0]["PBIDTitol"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["PBIDTitol"];

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