示例#1
0
        private void lendingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Hide();
            frm_lending lending = new frm_lending();

            lending.ShowDialog();
        }
示例#2
0
        private void btn_sub_Click(object sender, EventArgs e)
        {
            String un = txt_un.Text.Replace("'", "");

            un = un.Replace("\"", "");
            String pw = sha256(txt_pw.Text);

            if (un != "" && pw != "")
            {
                DataTable    dt_login = new DataTable();
                String       sql      = "SELECT * FROM login WHERE usr_un='" + un + "' AND usr_pw='" + pw + "'";
                MySqlCommand cmd      = new MySqlCommand(sql, conman.connection());
                using (MySqlDataAdapter da_login = new MySqlDataAdapter(cmd))
                {
                    da_login.Fill(dt_login);
                }

                int rowcount = dt_login.Rows.Count;
                if (rowcount > 0)
                {
                    foreach (DataRow row in dt_login.Rows)
                    {
                        pos = row["usr_pos"].ToString();
                    }

                    if (pos == "admin")
                    {
                        this.Hide();
                        frm_admin admin = new frm_admin();
                        admin.ShowDialog();
                    }
                    else if (pos == "Lending")
                    {
                        this.Hide();
                        frm_lending lending = new frm_lending();
                        lending.ShowDialog();
                    }
                    else if (pos == "Reference")
                    {
                        this.Hide();
                        frm_reference reference = new frm_reference();
                        reference.ShowDialog();
                    }
                    else if (pos == "Magazines_Newspapers")
                    {
                        this.Hide();
                        frm_MnN MnN = new frm_MnN();
                        MnN.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Invalid user !", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Incorrect username or password ! \nPlease try again....", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Please Enter your username and password !", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }