Ejemplo n.º 1
0
        private void login_btn_Click(object sender, EventArgs e) // MANUAL LOGIN
        {
            if (username.Text.Trim() == "")
            {
                MessageBox.Show("PLEASE ENTER YOUR USERNAME !!", "ERROR");
                username.Focus();
                return;
            }

            if (password.Text.Trim() == "")
            {
                MessageBox.Show("PLEASE ENTER YOUR PASSWORD !!", "ERROR");
                password.Focus();
                return;
            }

            String queryString = loginString + @"
            WHERE A.USERNAME LIKE '" + username.Text + @"' 
            AND A.PASSWORD LIKE '" + GF.SHA256_encode(password.Text.Trim()) + @"'
            AND A.IS_USE = 1";

            Dictionary <string, string> Params = new Dictionary <string, string>();

            /*Params.Add("@username", username.Text);
             * Params.Add("@password", GF.SHA256_encode(password.Text.Trim()));*/

            using (DataTable myDT = SPA_MANAGEMENT_SYSTEM.DB.getS(queryString, Params, "LOGIN BY KEY ATTEMPTED", false))
            {
                if (myDT.Rows.Count == 0)
                {
                    // LOGIN FAILED !!
                    MessageBox.Show("LOGIN FAILED !!\r\n\r\nPLEASE CHECK YOUR USERNAME OR PASSWORD.", "ERROR");
                    password.Text = "";
                    password.Focus();
                }
                else
                {
                    //MessageBox.Show("LOGIN SUCCESS !!\r\n\r\nYOU CAN NOW PROCEED.");
                    initMainPage(myDT);
                }
            }
        }