예제 #1
0
        public List<BackorderItem> getBackorderItems(int itemNum)
        {
            List<BackorderItem> backorderItems = new List<BackorderItem>();
            BackorderItem tempBackOrderItem;
            MySqlDataReader reader;
            try
            {
                using (MySqlConnection connection = new MySqlConnection(Helper.ConnectVal("WarehouseDB")))  // establish new db connection
                {
                    using (MySqlCommand cmd = new MySqlCommand("getBackorderItems", connection)) // assign new sql command to db connection and stored procedure
                    {
                        
                        connection.Open();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@itemID", itemNum);
                        cmd.Parameters.Add("@orderNum", MySqlDbType.VarChar, 6);
                        cmd.Parameters["@orderNum"].Direction = ParameterDirection.Output;
                        cmd.Parameters.Add("@reqQty", MySqlDbType.Int32, 5);
                        cmd.Parameters["@reqQty"].Direction = ParameterDirection.Output;
                        cmd.Parameters.Add("@backorderQty", MySqlDbType.Int32, 5);
                        cmd.Parameters["@backorderQty"].Direction = ParameterDirection.Output;
                        reader = cmd.ExecuteReader();

                        while(reader.Read())
                        {
                            tempBackOrderItem = new BackorderItem();
                            tempBackOrderItem.ItemId = itemNum;
                            tempBackOrderItem.OrderNum = (string) reader["@orderNum"];
                            tempBackOrderItem.ReqQty = (int) reader["@reqQty"];
                            tempBackOrderItem.BackorderQty = (int) reader["@backorderQty"];
                            backorderItems.Add(tempBackOrderItem);
                        }

                        connection.Close();
                    }
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {

            }

            return backorderItems;
        }
예제 #2
0
 public void updateBackorderItem(BackorderItem backorderItem)
 {
     try
     {
         using (MySqlConnection connection = new MySqlConnection(Helper.ConnectVal("WarehouseDB")))  // establish new db connection
         {
             using (MySqlCommand cmd = new MySqlCommand("updateBackorderItem", connection)) // assign new sql command to db connection and stored procedure
             {
                 connection.Open();
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.AddWithValue("@orderNum", backorderItem.OrderNum);
                 cmd.Parameters.AddWithValue("@itemID", backorderItem.ItemId);
                 cmd.Parameters.AddWithValue("@reqQty", backorderItem.ReqQty);
                 cmd.Parameters.AddWithValue("@backorderQty", backorderItem.BackorderQty);
                 cmd.ExecuteReader();
                 connection.Close();
             }
         }
     }
     catch(MySql.Data.MySqlClient.MySqlException ex)
     {
         
     }
 }