Exemple #1
0
 private void btnRemove_Click(object sender, EventArgs e)
 {
     if (lbShops.SelectedIndex != -1)
     {
         using (DBHelper helper = new DBHelper())
         {
             MySqlCommand command = new MySqlCommand("DELETE FROM ml_stand WHERE id = @stand_id", helper.GetConnection());
             command.Parameters.AddWithValue("@stand_id", lbShops.SelectedValue);
             helper.Open();
             if (command.ExecuteNonQuery() == 1)
             {
                 DirectMessage.ShowInfo("Shop removed successfully.");
                 UpdateShops();
             }
             else
             {
                 DirectMessage.ShowError("Something went wrong.");
             }
         }
     }
     else
     {
         DirectMessage.ShowError("You have to select a shop.");
     }
 }
Exemple #2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (tbxName.Text != "")
     {
         string type = "";
         if (rbtnShop.Checked)
         {
             type = "shop";
         }
         else
         {
             type = "loan_stand";
         }
         using (DBHelper helper = new DBHelper())
         {
             try
             {
                 MySqlCommand command = new MySqlCommand("INSERT INTO ml_stand (name, type) VALUES (@name, @type);", helper.GetConnection());
                 command.Parameters.AddWithValue("@name", tbxName.Text);
                 command.Parameters.AddWithValue("@type", type);
                 helper.Open();
                 if (command.ExecuteNonQuery() == 1)
                 {
                     DirectMessage.ShowInfo("Shop added successfully.");
                     UpdateShops();
                 }
                 else
                 {
                     DirectMessage.ShowError("Something went wrong.");
                 }
             }
             catch (MySqlException)
             {
                 DirectMessage.ShowError("There was problem executing the operation.");
             }
         }
     }
     else
     {
         DirectMessage.ShowError("You have to fill in a name.");
     }
 }
Exemple #3
0
 private void btnRefresh_Click(object sender, EventArgs e)
 {
     UpdateShops();
     DirectMessage.ShowInfo("Successfully updated.");
 }