博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
系统设置
阅读量:7225 次
发布时间:2019-06-29

本文共 3292 字,大约阅读时间需要 10 分钟。

一:截图

二:SettingDAL.cs

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data.SqlClient;using System.Data;namespace HRMSys.DAL{    public class SettingDAL    {        ///         /// 赋值的公用方法        ///         ///         ///         public void setValue(string name, string value)        {            int i = sqlhelper.ExecuteNon("update T_Setting set Value=@Value where Name=@Name",                new SqlParameter("@Value",value),                new SqlParameter("@Name",name));            if (i != 1)            {                throw new Exception("影响的行数不是1,而是"+i);             }        }        ///         /// bool重载赋值公用方法        ///         ///         ///         public void setValue(string name, bool value)        {            setValue(name, value.ToString());        }               ///         /// int 重载赋值公用方法        ///         ///         ///         public void SetValue(string name, int value)        {            setValue(name, value.ToString());             }        ///         /// 得到指定name的值        ///         ///         /// 
public string getValue(string name) { DataTable table = sqlhelper.datatable("select Value from T_Setting where Name=@Name", new SqlParameter("@Name",name)); if(table.Rows.Count<=0) { throw new Exception(name +"不存在!"); } if(table.Rows.Count>1) { throw new Exception("出现"+table.Rows.Count+"条Name="+"的Setting数据"); } else { DataRow row=table.Rows[0]; return (string)row["Value"]; } } /// /// 不是重载,又返回类型的得到指定的值 /// /// ///
public bool GetBoolValue(string name) { return Convert.ToBoolean(getValue(name)); } public int GetIntValue(string name) { return Convert.ToInt32(getValue(name)); } }}

三:SettingWindow.cs

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using HRMSys.DAL;namespace HYMSys.UI.SystemMgr{    public partial class SettingWindow : Form    {        public SettingWindow()        {            InitializeComponent();        }        ///         ///保存时        ///         ///         ///         private void btn_ok_Click(object sender, EventArgs e)        {            SettingDAL set = new SettingDAL();            set.setValue("公司网站", tb_companyWeb.Text);            set.setValue("公司名称", tb_CompanyName.Text);            set.setValue("启用生日提醒",(bool) chk_remind.Checked);//将是否选中转换为bool值            set.setValue("生日提醒天数",tb_remindDay.Text);            set.setValue("员工工号前缀",tb_employFirst.Text);        }            private void SettingWindow_Load(object sender, EventArgs e)        {            SettingDAL dal = new SettingDAL();            tb_CompanyName.Text = dal.getValue("公司名称");            tb_companyWeb.Text = dal.getValue("公司网站");            chk_remind.Checked = dal.GetBoolValue("启用生日提醒");            tb_remindDay.Text = dal.getValue("生日提醒天数");            tb_employFirst.Text = dal.getValue("员工工号前缀");                }        }    }

转载地址:http://izdfm.baihongyu.com/

你可能感兴趣的文章
框架名
查看>>
编译安装PHP
查看>>
插入透明背景Flash的HTML代码
查看>>
无标题
查看>>
我的友情链接
查看>>
Web前端入门学习(3)——CSS选择器
查看>>
DNS的搭建
查看>>
Apache/Nginx 访问日志分析脚本
查看>>
Curator的使用
查看>>
第五章 集合类型
查看>>
我的友情链接
查看>>
nagios监控服务出现FLAPPING状态时无法发出邮件报警信息
查看>>
数据库链接字符串方法
查看>>
The DCI Architecture: A New Vision of Object-Oriented Programming(一篇具有里程碑式意义的论文)...
查看>>
RIP路由配置实例V2
查看>>
Bytescout Spreadsheet SDK for.NET
查看>>
我的友情链接
查看>>
Haproxy的三种保持客户端会话保持方式
查看>>
iOS的数学函数
查看>>
python 模块 chardet下载及介绍(转)
查看>>