public static BG_PreviewDevide AddBG_PreviewDevide(BG_PreviewDevide bG_PreviewDevide)
        {
            string sql =
                "INSERT BG_PreviewDevide (DepID, PSID, DevMon)" +
                "VALUES (@DepID, @PSID, @DevMon)";

            sql += " ; SELECT @@IDENTITY";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@DepID", bG_PreviewDevide.DepID),
                    new SqlParameter("@PSID", bG_PreviewDevide.PSID),
                    new SqlParameter("@DevMon", bG_PreviewDevide.DevMon)
                };

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

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
        public static BG_PreviewDevide GetBG_PreviewDevideByPDID(int pDID)
        {
            string sql = "SELECT * FROM BG_PreviewDevide WHERE PDID = @PDID";

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

                if(dt.Rows.Count > 0)
                {
                    BG_PreviewDevide bG_PreviewDevide = new BG_PreviewDevide();

                    bG_PreviewDevide.PDID = dt.Rows[0]["PDID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["PDID"];
                    bG_PreviewDevide.DepID = dt.Rows[0]["DepID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["DepID"];
                    bG_PreviewDevide.PSID = dt.Rows[0]["PSID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["PSID"];
                    bG_PreviewDevide.DevMon = dt.Rows[0]["DevMon"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["DevMon"];

                    return bG_PreviewDevide;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
 public static bool DeleteBG_PreviewDevide(BG_PreviewDevide bG_PreviewDevide)
 {
     return DeleteBG_PreviewDevideByPDID( bG_PreviewDevide.PDID );
 }
        public static bool ModifyBG_PreviewDevide(BG_PreviewDevide bG_PreviewDevide)
        {
            string sql =
                "UPDATE BG_PreviewDevide " +
                "SET " +
                    "DepID = @DepID, " +
                    "PSID = @PSID, " +
                    "DevMon = @DevMon " +
                "WHERE PDID = @PDID";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@PDID", bG_PreviewDevide.PDID),
                    new SqlParameter("@DepID", bG_PreviewDevide.DepID),
                    new SqlParameter("@PSID", bG_PreviewDevide.PSID),
                    new SqlParameter("@DevMon", bG_PreviewDevide.DevMon)
                };

                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 bool ModifyBG_PreviewDevide(BG_PreviewDevide bG_PreviewDevide)
 {
     return BG_PreviewDevideService.ModifyBG_PreviewDevide(bG_PreviewDevide);
 }
 public static bool DeleteBG_PreviewDevide(BG_PreviewDevide bG_PreviewDevide)
 {
     return BG_PreviewDevideService.DeleteBG_PreviewDevide(bG_PreviewDevide);
 }
 public static BG_PreviewDevide AddBG_PreviewDevide(BG_PreviewDevide bG_PreviewDevide)
 {
     return BG_PreviewDevideService.AddBG_PreviewDevide(bG_PreviewDevide);
 }