コード例 #1
0
        // Вивести ОВОЧЕВІ ПОСТАВКИ
        public static List <VegetableSupply> getVegetableSupply()
        {
            List <VegetableSupply> list = new List <VegetableSupply>();

            try
            {
                MySqlCommand    command = new MySqlCommand("CALL select_vegetablesupply", connect);
                MySqlDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    VegetableSupply x = new VegetableSupply(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);
        }
コード例 #2
0
 // Редагувати ОВОЧЕВУ ПОСТАВКУ
 public static void updateVegetableSupply(VegetableSupply x)
 {
     try
     {
         MySqlCommand command = new MySqlCommand("UPDATE fruitsvegetables.vegetablesupply SET supplyDate = '" + x.getDate() + "', idProduct = '" + x.getIdProduct() + "', amount = '" + x.getAmount() + "', idShop = '" + x.getIdShop() + "', idCourier = '" + x.getIdCourier() + "' WHERE idSupply = " + x.getIdVegetableSupply() + ";", connect);
         command.ExecuteNonQuery();
     }
     catch (MySql.Data.MySqlClient.MySqlException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #3
0
 // Додати ОВОЧЕВУ ПОСТАВКУ
 public static void addVegetableSupply(VegetableSupply x)
 {
     try
     {
         MySqlCommand command = new MySqlCommand("INSERT INTO fruitsvegetables.vegetablesupply (`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.vegetables SET amount = (amount - '" + x.getAmount() + "') WHERE idVegetables = '" + x.getIdProduct() + "';", connect);
         command2.ExecuteNonQuery();
     }
     catch (MySql.Data.MySqlClient.MySqlException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }