private void login()
        {
            DataTable table = new DataTable();

            table = log.login(TB_USERNAME.Text, TB_PASSWORD.Text);
            if (table.Rows.Count > 0)
            {
                //if the user is admin
                // => hide the current form and show the home form
                if (table.Rows[0][3].ToString() == "admin")
                {
                    //this.Hide();
                    FORM_HOME FH = new FORM_HOME(true, TB_USERNAME.Text, TB_PASSWORD.Text, "admin", table.Rows[0][4].ToString(), table.Rows[0][5].ToString(), table.Rows[0][6].ToString(), Convert.ToInt32(table.Rows[0][0]));
                    FH.Closed += (s, args) => this.Close();
                    FH.Show();
                    this.Visible = false;
                }
                //else the user is not an admin
                // => hide the current form and show the home form
                // => and don't show the user tab
                // => a simple user cannot see the user tab
                else
                {
                    this.Hide();
                    FORM_HOME FH = new FORM_HOME(false, TB_USERNAME.Text, TB_PASSWORD.Text, table.Rows[0][2].ToString(), "user", table.Rows[0][4].ToString(), table.Rows[0][5].ToString(), Convert.ToInt32(table.Rows[0][0]));
                    FH.Closed += (s, args) => this.Close();
                    //FH.userToolStripMenuItem.Visible = false;
                    FH.Show();
                }
            }
            else
            {
                MessageBox.Show("Username Or Password Are Incorrect");
            }
        }
Exemple #2
0
        // login
        private void PANEL_LOGIN_Click(object sender, EventArgs e)
        {
            DataTable table = new DataTable();

            table = log.login(TB_USERNAME.Text, TB_PASSWORD.Text);
            if (table.Rows.Count > 0)
            {
                //if the user is admin
                // => hide the current form and show the home form
                if (table.Rows[0][3].ToString() == "admin")
                {
                    this.Hide();
                    FORM_HOME FH = new FORM_HOME();
                    FH.Closed += (s, args) => this.Close();
                    FH.Show();
                }
                //else the user is not an admin
                // => hide the current form and show the home form
                // => and don't show the user tab
                // => a simple user cannot see the user tab
                else
                {
                    this.Hide();
                    FORM_HOME FH = new FORM_HOME();
                    FH.Closed += (s, args) => this.Close();
                    FH.userToolStripMenuItem.Visible = false;
                    FH.Show();
                }
            }
            else
            {
                MessageBox.Show("le Nom_Utulisateur ou le mots de passwords est incorrect");
            }
        }
        private void PANEL_LOGIN_Click(object sender, EventArgs e)
        {
            DataTable table = new DataTable();

            table = log.login(TB_USERNAME.Text, TB_PASSWORD.Text);
            if (table.Rows.Count > 0)
            {
                if (table.Rows[0][3].ToString() == "admin")
                {
                    this.Hide();
                    FORM_HOME FH = new FORM_HOME();
                    FH.Closed += (s, args) => this.Close();
                    FH.Show();
                }
                else
                {
                    this.Hide();
                    FORM_HOME FH = new FORM_HOME();
                    FH.Closed += (s, args) => this.Close();
                    FH.userToolStripMenuItem.Visible = false;
                    FH.Show();
                }
            }
            else
            {
                MessageBox.Show("Netocno korisnicko ime ili lozinka");
            }
        }
        // login
        private void PANEL_LOGIN_Click(object sender, EventArgs e)
        {
            DataTable table = new DataTable();

            table = log.login(TB_USERNAME.Text, TB_PASSWORD.Text);
            if (table.Rows.Count > 0)
            {
                //if the user is admin
                // => hide the current form and show the home form
                if (table.Rows[0][7].ToString() == "Admin")
                {
                    loggedInUser = table.Rows[0][1].ToString();

                    this.Hide();
                    FORM_HOME FH = new FORM_HOME(loggedInUser);
                    FH.Closed += (s, args) => this.Close();
                    FH.Show();
                }
                //else the user is not an admin
                // => hide the current form and show the home form
                // => and don't show the user tab
                // => a simple user cannot see the user tab
                else
                {
                    loggedInUser = table.Rows[0][1].ToString();
                    this.Hide();
                    FORM_HOME FH = new FORM_HOME(loggedInUser);
                    FH.Closed += (s, args) => this.Close();
                    FH.userToolStripMenuItem.Visible = false;


                    FH.userToolStripMenuItem.Visible      = false;
                    FH.productToolStripMenuItem.Visible   = false;
                    FH.orderToolStripMenuItem.Visible     = false;
                    FH.customerToolStripMenuItem.Visible  = false;
                    FH.categorieToolStripMenuItem.Visible = false;



                    FH.Show();
                }
            }
            else
            {
                MessageBox.Show("Username Or Password Are Incorrect");
            }
        }