Пример #1
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            datalogin();
            bool cek = false;

            foreach (DataTable table in ds.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (row["name"].ToString() == txt_uname.Text && row["pass"].ToString() == txt_password.Text)
                    {
                        cek = true;
                        MessageBox.Show("Berhasil Login");
                        if (row["Jabatan"].ToString() == "3")
                        {
                            this.Hide();
                            Pilih p = new Pilih();
                            p.form_awal  = this;
                            p.id_jabatan = int.Parse(row["Jabatan"].ToString());
                            p.id_user    = row["name"].ToString();
                            p.user       = this.user;
                            p.namauser   = row["nama"].ToString();
                            this.Hide();
                            p.ShowDialog();
                            this.Show();
                        }
                        else if (row["Jabatan"].ToString() == "2")
                        {
                            this.Hide();
                            pilimanager pm = new pilimanager();
                            pm.form_awal  = this;
                            pm.id_jabatan = int.Parse(row["Jabatan"].ToString());
                            pm.id_user    = row["name"].ToString();
                            pm.user       = this.user;
                            pm.namauser   = row["nama"].ToString();
                            this.Hide();
                            pm.ShowDialog();
                            this.Show();
                        }
                        else
                        {
                            this.Hide();
                            Inventory i = new Inventory();
                            i.id_jabatan    = int.Parse(row["Jabatan"].ToString());
                            i.id_user       = row["name"].ToString();
                            i.form_awal     = this;
                            i.parent        = "awal";
                            i.lbl_nama.Text = row["nama"].ToString();
                            i.Show();
                        }
                    }
                }
            }
            if (cek == false)
            {
                MessageBox.Show("Password / Username Salah");
            }
        }