예제 #1
0
 public Update_order(FormMaster f, User u, int order_id)
 {
     InitializeComponent();
     fm            = f;
     this.u        = u;
     this.order_id = order_id;
     Properties.Settings.Default.FlagRole = false;
 }
예제 #2
0
 private void bt_login_Click_1(object sender, EventArgs e)
 {
     try
     {
         Connection = new MySqlConnection(Properties.Settings.Default.ConStr);
         Connection.Open();
         MySqlCommand selectUser = new MySqlCommand("select * from `workers` where `login`='" +
                                                    Crypt.Crypt.Encrypt(tb_login.Text) +
                                                    "' and `password`='" +
                                                    Crypt.Crypt.Encrypt(tb_pass.Text) + "'", Connection);
         MySqlDataReader reader = null;
         reader = selectUser.ExecuteReader();
         bool flag      = false;
         int  user_id   = 0;
         int  user_role = 1;
         while (reader.Read())
         {
             flag      = true;
             user_id   = Convert.ToInt32(reader[0]);
             user_role = Convert.ToInt32(reader[5]);
         }
         if (flag)
         {
             this.Hide();
             Properties.Settings.Default.StartForm = this;
             if (user_role == 1)
             {
                 FormMaster f = new FormMaster(user_id);
                 f.ShowDialog();
             }
             else
             {
                 FormAdmin f = new FormAdmin(user_id);
                 f.ShowDialog();
             }
             l_message.Text = "";
         }
         else
         {
             l_message.Text = "Неверный логин или пароль";
         }
         Connection.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         //MyMessageBox.Show(Owner, ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, 150, 400);
     }
 }