コード例 #1
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(this.ConfirmedPassword) || string.IsNullOrEmpty(this.Password))
     {
         MetroMessageBox.Show(this, English.InvalidPassword, "Error", 120);
     }
     else if (this.ConfirmedPassword != this.Password)
     {
         MetroMessageBox.Show(this, English.PasswordsMismatch, "Error", 120);
     }
     else
     if (FileMinapulation.WritePassword(User.hashPassword(this.Password)) == true)
     {
         MetroMessageBox.Show(this, English.Updated, "Success", 120);
         Login loginForm = new Login();
         loginForm.Width         = this.Width;
         loginForm.Height        = this.Height;
         loginForm.StartPosition = FormStartPosition.Manual;
         loginForm.Location      = new Point(this.Location.X, this.Location.Y);
         this.Hide();
         loginForm.ShowDialog();
     }
     else
     {
         MetroMessageBox.Show(this, English.UpdateError, "Error", 120);
     }
 }
コード例 #2
0
        private void mBtnLogin_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.Username) || string.IsNullOrEmpty(this.Password))
            {
                MetroMessageBox.Show(this, English.InvalidUsernameOrpassword, "Error", 120);
            }
            else
            {
                User validUser = FileMinapulation.ReadUserNameAndPassword();

                if (validUser == null)
                {
                    MetroMessageBox.Show(this, English.FileNotFound, "Error", 120);
                }
                else
                {
                    if (this.Username.ToLower() == validUser.Username.ToLower() &&
                        User.hashPassword(this.Password) == validUser.Password)
                    {
                        Welcome welcomeForm = new Welcome();
                        welcomeForm.Width         = this.Width;
                        welcomeForm.Height        = this.Height;
                        welcomeForm.StartPosition = FormStartPosition.Manual;
                        welcomeForm.Location      = new Point(this.Location.X, this.Location.Y);
                        this.Hide();
                        welcomeForm.ShowDialog();
                    }
                    else
                    {
                        MetroMessageBox.Show(this, English.NotFoundCredentials, "Error", 120);
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Formats exception to a readable string and logs is to exceptions file
        /// </summary>
        /// <param name="ex"></param>
        public static void Log(Exception ex)
        {
            string exceptionMsg = "Message :" + ex.Message + " " + Environment.NewLine + "StackTrace :" + ex.StackTrace +
                                  "" + Environment.NewLine + "Date :" + DateTime.Now.ToString();

            Console.WriteLine(exceptionMsg);
            FileMinapulation.WriteException(exceptionMsg);
        }
コード例 #4
0
 /// <summary>
 /// Logs a string to exceptions file
 /// </summary>
 /// <param name="issue"></param>
 public static void Log(string issue)
 {
     Console.WriteLine(issue);
     FileMinapulation.WriteException(issue + " " + "Date :" + DateTime.Now.ToString());
 }