public static BG_UserPurview AddBG_UserPurview(BG_UserPurview bG_UserPurview)
        {
            string sql =
                "INSERT BG_UserPurview (UPName, Remark)" +
                "VALUES (@UPName, @Remark)";

            sql += " ; SELECT @@IDENTITY";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@UPName", bG_UserPurview.UPName),
                    new SqlParameter("@Remark", bG_UserPurview.Remark)
                };

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

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
        public static BG_UserPurview GetBG_UserPurviewByUPID(int uPID)
        {
            string sql = "SELECT * FROM BG_UserPurview WHERE UPID = @UPID";

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

                if(dt.Rows.Count > 0)
                {
                    BG_UserPurview bG_UserPurview = new BG_UserPurview();

                    bG_UserPurview.UPID = dt.Rows[0]["UPID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["UPID"];
                    bG_UserPurview.UPName = dt.Rows[0]["UPName"] == DBNull.Value ? "" : (string)dt.Rows[0]["UPName"];
                    bG_UserPurview.Remark = dt.Rows[0]["Remark"] == DBNull.Value ? "" : (string)dt.Rows[0]["Remark"];

                    return bG_UserPurview;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
 public static bool DeleteBG_UserPurview(BG_UserPurview bG_UserPurview)
 {
     return DeleteBG_UserPurviewByUPID( bG_UserPurview.UPID );
 }
        public static bool ModifyBG_UserPurview(BG_UserPurview bG_UserPurview)
        {
            string sql =
                "UPDATE BG_UserPurview " +
                "SET " +
                    "UPName = @UPName, " +
                    "Remark = @Remark " +
                "WHERE UPID = @UPID";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@UPID", bG_UserPurview.UPID),
                    new SqlParameter("@UPName", bG_UserPurview.UPName),
                    new SqlParameter("@Remark", bG_UserPurview.Remark)
                };

                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_UserPurview(BG_UserPurview bG_UserPurview)
 {
     return BG_UserPurviewService.ModifyBG_UserPurview(bG_UserPurview);
 }
 public static bool DeleteBG_UserPurview(BG_UserPurview bG_UserPurview)
 {
     return BG_UserPurviewService.DeleteBG_UserPurview(bG_UserPurview);
 }
 public static BG_UserPurview AddBG_UserPurview(BG_UserPurview bG_UserPurview)
 {
     return BG_UserPurviewService.AddBG_UserPurview(bG_UserPurview);
 }