コード例 #1
0
        /// <summary>
        /// Inserta un nuevo lote en la base de datos.
        /// </summary>
        /// <param name="newBatch"></param>
        /// Contiene los datos que conforman un lote.
        /// <returns>
        /// Retorna -1 si la sentencia no se ejecuto correctamente.
        /// </returns>
        public static int insertBatch(BatchPOJO newBatch)
        {
            try
            {
                Conexion     con = new Conexion();
                MySqlCommand cmd = new MySqlCommand("INSERT INTO batches VALUES (@P0,@P1,@P2,@P3);");

                cmd.Parameters.AddWithValue("@P0", newBatch.IdBatch);
                cmd.Parameters.AddWithValue("@P1", newBatch.Date);
                cmd.Parameters.AddWithValue("@P2", newBatch.Reason);
                cmd.Parameters.AddWithValue("@P3", newBatch.Quantity);

                return(insertDetailBatch("1000_1", con.ejecutarSentencia(cmd, true)));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(-1);
            }
            finally
            {
                if (Conexion.conexion != null)
                {
                    Conexion.conexion.Close();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Guarda en la base de datos la modificación realizada en las existencias del subartículo.
        /// </summary>
        public void insert(string reason)
        {
            BatchPOJO newBatch = new BatchPOJO();

            newBatch.Date     = DateTime.Now;
            newBatch.Reason   = reason;
            newBatch.Quantity = int.Parse((spnInputOutput.Value) + "");
            BatchDAO.insertBatch(newBatch);
            batchesList = BatchDAO.getAll();
            BatchDAO.insertDetailBatch(selectedSubarticle.IdSubarticle, batchesList[(batchesList.Count) - 1].IdBatch);

            updateQuantity(newBatch.Quantity);
        }