Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txt_user.Text == "" && txt_password.Text == "")
            {
                MessageBox.Show("Harap Isi Username Dan Password");
            }
            else
            {
                SqlConnection conn = new SqlConnection(ukom.Properties.Resources.conn.ToString());
                conn.Open();
                String        username = txt_user.Text;
                String        Password = txt_password.Text;
                SqlCommand    da       = new SqlCommand("select * from [dbo].[user] where namauser ='******' and password='******'", conn);
                DataTable     dt       = new DataTable();
                SqlDataReader myReader;
                myReader = da.ExecuteReader();
                int    count = 0;
                string role  = string.Empty;
                while (myReader.Read())
                {
                    count = count + 1;
                    role  = myReader["role"].ToString();
                }
                if (count == 1)
                {
                    MessageBox.Show("Username Dan Password . . . Benar", "Pesan Konfirmasi", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.Hide();

                    //admin with generated key
                    if (role == "admin")
                    {
                        this.Hide();
                        admin parse = new admin(username);
                        parse.Show();
                    }
                    else if (role == "waiter")
                    {
                        this.Hide();
                        waiter parse = new waiter(username);
                        parse.Show();
                    }
                    else if (role == "kasir")
                    {
                        this.Hide();
                        kasir parse = new kasir(username);
                        parse.Show();
                    }
                    else if (role == "owner")
                    {
                        this.Hide();
                        owner parse = new owner(username);
                        parse.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Username Atau Password Tidak Ditemukan");
                }
            }
        }
Esempio n. 2
0
 private void dlog()
 {
     if (textBox1.Text.ToString().Length == 12)
     {
         string id  = textBox1.Text.ToString();
         string pwd = textBox2.Text.ToString();
         dbsc   d0  = new dbsc();
         d0.OpenConnection();
         StringBuilder sb = new StringBuilder();
         sb.AppendLine("declare @pwd0 varchar");
         sb.AppendFormat("select @pwd0=[pwd] from [Pinfo] where [pdrivingno]='{0}'", id);
         sb.AppendLine();
         sb.AppendLine("if @pwd0 is null");
         sb.AppendFormat("select [idcard] from [Pinfo] where [pdrivingno]='{0}'", id);
         sb.AppendLine();
         sb.AppendLine("else");
         sb.AppendFormat("select [pwd] from [Pinfo] where [pdrivingno]='{0}'", id);
         SqlCommand cmd  = new SqlCommand(sb.ToString(), d0.Connection);
         string     pwd0 = cmd.ExecuteScalar().ToString();
         d0.CloseConnection();
         if (pwd.Equals(pwd0) || pwd.Equals(pwd0.Substring(pwd0.Length - 6, 6)))
         {
             MessageBox.Show("登录成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             owner o1 = new owner(this.FindForm(), id);
             o1.Show();
             this.Hide();
         }
         else
         {
             MessageBox.Show("用户名或密码错误!", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("账号为12位驾驶证号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         textBox1.Focus();
     }
 }