Exemplo n.º 1
0
        // Вивести ФРУКТОВІ ПОСТАВКИ
        public static List <FruitSupply> getFruitSupply()
        {
            List <FruitSupply> list = new List <FruitSupply>();

            try
            {
                MySqlCommand    command = new MySqlCommand("CALL select_fruitsupply", connect);
                MySqlDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    FruitSupply x = new FruitSupply(reader.GetInt32(0), reader.GetString(1).Remove(10),
                                                    reader.GetInt32(2), reader.GetFloat(4),
                                                    reader.GetInt32(5), reader.GetInt32(7));
                    x.setProductName(reader.GetString(3));
                    x.setShopName(reader.GetString(6));
                    x.setCourierName(reader.GetString(8));
                    list.Add(x);
                }
                reader.Close();
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(list);
        }
Exemplo n.º 2
0
 // Редагувати ФРУКТОВУ ПОСТАВКУ
 public static void updateFruitSupply(FruitSupply x)
 {
     try
     {
         MySqlCommand command = new MySqlCommand("UPDATE fruitsvegetables.fruitsupply SET supplyDate = '" + x.getDate() + "', idProduct = '" + x.getIdProduct() + "', amount = '" + x.getAmount() + "', idShop = '" + x.getIdShop() + "', idCourier = '" + x.getIdCourier() + "' WHERE idSupply = " + x.getIdFruitSupply() + ";", connect);
         command.ExecuteNonQuery();
     }
     catch (MySql.Data.MySqlClient.MySqlException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 3
0
 // Додати ФРУКТОВУ ПОСТАВКУ
 public static void addFruitSupply(FruitSupply x)
 {
     try
     {
         MySqlCommand command = new MySqlCommand("INSERT INTO fruitsvegetables.fruitsupply (`idSupply`, `supplyDate`, `idProduct`, `amount`, `idShop`, `idCourier`) VALUES ( null, '" + x.getDate() + "', '" + x.getIdProduct() + "', '" + x.getAmount() + "', '" + x.getIdShop() + "', '" + x.getIdCourier() + "');", connect);
         command.ExecuteNonQuery();
         MySqlCommand command2 = new MySqlCommand("UPDATE fruitsvegetables.fruits SET amount = (amount - '" + x.getAmount() + "') WHERE idFruits = '" + x.getIdProduct() + "';", connect);
         command2.ExecuteNonQuery();
     }
     catch (MySql.Data.MySqlClient.MySqlException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }