public string SetLoginData(string userName, string password)
 {
     UserID.Clear();
     PassWord.Clear();
     UserID.SendKeys(userName);
     PassWord.SendKeys(password);
     return(ClickOnLogin());
 }
Beispiel #2
0
        /// <summary>
        /// Login to application
        /// </summary>
        /// <param name="userName">Login user name</param>
        /// <param name="password">Login password</param>
        /// <returns></returns>
        public HomePage Login(string userName, string password)
        {
            UserID.Clear();
            UserID.SendKeys(userName);

            Password.Clear();
            Password.SendKeys(password);

            SubmitButton.Click();

            return(new HomePage());
        }
        private void OK_Click(object sender, EventArgs e)
        {
            try
            {
                OleDbConnection myConnection = default(OleDbConnection);
                myConnection = new OleDbConnection(lblpath.Text);

                OleDbCommand myCommand = default(OleDbCommand);

                myCommand = new OleDbCommand("SELECT USERNAME,PASSWORD FROM LOGIN WHERE USERNAME = @username AND PASSWORD = @UserPassword", myConnection);
                OleDbParameter uName     = new OleDbParameter("@username", OleDbType.VarChar);
                OleDbParameter uPassword = new OleDbParameter("@UserPassword", OleDbType.VarChar);
                uName.Value     = UserID.Text;
                uPassword.Value = Password.Text;
                myCommand.Parameters.Add(uName);
                myCommand.Parameters.Add(uPassword);

                myCommand.Connection.Open();

                OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                if (myReader.Read() == true)
                {
                    this.Hide();
                    MAINFORM frm = new MAINFORM();
                    frm.lblcompanypath.Text = lblpath.Text;
                    frm.lblcompanyname.Text = lblcompanyname.Text;
                    frm.Show();
                    this.Hide();

                    Check_Expiry();
                }


                else
                {
                    MessageBox.Show("Login is Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    UserID.Clear();
                    Password.Clear();
                    UserID.Focus();
                }
                if (myConnection.State == ConnectionState.Open)
                {
                    myConnection.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            LoginHandler loginHandler = new LoginHandler();

            if (ControlCheck())
            {
                if (loginHandler.LoginCheck(UserID.Text, UserPW.Text)) //loginHandler 객체를 통한 아이디 비밀번호 체크
                {
                    string userName = UserID.Text;
                    loginEventHandler(userName);
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Login information is incorrect.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    UserID.Clear();
                    UserPW.Clear();
                }
            }
        }
Beispiel #5
0
        private void submitUser_Click(object sender, EventArgs e)
        {
            if (validateUserID() && validateFirstName() && validateLastName() && validateEmail() && validatePassword() && validateJiraKey() && validateChatChannel())
            {
                string          dataLink     = "datasource=127.0.0.1;port=3306;username=root;password=;database=appadepts";
                MySqlConnection myConnection = new MySqlConnection(dataLink);

                MySqlCommand addUser = new MySqlCommand("INSERT INTO Users (UserID, firstName, lastName, email, password, jiraKey, chatChannel, jiraChannel, shouldLockout) VALUES (@UserID, @firstName, @lastName, @email, @password, @jiraKey, @chatChannel, @jiraChannel, 0)",
                                                        myConnection);

                addUser.Parameters.Add("@UserID", MySqlDbType.VarChar);
                addUser.Parameters.Add("@firstName", MySqlDbType.VarChar);
                addUser.Parameters.Add("@lastName", MySqlDbType.VarChar);
                addUser.Parameters.Add("@email", MySqlDbType.VarChar);
                addUser.Parameters.Add("@password", MySqlDbType.VarChar);
                addUser.Parameters.Add("@jiraKey", MySqlDbType.VarChar);
                addUser.Parameters.Add("@chatChannel", MySqlDbType.VarChar);
                addUser.Parameters.Add("@jiraChannel", MySqlDbType.VarChar);

                addUser.Parameters["@UserID"].Value      = UserID.Text;
                addUser.Parameters["@firstName"].Value   = firstName.Text;
                addUser.Parameters["@lastName"].Value    = lastName.Text;
                addUser.Parameters["@email"].Value       = email.Text;
                addUser.Parameters["@password"].Value    = BCrypt.Net.BCrypt.HashPassword(password.Text);
                addUser.Parameters["@jiraKey"].Value     = jiraKey.Text;
                addUser.Parameters["@chatChannel"].Value = chatChannel.Text;
                addUser.Parameters["@jiraChannel"].Value = chatChannel.Text;

                addUser.Connection.Open();
                addUser.ExecuteReader();
                UserID.Clear();
                firstName.Clear();
                lastName.Clear();
                email.Clear();
                password.Clear();
                jiraKey.Clear();
                chatChannel.Clear();
            }
        }
Beispiel #6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cmbUsertype.Text == "")
            {
                MessageBox.Show("Please select user type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbUsertype.Focus();
                return;
            }
            if (UserID.Text == "")
            {
                MessageBox.Show("Please enter user ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UserID.Focus();
                return;
            }
            if (Password.Text == "")
            {
                MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Password.Focus();
                return;
            }
            try
            {
                con = new SqlConnection(cs.DBcon);
                con.Open();
                cmd             = con.CreateCommand();
                cmd.CommandText = "SELECT RTRIM(UserID),RTRIM(Password) FROM User_Registration where UserID = @d1 and Password=@d2";
                cmd.Parameters.AddWithValue("@d1", UserID.Text);
                cmd.Parameters.AddWithValue("@d2", Password.Text);
                rdr = cmd.ExecuteReader();
                if (rdr.Read())
                {
                    con = new SqlConnection(cs.DBcon);
                    con.Open();
                    cmd             = con.CreateCommand();
                    cmd.CommandText = "SELECT usertype FROM User_Registration where UserID=@d3 and Password=@d4";
                    cmd.Parameters.AddWithValue("@d3", UserID.Text);
                    cmd.Parameters.AddWithValue("@d4", Password.Text);
                    rdr = cmd.ExecuteReader();
                    if (rdr.Read())
                    {
                        cmbUsertype.Text = rdr.GetValue(0).ToString().Trim();
                    }
                    if ((rdr != null))
                    {
                        rdr.Close();
                    }
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }


                    if (cmbUsertype.Text == "Librarian")
                    {
                        this.Hide();
                        Librarian_Window frm = new Librarian_Window();
                        frm.User.Text     = UserID.Text;
                        frm.UserType.Text = cmbUsertype.Text;
                        frm.Show();

                        ProgressBar1.Visible = true;
                        ProgressBar1.Maximum = 5000;
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Value   = 4;
                        ProgressBar1.Step    = 1;
                        for (int i = 0; i <= 5000; i++)
                        {
                            ProgressBar1.PerformStep();
                        }
                    }
                    if (cmbUsertype.Text == "Account Officer")
                    {
                        this.Hide();
                        Account_Officer_Window frm = new Account_Officer_Window();
                        frm.User.Text     = UserID.Text;
                        frm.UserType.Text = cmbUsertype.Text;
                        frm.Show();

                        ProgressBar1.Visible = true;
                        ProgressBar1.Maximum = 5000;
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Value   = 4;
                        ProgressBar1.Step    = 1;
                        for (int i = 0; i <= 5000; i++)
                        {
                            ProgressBar1.PerformStep();
                        }

                        /*st1 = UserID.Text;
                         * st2 = "Successfully logged in";
                         * cf.LogFunc(st1, System.DateTime.Now, st2);
                         * this.Hide();
                         * frm.Show();*/
                    }


                    if (cmbUsertype.Text == "Admin")
                    {
                        this.Hide();
                        frm_Main_Menu frm = new frm_Main_Menu();
                        //frm.User.Text = txtUserName.Text;
                        frm.User.Text     = UserID.Text;
                        frm.UserType.Text = cmbUsertype.Text;
                        frm.Show();
                        // frm.registrationToolStripMenuItem2.Enabled = true;
                        frm.studentDetailsToolStripMenuItem.Enabled = true;

                        frm.hostelersToolStripMenuItem.Enabled  = true;
                        frm.busHoldersToolStripMenuItem.Enabled = true;


                        frm.Master_entryMenu.Enabled             = true;
                        frm.usersToolStripMenuItem.Enabled       = true;
                        frm.studentToolStripMenuItem.Enabled     = true;
                        frm.employeeToolStripMenuItem.Enabled    = true;
                        frm.transactionToolStripMenuItem.Enabled = true;
                        frm.searchToolStripMenuItem.Enabled      = true;
                        frm.reportToolStripMenuItem.Enabled      = true;


                        frm.busFeePaymentToolStripMenuItem2.Enabled     = true;
                        frm.feePaymentToolStripMenuItem.Enabled         = true;
                        frm.employeeSalaryToolStripMenuItem.Enabled     = true;
                        frm.hostelFeesPaymentToolStripMenuItem.Enabled  = true;
                        frm.scholarshipPaymentToolStripMenuItem.Enabled = true;
                        ProgressBar1.Visible = true;
                        ProgressBar1.Maximum = 5000;
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Value   = 4;
                        ProgressBar1.Step    = 1;
                        for (int i = 0; i <= 5000; i++)
                        {
                            ProgressBar1.PerformStep();
                        }
                        st1 = UserID.Text;
                        st2 = "Successfully logged in";
                        cf.LogFunc(st1, System.DateTime.Now, st2);
                        this.Hide();
                        frm.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Login Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    UserID.Clear();
                    Password.Clear();
                    UserID.Focus();
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #7
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            if (UserID.Text == "")
            {
                MessageBox.Show("Please enter user ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UserID.Focus();
                return;
            }
            if (Password.Text == "")
            {
                MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Password.Focus();
                return;
            }
            try
            {
                SQLConn.ConnOpen();



                SQLConn.cmd             = SQLConn.conn.CreateCommand();
                SQLConn.cmd.CommandText = "SELECT userid,password,name, usertype  FROM user_registration where userid = @d1 and password=@d2";
                SQLConn.cmd.Parameters.AddWithValue("@d1", UserID.Text);
                SQLConn.cmd.Parameters.AddWithValue("@d2", Password.Text);
                SQLConn.dr = SQLConn.cmd.ExecuteReader();
                if (SQLConn.dr.Read())
                {
                    SQLConn.USERNAME = SQLConn.dr["name"].ToString();
                    SQLConn.USERID   = SQLConn.dr["userid"].ToString();
                    SQLConn.USERTYPE = SQLConn.dr["usertype"].ToString();


                    if ((SQLConn.dr != null))
                    {
                        SQLConn.dr.Close();
                    }
                    SQLConn.ConnClose();



                    switch (SQLConn.USERTYPE)
                    {
                    case "Librarian":

                        Librarian_Window frm = new Librarian_Window();

                        frm.UserType.Text = SQLConn.USERTYPE;
                        frm.Show();

                        //    }
                        //    if (cmbUsertype.Text == "Account Officer")
                        //    {
                        //        this.Hide();
                        //        Account_Officer_Window frm = new Account_Officer_Window();
                        //        frm.User.Text = UserID.Text;
                        //        frm.UserType.Text = cmbUsertype.Text;
                        //        frm.Show();

                        //        ProgressBar1.Visible = true;
                        //        ProgressBar1.Maximum = 5000;
                        //        ProgressBar1.Minimum = 0;
                        //        ProgressBar1.Value = 4;
                        //        ProgressBar1.Step = 1;
                        //        for (int i = 0; i <= 5000; i++)
                        //        {
                        //            ProgressBar1.PerformStep();
                        //        }
                        //        /*st1 = UserID.Text;
                        //        st2 = "Successfully logged in";
                        //        cf.LogFunc(st1, System.DateTime.Now, st2);
                        //        this.Hide();
                        //        frm.Show();*/

                        //    }

                        break;

                    case "Admin":

                        this.Hide();
                        frmMain frmadmin = new frmMain();
                        frmadmin.Show();

                        ////        //frm.User.Text = txtUserName.Text;
                        ////        frm.User.Text = UserID.Text;
                        ////        frm.UserType.Text = cmbUsertype.Text;
                        ////        frm.Show();
                        ////        // frm.registrationToolStripMenuItem2.Enabled = true;
                        ////        frm.studentDetailsToolStripMenuItem.Enabled = true;

                        ////        frm.hostelersToolStripMenuItem.Enabled = true;
                        ////        frm.busHoldersToolStripMenuItem.Enabled = true;


                        ////        frm.Master_entryMenu.Enabled = true;
                        ////        frm.usersToolStripMenuItem.Enabled = true;
                        ////        frm.studentToolStripMenuItem.Enabled = true;
                        ////        frm.employeeToolStripMenuItem.Enabled = true;
                        ////        frm.transactionToolStripMenuItem.Enabled = true;
                        ////        frm.searchToolStripMenuItem.Enabled = true;
                        ////        frm.reportToolStripMenuItem.Enabled = true;


                        ////        frm.busFeePaymentToolStripMenuItem2.Enabled = true;
                        ////        frm.feePaymentToolStripMenuItem.Enabled = true;
                        ////        frm.employeeSalaryToolStripMenuItem.Enabled = true;
                        ////        frm.hostelFeesPaymentToolStripMenuItem.Enabled = true;
                        ////        frm.scholarshipPaymentToolStripMenuItem.Enabled = true;

                        ////        st1 = UserID.Text;
                        ////        st2 = "Successfully logged in";
                        ////        //  cf.LogFunc(st1, System.DateTime.Now, st2);

                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Login Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UserID.Clear();
                    UserID.BackColor = Color.MidnightBlue;
                    Password.Clear();
                    Password.BackColor = Color.MidnightBlue;
                    UserID.Focus();
                }
            }
            catch (NpgsqlException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            finally
            {
                SQLConn.cmd.Dispose();
                SQLConn.ConnClose();
            }
        }
Beispiel #8
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (UserID.Text == "")
            {
                MessageBox.Show("Please enter user ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UserID.Focus();
                return;
            }
            if (Password.Text == "")
            {
                MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Password.Focus();
                return;
            }
            try
            {
                con = new SqlConnection(cs.DBcon);
                con.Open();
                cmd             = con.CreateCommand();
                cmd.CommandText = "SELECT RTRIM(UserID),RTRIM(Password) FROM User_Registration where UserID=@d1 and Password=@d2 union Select RTRIM(UserID),RTRIM(Password) from Client where UserID = @d1 and Password=@d2";
                cmd.Parameters.AddWithValue("@d1", UserID.Text);
                cmd.Parameters.AddWithValue("@d2", Password.Text);
                rdr = cmd.ExecuteReader();
                if (rdr.Read())
                {
                    con = new SqlConnection(cs.DBcon);
                    con.Open();
                    cmd             = con.CreateCommand();
                    cmd.CommandText = "SELECT usertype FROM User_Registration where UserID=@d3 and Password=@d4";
                    cmd.Parameters.AddWithValue("@d3", UserID.Text);
                    cmd.Parameters.AddWithValue("@d4", Password.Text);
                    rdr = cmd.ExecuteReader();
                    if (rdr.Read())
                    {
                        cmbUsertype.Text = rdr.GetValue(0).ToString().Trim();
                    }
                    if ((rdr != null))
                    {
                        rdr.Close();
                    }
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }

                    progressBar1.Visible = true;
                    progressBar1.Maximum = 5000;
                    progressBar1.Minimum = 0;
                    progressBar1.Value   = 4;
                    progressBar1.Step    = 1;
                    for (int i = 0; i <= 5000; i++)
                    {
                        progressBar1.PerformStep();
                    }

                    this.Hide();
                    frmMainMenu frm1 = new frmMainMenu();
                    frm1.User.Text = UserID.Text;
                    frm1.Show();
                    st1 = UserID.Text;
                    st2 = "Successfully logged in";
                    cf.LogFunc(st1, System.DateTime.Now, st2);
                }
                else
                {
                    MessageBox.Show("Login Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    UserID.Clear();
                    Password.Clear();
                    UserID.Focus();
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void UpdateSM_Click(object sender, EventArgs e)
 {
     if (radioButton1.Checked)
     {
         if (Admin.Authenticate(textBox1.Text))
         {
             string imgloc;
             if (IsImgUploaded)
             {
                 imgloc = Admin.SaveImage(o1.FileName);
                 Admin.UpdateShopManagerAccount(ShopManager.Text, textBox2.Text, ContactNumber.Text, Address.Text, imgloc);
                 ShopManager.Clear();
                 UserID.Clear();
                 textBox1.Clear();
                 textBox2.Clear();
                 ContactNumber.Clear();
                 Address.Clear();
                 Date.Text            = "";
                 pictureBox1.Image    = pictureBox1.InitialImage;
                 radioButton1.Checked = false;
                 radioButton2.Checked = false;
             }
             else
             {
                 imgloc = pictureBox1.ImageLocation;
                 Admin.UpdateShopManagerAccount(ShopManager.Text, textBox2.Text, ContactNumber.Text, Address.Text, imgloc);
                 ShopManager.Clear();
                 UserID.Clear();
                 textBox1.Clear();
                 textBox2.Clear();
                 ContactNumber.Clear();
                 Address.Clear();
                 Date.Text            = "";
                 pictureBox1.Image    = pictureBox1.InitialImage;
                 radioButton1.Checked = false;
                 radioButton2.Checked = false;
             }
         }
         else
         {
             MessageBox.Show("Wrong Current Password");
         }
     }
     else
     {
         string imgloc;
         if (IsImgUploaded)
         {
             imgloc = Admin.SaveImage(o1.FileName);
             Admin.UpdateShopManagerAccount(ShopManager.Text, ContactNumber.Text, Address.Text, imgloc);
             ShopManager.Clear();
             UserID.Clear();
             textBox1.Clear();
             textBox2.Clear();
             ContactNumber.Clear();
             Address.Clear();
             Date.Text            = "";
             pictureBox1.Image    = pictureBox1.InitialImage;
             radioButton1.Checked = false;
             radioButton2.Checked = false;
         }
         else
         {
             imgloc = pictureBox1.ImageLocation;
             Admin.UpdateShopManagerAccount(ShopManager.Text, ContactNumber.Text, Address.Text, imgloc);
             ShopManager.Clear();
             UserID.Clear();
             textBox1.Clear();
             textBox2.Clear();
             ContactNumber.Clear();
             Address.Clear();
             Date.Text            = "";
             pictureBox1.Image    = pictureBox1.InitialImage;
             radioButton1.Checked = false;
             radioButton2.Checked = false;
         }
     }
 }
Beispiel #10
0
        //--------------------------------------ON SAVE CONNECTION DATA FUNCTION-------------------------------------
        private void Submit_Click(object sender, RoutedEventArgs e)  //function to save the data used for the connection
        {
            Boolean ipchecked = true;
            string  srvAdd, dbname, user, dbpasswd, admin, dbport;

            srvAdd   = ServerAddress.Text;
            dbname   = DBName.Text;
            user     = UserID.Text;
            dbpasswd = UserPasswd.Password.ToString();
            admin    = AdminCredentials.Password.ToString();
            dbport   = Port.Text;
            //CHECKING IF THE FIELDS ARE ALL FILLED
            if (String.IsNullOrWhiteSpace(srvAdd) == true || String.IsNullOrWhiteSpace(dbname) == true || String.IsNullOrWhiteSpace(user) == true || String.IsNullOrWhiteSpace(dbport) == true)
            {
                MessageBox.Show("Please fill all the required fields", "Error", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
            else if (!srvAdd.Equals("localhost"))//IF THE SERVER ADDRESS IS NOT THE LOCALHOST -> CHECK IF IT IS A VALID IP
            {
                ipchecked = CheckIPValid(srvAdd);
                if (ipchecked == false)
                {
                    MessageBox.Show("Please enter a valid IP", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else if (admin.Equals(Properties.Resources.adminpasswd.ToString()) && ipchecked == true) //CHECKING ADMINS PASSWORD
                {
                    Properties.dbSettings.Default.datasource = srvAdd;                                   //save the checkobox data into the programs settings
                    Properties.dbSettings.Default.database   = dbname;
                    Properties.dbSettings.Default.username   = user;
                    Properties.dbSettings.Default.password   = dbpasswd;
                    Properties.dbSettings.Default.port       = dbport;
                    Properties.dbSettings.Default.Save();
                    MessageBox.Show("Changes saved successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                    ShowStoredValues();

                    ServerAddress.Clear();
                    DBName.Clear();
                    UserID.Clear();
                    UserPasswd.Clear();
                    AdminCredentials.Clear();
                    Port.Clear();
                }
                else
                {
                    MessageBox.Show("You must enter admins password", "Error", MessageBoxButton.OK, MessageBoxImage.Stop);
                }
            }
            else if (srvAdd.Equals("localhost"))//IF THE SERVER ADDRESS IS THE LOCALHOST THEN CHECK FOR ADMINS PASSWORD
            {
                if (admin.Equals(Properties.Resources.adminpasswd.ToString()))
                {
                    Properties.dbSettings.Default.datasource = srvAdd;     //save the checkobox data into the programs settings
                    Properties.dbSettings.Default.database   = dbname;
                    Properties.dbSettings.Default.username   = user;
                    Properties.dbSettings.Default.password   = dbpasswd;
                    Properties.dbSettings.Default.port       = dbport;
                    Properties.dbSettings.Default.Save();
                    MessageBox.Show("Changes saved successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                    ShowStoredValues();
                    ServerAddress.Clear();
                    DBName.Clear();
                    UserID.Clear();
                    UserPasswd.Clear();
                    AdminCredentials.Clear();
                    Port.Clear();
                }
                else
                {
                    MessageBox.Show("You must enter a valid admins password", "Error", MessageBoxButton.OK, MessageBoxImage.Stop);
                }
            }
        }