⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 settingdbfunc.cs

📁 JAVA的精彩实例
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;

using System.Data;

namespace feiyun0112.cnblogs.com.CSDNReader.Functions
{
    class SettingDBFunc
    {
        private SettingDBFunc()
        {
        }
        public static  DataView GetSetting()
        {
            DataView dvw = null;
            DBFunc db = new DBFunc(false, false);
            try
            {                
                string strSql = "select * from Settings";
                dvw = db.GetDataSet(strSql).Tables[0].DefaultView;
                
            }
            catch (Exception e)
            {
                dvw = null;
                MsgFunc.ShowWarning(e.Message);
                return dvw;
            }
            finally
            {
                db.CloseCon();
            }
            return dvw;
        }

        public static string GetSettingValue(string strID)
        {
            DataView dvwSetting = GetSetting();
            string strValue = "";
            dvwSetting.RowFilter = "ID='" + strID + "'";
            if (dvwSetting.Count > 0)
            {
                strValue = dvwSetting[0]["Value"].ToString();
            }

            return strValue;
        }


        public static void SetSetting(string strID, string strNewValue)
        {
            DBFunc db = new DBFunc(false, false);

            
            try
            {
                string strSql = "delete * from Settings where Id='" + strID + "'";
                db.ExecuteSql(strSql);

                strSql = "insert into Settings([ID],[Value]) values('" + strID + "','" + DBFunc.SpecialChar(strNewValue) + "')";
                db.ExecuteSql(strSql);
            }
            catch (Exception e)
            {
                
                MsgFunc.ShowWarning(e.Message);
                return ;
            }
            finally
            {
                db.Dispose();
            }


        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -