Esempio n. 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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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));
        }
Esempio n. 4
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);
        }
 private void HidePassword()
 {
     Password_txt.Visibility    = Visibility.Visible;
     VisiblePass_txt.Visibility = Visibility.Hidden;
     Password_txt.Focus();
 }
Esempio n. 6
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();
            }
        }
Esempio n. 7
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);
            }
        }