public static BG_SysSetting AddBG_SysSetting(BG_SysSetting bG_SysSetting)
        {
            string sql =
                "INSERT BG_SysSetting (SysName, DefaultYear, PepNum)" +
                "VALUES (@SysName, @DefaultYear, @PepNum)";

            sql += " ; SELECT @@IDENTITY";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@SysName", bG_SysSetting.SysName),
                    new SqlParameter("@DefaultYear", bG_SysSetting.DefaultYear),
                    new SqlParameter("@PepNum", bG_SysSetting.PepNum)
                };

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

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
    protected void btnSure_DirectClick(object sender, Ext.Net.DirectEventArgs e)
    {
        DataTable dt = BG_SysSettingManager.GetAllBG_SysSetting();
        int count = dt.Rows.Count;
        int curtime = 0;
        if (count == 0)
        {
            curtime = Convert.ToInt32(TFDefaultYear.Text);
        }
        else { curtime = Convert.ToInt32(dt.Rows[count - 1]["DefaultYear"].ToString()); }

        if (Convert.ToInt32(TFDefaultYear.Text.Trim()) >= curtime)
        {
            BG_SysSetting bg_sys = new BG_SysSetting();
            bg_sys.SysName = TFSysName.Text.Trim();
            bg_sys.DefaultYear = Convert.ToInt32(TFDefaultYear.Text.Trim());
            bg_sys.PepNum = Convert.ToInt32(TFPopNum.Text.Trim());
            BG_SysSettingManager.AddBG_SysSetting(bg_sys);
            X.Msg.Alert("提示", "添加成功!").Show();
        }
        else
        {
            BG_SysSetting bg_sys = new BG_SysSetting();
            bg_sys.SSID = Convert.ToInt32(hidID.Value);
            bg_sys.SysName = TFSysName.Text.Trim();
            bg_sys.DefaultYear = Convert.ToInt32(TFDefaultYear.Text.Trim());
            bg_sys.PepNum = Convert.ToInt32(TFPopNum.Text.Trim());
            bool flag = BG_SysSettingManager.ModifyBG_SysSetting(bg_sys);
            if (flag)
            {
                X.Msg.Alert("提示", "修改成功!").Show();
            }
            else
            {
                X.Msg.Alert("提示", "修改失败,请与管理员联系!").Show();
            }
        }
    }
 public static bool ModifyBG_SysSetting(BG_SysSetting bG_SysSetting)
 {
     return BG_SysSettingService.ModifyBG_SysSetting(bG_SysSetting);
 }
 public static bool DeleteBG_SysSetting(BG_SysSetting bG_SysSetting)
 {
     return BG_SysSettingService.DeleteBG_SysSetting(bG_SysSetting);
 }
 public static BG_SysSetting AddBG_SysSetting(BG_SysSetting bG_SysSetting)
 {
     return BG_SysSettingService.AddBG_SysSetting(bG_SysSetting);
 }
        public static BG_SysSetting GetBG_SysSettingBySSID(int sSID)
        {
            string sql = "SELECT * FROM BG_SysSetting WHERE SSID = @SSID";

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

                if(dt.Rows.Count > 0)
                {
                    BG_SysSetting bG_SysSetting = new BG_SysSetting();

                    bG_SysSetting.SSID = dt.Rows[0]["SSID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["SSID"];
                    bG_SysSetting.SysName = dt.Rows[0]["SysName"] == DBNull.Value ? "" : (string)dt.Rows[0]["SysName"];
                    bG_SysSetting.DefaultYear = dt.Rows[0]["DefaultYear"] == DBNull.Value ? 0 : (int)dt.Rows[0]["DefaultYear"];
                    bG_SysSetting.PepNum = dt.Rows[0]["PepNum"] == DBNull.Value ? 0 : (int)dt.Rows[0]["PepNum"];

                    return bG_SysSetting;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
 public static bool DeleteBG_SysSetting(BG_SysSetting bG_SysSetting)
 {
     return DeleteBG_SysSettingBySSID( bG_SysSetting.SSID );
 }
        public static bool ModifyBG_SysSetting(BG_SysSetting bG_SysSetting)
        {
            string sql =
                "UPDATE BG_SysSetting " +
                "SET " +
                    "SysName = @SysName, " +
                    "DefaultYear = @DefaultYear, " +
                    "PepNum = @PepNum " +
                "WHERE SSID = @SSID";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@SSID", bG_SysSetting.SSID),
                    new SqlParameter("@SysName", bG_SysSetting.SysName),
                    new SqlParameter("@DefaultYear", bG_SysSetting.DefaultYear),
                    new SqlParameter("@PepNum", bG_SysSetting.PepNum)
                };

                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;
            }
        }