Exemple #1
0
        //Metodo insertar detalle de ingreso
        public string InsertarDetalleIngreso(E_Detalle_Ingreso DetalleIngreso, ref SqlConnection Connection, ref SqlTransaction transaction)
        {
            string Rpta;

            try
            {
                SqlCommand SqlCmd = new SqlCommand("sp_insertar_detalle_ingreso", Connection)
                {
                    CommandType = CommandType.StoredProcedure,
                    Transaction = transaction
                };

                SqlCmd.Parameters.AddWithValue("@id_ingreso", DetalleIngreso.Id_ingreso);
                SqlCmd.Parameters.AddWithValue("@id_producto", DetalleIngreso.Id_producto);
                SqlCmd.Parameters.AddWithValue("@precio_compra", DetalleIngreso.Precio_compra);
                SqlCmd.Parameters.AddWithValue("@precio_venta", DetalleIngreso.Precio_venta);
                SqlCmd.Parameters.AddWithValue("@stock_inicial", DetalleIngreso.Stock_inicial);
                SqlCmd.Parameters.AddWithValue("@stock_actual", DetalleIngreso.Stock_actual);
                SqlCmd.Parameters.AddWithValue("@fecha_produccion", DetalleIngreso.Fecha_produccion);
                SqlCmd.Parameters.AddWithValue("@fecha_vence", DetalleIngreso.Fecha_vence);

                Rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "No se puede ingresar detalle de ingreso";
            }
            catch (Exception ex)
            {
                Rpta = "ERROR" + ex.Message + ex.StackTrace;
            }
            return(Rpta);
        }
Exemple #2
0
        //Metodo insertar
        public static string InsertarIngreso(E_Ingreso Ingreso, DataTable DTDetalleIngreso)
        {
            D_Ingreso ObjIngreso = new D_Ingreso();
            List <E_Detalle_Ingreso> detalles = new List <E_Detalle_Ingreso>();

            foreach (DataRow row in DTDetalleIngreso.Rows)
            {
                E_Detalle_Ingreso e_Detalle_Ingreso = new E_Detalle_Ingreso()
                {
                    Id_producto      = Convert.ToInt32(row["id_producto"].ToString()),
                    Precio_compra    = Convert.ToDecimal(row["precio_compra"].ToString()),
                    Precio_venta     = Convert.ToDecimal(row["precio_venta"].ToString()),
                    Stock_inicial    = Convert.ToInt32(row["stock_inicial"].ToString()),
                    Stock_actual     = Convert.ToInt32(row["stock_inicial"].ToString()),
                    Fecha_produccion = Convert.ToDateTime(row["fecha_produccion"].ToString()),
                    Fecha_vence      = Convert.ToDateTime(row["fecha_vence"].ToString())
                };

                detalles.Add(e_Detalle_Ingreso);
            }
            return(ObjIngreso.InsertarIngreso(Ingreso, detalles));
        }