• 系统设置


    一:截图

    2014-04-08_1759552014-04-08_1800202014-04-08_180100

    二: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
        {
            /// <summary>
            /// 赋值的公用方法
            /// </summary>
            /// <param name="name"></param>
            /// <param name="value"></param>
            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);
     
                }
            }
            /// <summary>
            /// bool重载赋值公用方法
            /// </summary>
            /// <param name="name"></param>
            /// <param name="value"></param>
            public void setValue(string name, bool value)
            {
                setValue(name, value.ToString());
            }
           
            /// <summary>
            /// int 重载赋值公用方法
            /// </summary>
            /// <param name="name"></param>
            /// <param name="value"></param>
            public void SetValue(string name, int value)
            {
                setValue(name, value.ToString());
         
            }
            /// <summary>
            /// 得到指定name的值
            /// </summary>
            /// <param name="name"></param>
            /// <returns></returns>
            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"];
                }
            }
    
    
            /// <summary>
            /// 不是重载,又返回类型的得到指定的值
            /// </summary>
            /// <param name="name"></param>
            /// <returns></returns>
            public bool GetBoolValue(string name)
            {
                return Convert.ToBoolean(getValue(name));
            }
    
            public int GetIntValue(string name)
            {
                return Convert.ToInt32(getValue(name));
            }
       
        }
    
    }

    三:SettingWindow.cs

    2014-04-08_180540

    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();
            }
            /// <summary>
            ///保存时
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            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("员工工号前缀");
            
            }
    
            }
        }
  • 相关阅读:
    request内置对象(上)1
    康拓展开-----两个排列的位置之差
    判断一个数的质因子个数
    学生信息管理系统----(顺序表)
    学生信息管理系统----(链表)
    二分图的最大匹配--匈牙利算法
    hdu-1285拓扑排序
    文件的压缩与解压
    树莓派安装QT(全部库包括)
    Win10 + CLion + 树莓派 + QT 远程开发调用Python
  • 原文地址:https://www.cnblogs.com/hongmaju/p/3653512.html
Copyright © 2020-2023  润新知