예제 #1
0
        /// <summary>
        /// Checks mandatory fields
        /// </summary>
        /// <returns></returns>
        private bool CheckMandatory()
        {
            if (UserCode_txt.Text == string.Empty)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, UserCode_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                UserCode_txt.Focus();

                return(false);
            }
            if (UserName_txt.Text == string.Empty)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, UserName_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                UserName_txt.Focus();

                return(false);
            }

            if (Password_txt.Text == string.Empty)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, Password_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                Password_txt.Focus();

                return(false);
            }

            if (Country_cmb.Text == string.Empty || Country_cmb.SelectedIndex < 0)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, Country_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                Country_cmb.Focus();

                return(false);
            }
            //if (Language_cmb.Text == string.Empty || Language_cmb.SelectedIndex < 0)
            //{
            //    messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, Language_lbl.Text);
            //    popUpMessage.Warning(messageData, Text);

            //    Language_cmb.Focus();

            //    return false;
            //}
            if (FactoryCode_cmb.Text == string.Empty || FactoryCode_cmb.SelectedIndex < 0)
            {
                messageData = new MessageData("mmce00002", Properties.Resources.mmce00002, FactoryCode_lbl.Text);
                popUpMessage.Warning(messageData, Text);

                FactoryCode_cmb.Focus();

                return(false);
            }
            return(true);
        }
예제 #2
0
        private async void Login_button_Click(object sender, EventArgs e)
        {
            Login_btn.Enabled       = false;
            NewUser_btn.Enabled     = false;
            loading_picture.Visible = true;

            // Build connection string
            NpgsqlConnectionStringBuilder builder = new NpgsqlConnectionStringBuilder();

            builder.Host     = "dbclass.cs.pdx.edu";
            builder.Database = "w19wdb19";
            builder.Username = "******";
            builder.Passfile = GetPassfilePath();
            builder.SslMode  = SslMode.Require;
            builder.TrustServerCertificate = true;

            // Check for password file
            if (builder.Passfile == null)
            {
                MessageBox.Show(@"PostgreSQL password file not found! Please create a password file at %APPDATA%\postgresql\pgpass.conf (where %APPDATA% refers to the Application Data subdirectory in the user's profile).", "ERROR: No password file found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Create connection object
            conn = new NpgsqlConnection(builder.ConnectionString);
            try
            {
                await conn.OpenAsync();

                NpgsqlCommand cmd = new NpgsqlCommand("SELECT COUNT(*) FROM train.user WHERE email = @email AND password = @password", conn);
                cmd.Parameters.AddWithValue("email", email_txt.Text.ToLower());
                cmd.Parameters.AddWithValue("password", Password_txt.Text);

                Int64 count = (Int64)cmd.ExecuteScalar();
                if (count == 1)
                {
                    main_form = new Main_form(conn, email_txt.Text.ToLower());
                    Close();
                    main_form.Show();
                }
                else
                {
                    MessageBox.Show("Wrong credential", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    conn.Close();
                    Password_txt.SelectAll();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to connect to database. Please make sure VPN is enabled and try again.\n" + ex.Message, "ERROR: Unable to connect to database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                conn.Close();
            }
            finally
            {
                Login_btn.Enabled       = true;
                NewUser_btn.Enabled     = true;
                loading_picture.Visible = false;
            }
        }
예제 #3
0
 private void LoginName_txt_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode != Keys.Enter)
     {
         return;
     }
     Password_txt.Select();
 }
예제 #4
0
        //clears the login information and disables all controls on the panel.
        //Used when right username and password is provided in order to transition to the next panel.
        private void LoginClear()
        {
            attempts = 0;
            Username_txt.Clear();
            Password_txt.Clear();
            Username_txt.Enabled            = false;
            Password_txt.Enabled            = false;
            Login_submit.Enabled            = false;
            Incorrect_Login_Warning.Visible = false;
            SignInPage.Visible = false;

            //TODO: delete red outline on textboxes.
        }
예제 #5
0
        /// <summary>
        /// Checks mandatory fields
        /// </summary>
        /// <returns></returns>
        private bool CheckMandatory()
        {
            if (Password_txt.Text == string.Empty)
            {
                messageData = new MessageData("llce00010", Properties.Resources.llce00010.ToString());
                Logger.Info(messageData);
                popUpMessage.Warning(messageData, this.Text);

                Password_txt.Focus();

                return(false);
            }
            if (NewPwd_txt.Text == string.Empty)
            {
                messageData = new MessageData("llce00010", Properties.Resources.llce00010.ToString());
                Logger.Info(messageData);
                popUpMessage.Warning(messageData, this.Text);

                NewPwd_txt.Focus();

                return(false);
            }
            if (ConfPwd_txt.Text == string.Empty)
            {
                messageData = new MessageData("llce00011", Properties.Resources.llce00011.ToString());
                Logger.Info(messageData);
                popUpMessage.Warning(messageData, this.Text);

                ConfPwd_txt.Focus();

                return(false);
            }

            if (NewPwd_txt.Text.Trim() != ConfPwd_txt.Text.Trim())
            {
                messageData = new MessageData("llce00009", Properties.Resources.llce00009.ToString());
                Logger.Info(messageData);
                popUpMessage.Warning(messageData, this.Text);

                ConfPwd_txt.Focus();

                return(false);
            }

            return(true);
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="keyData"></param>
        /// <returns></returns>
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == (Keys.Enter))
            {
                if (this.ActiveControl == LoginName_txt)
                {
                    Password_txt.Focus();
                    return(true);
                }
                else if (this.ActiveControl == Password_txt)
                {
                    Login_btn.PerformClick();
                    return(true);
                }
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
예제 #7
0
 private void Aceptar_btn_Click(object sender, EventArgs e)
 {
     if (User_txt.Text.Length != 0)
     {
         string Usuario  = User_txt.Text;
         string Password = Password_txt.Text;
         bool   Log      = false;
         if (Password_txt.Text.Length != 0)
         {
             Conexiones Conexion = new Conexiones();
             Log = Conexion.Login(Usuario, Password);
             if (Log == true)
             {
                 //usuario anterior administrador rh
                 if (Usuario == "raul")
                 {
                     this.Hide();
                     User_txt.Clear();
                     Password_txt.Clear();
                     frmMenuRH M = new frmMenuRH(1, Usuario);
                     M.Show();
                 }
                 else
                 {
                 }
             }
         }
         else
         {
             MessageBox.Show("Introdusca su contraseña!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     else
     {
         MessageBox.Show("Introdusca su usuario!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
예제 #8
0
        /// <summary>
        /// Checks mandatory fields
        /// </summary>
        /// <returns></returns>
        private bool CheckMandatory()
        {
            if (LoginName_txt.Text == string.Empty)
            {
                messageData = new MessageData("llce00002", Properties.Resources.llce00002.ToString());
                Logger.Info(messageData);
                popUpMessage.ApplicationError(messageData, this.Text);

                LoginName_txt.Focus();

                return(false);
            }
            if (Password_txt.Text == string.Empty)
            {
                messageData = new MessageData("llce00003", Properties.Resources.llce00003.ToString());
                Logger.Info(messageData);
                popUpMessage.ApplicationError(messageData, this.Text);

                Password_txt.Focus();

                return(false);
            }
            return(true);
        }
예제 #9
0
 // Clear button funcionality
 private void ClearBtn_Click(object sender, RoutedEventArgs e)
 {
     Username_txt.Clear();
     Password_txt.Clear();
     Username_txt.Focus();
 }
예제 #10
0
 /// <summary>
 /// login form load
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ChangePasswordForm_Load(object sender, EventArgs e)
 {
     Password_txt.Select();
 }
 private void HidePassword()
 {
     Password_txt.Visibility    = Visibility.Visible;
     VisiblePass_txt.Visibility = Visibility.Hidden;
     Password_txt.Focus();
 }
예제 #12
0
        private void Accept_btn_Click(object sender, EventArgs e)
        {
            try
            {
                if (UserName_txt.Text == "")
                {
                    MessageBox.Show("Please enter your Username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UserName_txt.Focus();
                }
                else if (Password_txt.Text == "")
                {
                    MessageBox.Show("Please enter your Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Password_txt.Focus();
                }
                else if (UserName_txt.Text == "admin" && Password_txt.Text == "admin3092")
                {
                    role = "System Administrator";

                    MessageBox.Show("Welcome " + role, "Congrats", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    Main_Menu mainfrm = new Main_Menu();
                    this.Hide();
                    mainfrm.Show();

                    ((Form)mainfrm).Controls["User_txt"].Text     = role;
                    ((Form)mainfrm).Controls["Username_lbl"].Text = role;
                    ((Form)mainfrm).Controls["Password_lbl"].Text = Convert.ToString(DateTime.Now);


                    connection.Open();
                    OleDbCommand command = connection.CreateCommand();
                    command             = connection.CreateCommand();
                    command.CommandType = CommandType.Text;
                    command.CommandText = "insert into [System_Log_tbl] (Username,Login_DateTime) values ('" + role + "','" + DateTime.Now + "')";
                    command.ExecuteNonQuery();
                    connection.Close();
                }
                else
                {
                    string           query = "Select [Role] FROM [System_Users_tbl] WHERE Username = '******' and Password = '******'";
                    OleDbDataAdapter sda   = new OleDbDataAdapter(query, connection);
                    DataTable        dtbl  = new DataTable();
                    sda.Fill(dtbl);
                    role = dtbl.Rows[0][0].ToString();

                    if (role != "")
                    {
                        MessageBox.Show("Welcome " + role, "Congrats", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        Main_Menu mainfrm = new Main_Menu();
                        this.Hide();
                        mainfrm.Show();

                        ((Form)mainfrm).Controls["User_txt"].Text     = role;
                        ((Form)mainfrm).Controls["Username_lbl"].Text = UserName_txt.Text.Trim();
                        ((Form)mainfrm).Controls["Password_lbl"].Text = Convert.ToString(DateTime.Now);


                        connection.Open();
                        OleDbCommand command = connection.CreateCommand();
                        command.CommandType = CommandType.Text;
                        command.CommandText = "insert into [System_Log_tbl] (Username,Login_DateTime) values ('" + UserName_txt.Text.Trim() + "','" + DateTime.Now + "')";
                        command.ExecuteNonQuery();
                        connection.Close();
                    }
                    else
                    {
                        MessageBox.Show("Username and/or Password is incorrect", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        UserName_txt.Text = "";
                        Password_txt.Text = "";
                        UserName_txt.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Database not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UserName_txt.Text = "";
                Password_txt.Text = "";
                UserName_txt.Focus();
            }
        }
예제 #13
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (Username_txt.Text == "")
                {
                    MessageBox.Show("Username is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Username_txt.Focus();
                }
                else if (Password_txt.Text == "")
                {
                    MessageBox.Show("Password is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Password_txt.Focus();
                }
                else if (Full_Name_txt.Text == "")
                {
                    MessageBox.Show("Role is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Full_Name_txt.Focus();
                }
                else
                {
                    OleDbCommand command = new OleDbCommand
                    {
                        CommandType = CommandType.Text,
                        CommandText = "INSERT INTO [System_Users_tbl] ([Role],[Username],[Password],[Creation_Date],[Accountant])" + "VALUES (?,?,?,?,?)"
                    };
                    command.Parameters.AddWithValue("@Role", Full_Name_txt.Text.Trim());
                    command.Parameters.AddWithValue("@Username", Username_txt.Text.Trim());
                    command.Parameters.AddWithValue("@Password", Password_txt.Text.Trim());
                    command.Parameters.AddWithValue("@Creation_Date", Convert.ToString(User_dateTimePicker.Text.Trim()));
                    command.Parameters.AddWithValue("@Accountant", User_txt.Text.Trim());
                    command.Connection = connection;
                    connection.Open();
                    command.ExecuteNonQuery();
                    connection.Close();

                    MessageBox.Show(Username_txt.Text.Trim() + " is now a System User, with\n" + Full_Name_txt.Text.Trim() + " privillages", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Username_txt.Text         = "";
                    Password_txt.Text         = "";
                    Full_Name_txt.Text        = "";
                    User_dateTimePicker.Value = DateTime.Now;
                    Full_Name_txt.Focus();

                    connection.Open();
                    OleDbCommand ViewCommand = connection.CreateCommand();
                    ViewCommand.CommandType = CommandType.Text;
                    ViewCommand.CommandText = "select * from [System_Users_tbl]";
                    ViewCommand.ExecuteNonQuery();
                    DataTable        dta   = new DataTable();
                    OleDbDataAdapter adapt = new OleDbDataAdapter(ViewCommand);
                    adapt.Fill(dta);
                    Users_dataGridView.DataSource = dta;
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox.Show(ex.StackTrace, "Error Location", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
 private void Password_txt_Click(object sender, EventArgs e)
 {
     Password_txt.Clear();
     Password_txt.ForeColor = Color.Black;
 }