コード例 #1
0
ファイル: Program.cs プロジェクト: q394304565/Addresslist
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     SQLiteOperate.CreateDB();
     Application.Run(new Login());
 }
コード例 #2
0
ファイル: Login.cs プロジェクト: q394304565/Addresslist
 public Login()
 {
     InitializeComponent();
     GlobalData.Current.SkinEngine = skinEngine1;
     GlobalData.Current.UserConfig = SQLiteOperate.GetUserConfig();
     if (GlobalData.Current.UserConfig != null)
     {
         cbRemindName.Checked     = GlobalData.Current.UserConfig.IsSaveName;
         txtUName.Text            = GlobalData.Current.UserConfig.IsSaveName ? GlobalData.Current.UserConfig.UserName : string.Empty;
         cbRemindPassword.Checked = GlobalData.Current.UserConfig.IsSavePassword;
         txtPassword.Text         = GlobalData.Current.UserConfig.IsSavePassword ? GlobalData.Current.UserConfig.Password : string.Empty;
         if (!string.IsNullOrEmpty(GlobalData.Current.UserConfig.SkinName))
         {
             var skin = GlobalData.Current.SkinList.FirstOrDefault(p => p.Name == GlobalData.Current.UserConfig.SkinName);
             GlobalData.Current.SkinEngine.SkinFile = skin != null ? skin.FilePath : string.Empty;
         }
         else
         {
             var skin = GlobalData.Current.SkinList.First();
             GlobalData.Current.SkinEngine.SkinFile = skin != null ? skin.FilePath : string.Empty;
         }
     }
     else
     {
         GlobalData.Current.UserConfig = new UserConfig();
         SQLiteOperate.AddUserConfig(GlobalData.Current.UserConfig);
         var skin = GlobalData.Current.SkinList.First();
         GlobalData.Current.SkinEngine.SkinFile = skin != null ? skin.FilePath : string.Empty;
     }
 }
コード例 #3
0
ファイル: Main.cs プロジェクト: q394304565/Addresslist
        /// <summary>
        /// 皮肤更换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbSkin_SelectedIndexChanged(object sender, EventArgs e)
        {
            var fileInfo = cbSkin.SelectedItem as FileInformation;

            if (fileInfo == null || !IsLoaded)
            {
                return;
            }
            GlobalData.Current.UserConfig.SkinName = fileInfo.Name;
            SQLiteOperate.ModifyUserConfig(GlobalData.Current.UserConfig);
            GlobalData.Current.SkinEngine.SkinFile = fileInfo.FilePath;
        }
コード例 #4
0
ファイル: Login.cs プロジェクト: q394304565/Addresslist
 /// <summary>
 /// 登录
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnLogin_Click(object sender, EventArgs e)
 {
     BLLOperate.CreateAdminUser();
     if (VerifyRequired(txtUName))
     {
         lbMessage.ForeColor = Color.Red;
         lbMessage.Text      = "用户名不能为空";
         return;
     }
     if (VerifyRequired(txtPassword))
     {
         lbMessage.ForeColor = Color.Red;
         lbMessage.Text      = "密码不能为空";
         return;
     }
     HandleData(() =>
     {
         TB_User user = BLLOperate.UserLogin(txtUName.Text, txtPassword.Text);
         if (user != null)
         {
             GlobalData.Current.CurrentUser               = user;
             GlobalData.Current.UserConfig.IsSaveName     = cbRemindName.Checked;
             GlobalData.Current.UserConfig.IsSavePassword = cbRemindPassword.Checked;
             GlobalData.Current.UserConfig.UserName       = txtUName.Text;
             GlobalData.Current.UserConfig.Password       = txtPassword.Text;
             SQLiteOperate.ModifyUserConfig(GlobalData.Current.UserConfig);
             MessageBox.Show(this, string.Format("欢迎{0}登录!", string.IsNullOrEmpty(user.Name) ? user.UName : user.Name));
             Hide();
             var main = new Main();
             main.Show();
         }
         else
         {
             lbMessage.ForeColor = Color.Red;
             lbMessage.Text      = "登录失败,用户名或密码错误";
         }
     }, s =>
     {
         lbMessage.ForeColor = Color.Red;
         lbMessage.Text      = "登录失败,数据访问出错";
     });
 }