10-01-23, 03:56 AM
كود :
if (ComboBox1.SelectedIndex < 0)
{
MessageBox.Show("الرجاء اختيار اسم المستخدم ");
return;
}
Module1.con.Open();
cmd = new SqlCommand("select *from users where user_name=@user_name and user_password=@user_password", Module1.con);
cmd.Parameters.AddWithValue("@user_name", ComboBox1.Text);
cmd.Parameters.AddWithValue("@user_password", Textpass.Text);
rdr = cmd.ExecuteReader;
rdr.Read();
if (rdr.HasRows())
{
str_username = rdr("user_name").ToString();
var with_1 = Form_main;
with_1.btn_sales.Enabled = rdr("btn_sales").ToString();
with_1.btn_customer.Enabled = rdr("btn_customer").ToString();
with_1.btn_product.Enabled = rdr("btn_product").ToString();
with_1.btn_users.Enabled = rdr("btn_users").ToString();
with_1.btn_con.Enabled = rdr("btn_con").ToString();
with_1.Show();
this.Hide();
}
else
{
MessageBox.Show("كلمة المرور خطأ");
Textpass.Select();
}
rdr.Close();
Module1.con.Close();
