Esempio n. 1
0
        private void loadSkin()
        {
            string filePath = Application.StartupPath + @"\config.lsf";

            if (File.Exists(filePath))
            {
                KBFile kbFile = new KBFile();
                kbFile.path = filePath;
                SysConfig config = kbFile.readObjectFromFile() as SysConfig;

                if (!string.IsNullOrEmpty(config.SkinFile))
                {
                    this.skin.SkinFile    = config.SkinFile; //使用第三方皮肤控件
                    this.skin.SkinAllForm = true;
                    this.skin.Active      = true;
                }
                else
                {
                    this.skin.SkinFile    = null; //使用第三方皮肤控件
                    this.skin.SkinAllForm = true;
                    this.skin.Active      = false;
                }
            }
            else
            {
                this.skin.SkinFile    = null;; //使用第三方皮肤控件
                this.skin.SkinAllForm = true;
                this.skin.Active      = false;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 获取配置信息
        /// </summary>
        /// <returns></returns>
        public DBConfig getConfig()
        {
            try
            {
                KBFile file = new KBFile();
                file.path = System.Windows.Forms.Application.StartupPath + "\\dbConfig.kb";
                CrypToFile cy    = new CrypToFile();
                int        count = file.path.Split('.').Length;

                string fileExt  = file.path.Split('.')[count - 1];
                string fileName = file.path.Substring(0, file.path.Length - fileExt.Length - 1);

                if (cy.DecryptData(file.path, fileName + "pwd." + fileExt, "KingBoy"))
                {
                    file.path = fileName + "pwd." + fileExt;
                    DBConfig con = (DBConfig)file.readObjectFromFile();
                    System.IO.File.Delete(file.path);
                    return(con);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 用户登录
        /// </summary>
        private void userLogin()
        {
            if (checkInput())
            {
                try
                {
                    SysUserBLL sysUserBll = new SysUserBLL();
                    SysUser    userEntity = sysUserBll.Login(this.txtUser.Text, txtPass.Text);

                    if (!userEntity.LoginOk)//登录失败
                    {
                        untCommon.ErrorMsg("登录失败:" + userEntity.LoginMsg);
                    }
                    else
                    {
                        if (cbRemember.Checked)
                        {
                            LoginInfo loginInfo = new LoginInfo();
                            loginInfo.Number   = this.txtUser.Text;
                            loginInfo.Pwd      = txtPass.Text;
                            loginInfo.Remember = true;

                            /*删除旧的配置文件*/
                            if (File.Exists(Application.StartupPath + @"\\loginConfig.lsf"))
                            {
                                File.Delete(Application.StartupPath + @"\\loginConfig.lsf");
                            }

                            KBFile kbFile = new KBFile();
                            kbFile.path = Application.StartupPath + @"\\loginConfig.lsf";
                            if (kbFile.writeObjectToFile(loginInfo) < 1)
                            {
                                MessageBox.Show("保存登陆配置文件失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            /*删除旧的配置文件*/
                            if (File.Exists(Application.StartupPath + @"\\loginConfig.lsf"))
                            {
                                File.Delete(Application.StartupPath + @"\\loginConfig.lsf");
                            }
                        }
                        Globels.strName = userEntity.F_RealName;
                        Globels.strUser = this.txtUser.Text;

                        frmMain main = new frmMain(this);
                        main.User = userEntity;

                        main.Show();
                        this.Hide();
                    }
                }
                catch (Exception ex)
                {
                    untCommon.ErrorMsg("用户登录异常:" + ex.Message);
                }
            }
        }
Esempio n. 4
0
        private void Init()
        {
            try
            {
                if (File.Exists(Application.StartupPath + @"\\WorkShop.txt"))
                {
                    using (StreamReader sr = File.OpenText(Application.StartupPath + @"\\WorkShop.txt"))
                    {
                        string strTemp = sr.ReadLine();
                        Globels.strWorkShop  = Data(strTemp);
                        strTemp              = sr.ReadLine();
                        Globels.strTeam      = Data(strTemp);
                        strTemp              = sr.ReadLine();
                        Globels.strStockCode = Data(strTemp);
                        strTemp              = sr.ReadLine();
                        Globels.strProce     = Data(strTemp);
                        strTemp              = sr.ReadLine();
                        Globels.strCom       = Data(strTemp);
                        sr.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }

            try
            {
                if (File.Exists(Application.StartupPath + @"\\loginConfig.lsf"))
                {
                    KBFile kbFile = new KBFile();
                    kbFile.path = Application.StartupPath + @"\\loginConfig.lsf";
                    LoginInfo loginInfo = kbFile.readObjectFromFile() as LoginInfo;
                    txtUser.Text       = loginInfo.Number;
                    txtPass.Text       = loginInfo.Pwd;
                    cbRemember.Checked = loginInfo.Remember;

                    txtPass.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("用户登陆模块出现异常:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Esempio n. 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string    filePath = Application.StartupPath + @"\config.lsf";
                string    skinfile = cbSkin.SelectedItem.ToString();
                SysConfig config   = new SysConfig();
                if (skinfile == "None")
                {
                    config.SkinFile = "";
                }
                else
                {
                    config.SkinFile = Application.StartupPath + @"\Skins\" + skinfile;
                }


                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }

                KBFile kbFile = new KBFile();
                kbFile.path = filePath;
                int result = kbFile.writeObjectToFile(config);

                if (result > 0)
                {
                    frmParent.frmLogin.setSkin(config.SkinFile);
                    untCommon.InfoMsg("设置成功!");
                }
                else
                {
                    untCommon.InfoMsg("设置失败!");
                }
            }
            catch (Exception ex)
            {
                untCommon.ErrorMsg("皮肤设置异常:" + ex.Message);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 将配置对象写入数据库
        /// </summary>
        /// <returns></returns>
        public int setConfig()
        {
            try
            {
                KBFile file = new KBFile();
                file.path = System.Windows.Forms.Application.StartupPath + "\\dbConfig.kb";

                if (file.writeObjectToFile(this) > 0)
                {
                    CrypToFile cy    = new CrypToFile();
                    int        count = file.path.Split('.').Length;

                    string fileExt  = file.path.Split('.')[count - 1];
                    string fileName = file.path.Substring(0, file.path.Length - fileExt.Length - 1);

                    if (cy.EncryptData(file.path, fileName + "pwd." + fileExt, "KingBoy"))
                    {
                        System.IO.File.Delete(file.path);
                        System.IO.File.Copy(fileName + "pwd." + fileExt, file.path, true);
                        System.IO.File.Delete(fileName + "pwd." + fileExt);
                        return(1);
                    }
                    else
                    {
                        return(-2);
                    }
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception)
            {
                return(-1);
            }
        }