示例#1
0
        private void Button10_Click(object sender, EventArgs e)
        {
            //保存数据
            string dbSvrName  = textBox11.Text;
            string dbName     = textBox4.Text;
            string dbUserName = textBox6.Text;
            string dbUserPwd  = textBox5.Text;

            //测试数据库连接
            if (sys.SysSec.CheckdbCon(dbSvrName, dbName, dbUserName, dbUserPwd) == false)
            {
                return;
            }

            SysSec.SaveSetInIni(dbSvrName, dbName, dbUserName, dbUserPwd);
            MessageBox.Show("数据已经保存在当前目录的setting.ini文件中,你可以复制该配置文件到其他计算机中应用");
        }
示例#2
0
        private void Button11_Click(object sender, EventArgs e)
        {
            //保存数据
            string dbSvrName  = textBox11.Text;
            string dbName     = textBox4.Text;
            string dbUserName = textBox6.Text;
            string dbUserPwd  = textBox5.Text;

            //测试数据库连接
            if (sys.SysSec.CheckdbCon(dbSvrName, dbName, dbUserName, dbUserPwd) == false)
            {
                return;
            }

            SysSec.SaveSetInReg(dbSvrName, dbName, dbUserName, dbUserPwd);
            SysSec.SaveSetInIni(dbSvrName, dbName, dbUserName, dbUserPwd);
        }
示例#3
0
        public void LoadSysData()
        {
            //如果没有admin用户,添加该用户

            myEFContext db = new myEFContext();

            //检查系统设置

            int n = db.sysInfo.Count();

            if (n == 1)
            {
                sysInfo sysInfo = db.sysInfo.First();

                SysSec.companyName = sysInfo.companyName;
                SysSec.sysName     = sysInfo.sysName;
            }

            n = db.Users.Where(t => t.UserLoginName.ToLower() == "admin").Count();
            if (n == 0)
            {
                User adminUser = new User
                {
                    UserLoginName  = "admin",
                    UserPassword   = SysSec.StringSec("admin"),
                    UserName       = "******",
                    Level          = 0,
                    Enable         = true,
                    remark         = "系统内置管理员,不能删除",
                    UserCreateTime = DateTime.Now,
                    LastLoginTime  = null
                };

                db.Users.Add(adminUser);
                db.SaveChanges();

                //自动打开系统配置界面
                MessageBox.Show("第一次登录使用系统,请设置系统数据");
                Form dbset = new sys.SysSet();

                dbset.ShowDialog();
            }
        }
示例#4
0
        private void Button9_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.FileName = "setting.ini";
            fileDialog.Filter   = "配置文件|*.ini";
            fileDialog.Title    = "请选择配置文件setting.ini,默认存储在程序当前目录";
            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                string iniPath = fileDialog.FileName;
                Dictionary <string, string> SetDict = new Dictionary <string, string>();
                SetDict = SysSec.ReadSetInIni(iniPath);
                if (SetDict == null)
                {
                    MessageBox.Show("数据错误");
                    return;
                }
                try
                {
                    textBox11.Text = SetDict["1"];
                    textBox4.Text  = SetDict["2"];
                    textBox6.Text  = SetDict["3"];
                    textBox5.Text  = SetDict["4"];

                    //测试数据库连接
                    if (sys.SysSec.CheckdbCon(textBox11.Text, textBox4.Text, textBox6.Text, textBox5.Text) == false)
                    {
                        return;
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("数据错误");
                    return;
                }
            }
        }