public static string Insertar(int idtrabajador,int idproveedor, DateTime fecha, string tipo_comprobante,string serie,string correlativo, decimal igv, string estado,DataTable dtDetalles) { DIngreso Obj = new DIngreso(); Obj.Idtrabajador = idtrabajador; Obj.Idproveedor = idproveedor; Obj.Fecha = fecha; Obj.Tipo_Comprobante = tipo_comprobante; Obj.Serie = serie; Obj.Correlativo = correlativo; Obj.Igv = igv; Obj.Estado = estado; List<DDetalle_Ingreso> detalles = new List<DDetalle_Ingreso>(); foreach (DataRow row in dtDetalles.Rows) { DDetalle_Ingreso detalle = new DDetalle_Ingreso(); detalle.Idarticulo = Convert.ToInt32(row["idarticulo"].ToString()); detalle.Precio_Compra = Convert.ToDecimal(row["precio_compra"].ToString()); detalle.Precio_Venta = Convert.ToDecimal(row["precio_venta"].ToString()); detalle.Stock_Inicial = Convert.ToInt32(row["stock_inicial"].ToString()); detalle.Stock_Actual = Convert.ToInt32(row["stock_inicial"].ToString()); detalle.Fecha_Produccion = Convert.ToDateTime(row["fecha_produccion"].ToString()); detalle.Fecha_Vencimiento = Convert.ToDateTime(row["fecha_vencimiento"].ToString()); detalles.Add(detalle); } return Obj.Insertar(Obj,detalles); }
//Método Insertar public string Insertar(DDetalle_Ingreso Detalle_Ingreso, ref SqlConnection SqlCon, ref SqlTransaction SqlTra) { string rpta = ""; try { //Establecer el Comando SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = SqlCon; SqlCmd.Transaction = SqlTra; SqlCmd.CommandText = "spinsertar_detalle_ingreso"; SqlCmd.CommandType = CommandType.StoredProcedure; SqlParameter ParIddetalle_Ingreso = new SqlParameter(); ParIddetalle_Ingreso.ParameterName = "@iddetalle_ingreso"; ParIddetalle_Ingreso.SqlDbType = SqlDbType.Int; ParIddetalle_Ingreso.Direction = ParameterDirection.Output; SqlCmd.Parameters.Add(ParIddetalle_Ingreso); SqlParameter ParIdingreso = new SqlParameter(); ParIdingreso.ParameterName = "@idingreso"; ParIdingreso.SqlDbType = SqlDbType.Int; ParIdingreso.Value = Detalle_Ingreso.Idingreso; SqlCmd.Parameters.Add(ParIdingreso); SqlParameter ParIdarticulo = new SqlParameter(); ParIdarticulo.ParameterName = "@idarticulo"; ParIdarticulo.SqlDbType = SqlDbType.Int; ParIdarticulo.Value = Detalle_Ingreso.Idarticulo; SqlCmd.Parameters.Add(ParIdarticulo); SqlParameter ParPrecio_Compra = new SqlParameter(); ParPrecio_Compra.ParameterName = "@precio_compra"; ParPrecio_Compra.SqlDbType = SqlDbType.Money; ParPrecio_Compra.Value = Detalle_Ingreso.Precio_Compra; SqlCmd.Parameters.Add(ParPrecio_Compra); SqlParameter ParPrecio_Venta = new SqlParameter(); ParPrecio_Venta.ParameterName = "@precio_venta"; ParPrecio_Venta.SqlDbType = SqlDbType.Money; ParPrecio_Venta.Value = Detalle_Ingreso.Precio_Venta; SqlCmd.Parameters.Add(ParPrecio_Venta); SqlParameter ParStock_Actual = new SqlParameter(); ParStock_Actual.ParameterName = "@stock_actual"; ParStock_Actual.SqlDbType = SqlDbType.Int; ParStock_Actual.Value = Detalle_Ingreso.Stock_Actual; SqlCmd.Parameters.Add(ParStock_Actual); SqlParameter ParStock_Inicial = new SqlParameter(); ParStock_Inicial.ParameterName = "@stock_inicial"; ParStock_Inicial.SqlDbType = SqlDbType.Int; ParStock_Inicial.Value = Detalle_Ingreso.Stock_Inicial; SqlCmd.Parameters.Add(ParStock_Inicial); SqlParameter ParFecha_Produccion = new SqlParameter(); ParFecha_Produccion.ParameterName = "@fecha_produccion"; ParFecha_Produccion.SqlDbType = SqlDbType.Date; ParFecha_Produccion.Value = Detalle_Ingreso.Fecha_Produccion; SqlCmd.Parameters.Add(ParFecha_Produccion); SqlParameter ParFecha_Vencimiento = new SqlParameter(); ParFecha_Vencimiento.ParameterName = "@fecha_vencimiento"; ParFecha_Vencimiento.SqlDbType = SqlDbType.Date; ParFecha_Vencimiento.Value = Detalle_Ingreso.Fecha_Vencimiento; SqlCmd.Parameters.Add(ParFecha_Vencimiento); //Ejecutamos nuestro comando rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "NO se Ingreso el Registro"; } catch (Exception ex) { rpta = ex.Message; } return rpta; }
//Metodo Insertar /// <summary> /// Recibe el detalle de ingreso de la Clase DIngreso /// </summary> /// <param name="Detalle_Ingreso">recibe el mismo String de conexion de la clase DIngreso</param> /// <param name="SqlCon"></param> /// <param name="SqlTran">Establece una unica transacion,para no poder mesclar entre varios ingresos</param> /// <returns></returns> public string Insertar(DDetalle_Ingreso Detalle_Ingreso, ref SqlConnection SqlCon, ref SqlTransaction SqlTran) { string rpta = ""; try { //Establecer el comando SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = SqlCon; SqlCmd.Transaction = SqlTran; SqlCmd.CommandText = "spinsertar_detalle_ingreso"; SqlCmd.CommandType = CommandType.StoredProcedure; SqlParameter ParIddetalle_Ingreso = new SqlParameter(); ParIddetalle_Ingreso.ParameterName = "@iddetalle_ingreso"; ParIddetalle_Ingreso.SqlDbType = SqlDbType.Int; ParIddetalle_Ingreso.Direction = ParameterDirection.Output;//se utiliza este metodo por que es un valor de salida SqlCmd.Parameters.Add(ParIddetalle_Ingreso); SqlParameter ParIdingreso = new SqlParameter(); ParIdingreso.ParameterName = "@idingreso"; ParIdingreso.SqlDbType = SqlDbType.Int; ParIdingreso.Value = Detalle_Ingreso.Idingreso; SqlCmd.Parameters.Add(ParIdingreso); SqlParameter ParIdarticulo = new SqlParameter(); ParIdarticulo.ParameterName = "@idarticulo"; ParIdarticulo.SqlDbType = SqlDbType.Int; ParIdarticulo.Value = Detalle_Ingreso.Idarticulo; SqlCmd.Parameters.Add(ParIdarticulo); SqlParameter ParPrecio_Compra = new SqlParameter(); ParPrecio_Compra.ParameterName = "@precio_compra"; ParPrecio_Compra.SqlDbType = SqlDbType.Money; ParPrecio_Compra.Value = Detalle_Ingreso.Precio_Compra; SqlCmd.Parameters.Add(ParPrecio_Compra); SqlParameter ParPrecio_Venta = new SqlParameter(); ParPrecio_Venta.ParameterName = "@precio_venta"; ParPrecio_Venta.SqlDbType = SqlDbType.Money; ParPrecio_Venta.Value = Detalle_Ingreso.Precio_Venta; SqlCmd.Parameters.Add(ParPrecio_Venta); SqlParameter ParStock_Inicial = new SqlParameter(); ParStock_Inicial.ParameterName = "@stock_inicial"; ParStock_Inicial.SqlDbType = SqlDbType.Int; ParStock_Inicial.Value = Detalle_Ingreso.Stock_Inicial; SqlCmd.Parameters.Add(ParStock_Inicial); SqlParameter ParStock_Actual = new SqlParameter(); ParStock_Actual.ParameterName = "@stock_actual"; ParStock_Actual.SqlDbType = SqlDbType.Int; ParStock_Actual.Value = Detalle_Ingreso.Stock_Actual; SqlCmd.Parameters.Add(ParStock_Actual); SqlParameter ParFecha_Produccion = new SqlParameter(); ParFecha_Produccion.ParameterName = "@fecha_produccion"; ParFecha_Produccion.SqlDbType = SqlDbType.DateTime; ParFecha_Produccion.Value = Detalle_Ingreso.Fecha_Produccion; SqlCmd.Parameters.Add(ParFecha_Produccion); SqlParameter ParFecha_Vencimiento = new SqlParameter(); ParFecha_Vencimiento.ParameterName = "@fecha_vencimiento"; ParFecha_Vencimiento.SqlDbType = SqlDbType.DateTime; ParFecha_Vencimiento.Value = Detalle_Ingreso.Fecha_Vencimiento; SqlCmd.Parameters.Add(ParFecha_Vencimiento); //Ejecutamos nuestro comando rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "No se Ingreso ningun registro"; } catch (Exception ex) { rpta = ex.Message; } return(rpta); }
//Método Insertar public string Insertar(DDetalle_Ingreso Detalle_Ingreso, //2 parámetros más por referencia: //SqlConnectio, lo que voy a recibir es la conexión para no establecer una nueva conexión... //... sino utilizar la conexión que me pide la clase DIngreso, porque al momento de insertar... //... un ingreso se va a insertar al mismo tiempo con todos sus detalles, entonces recibo por referencia esta conexión. //La variable se va a llamar SqlCon. ref SqlConnection SqlCon, //También recibo por referencia la transacción, en éste caso un SqlTransaction, y esto para qué?... //... para establecer una única transacción, un único ingreso se va a insertar en la BD con una única transacción... //... para no poder mezclar entre varios ingresos, ya que el sistema podría ser utilizado en red. ref SqlTransaction SqlTra) { string rpta = ""; try { //Establecer el Comando SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = SqlCon; //Establecemos la transacción, que será con la variable: SqlTra: SqlCmd.Transaction = SqlTra; SqlCmd.CommandText = "spinsertar_detalle_ingreso"; SqlCmd.CommandType = CommandType.StoredProcedure; SqlParameter ParIddetalle_Ingreso = new SqlParameter(); ParIddetalle_Ingreso.ParameterName = "@iddetalle_ingreso"; ParIddetalle_Ingreso.SqlDbType = SqlDbType.Int; ParIddetalle_Ingreso.Direction = ParameterDirection.Output; SqlCmd.Parameters.Add(ParIddetalle_Ingreso); SqlParameter ParIdingreso = new SqlParameter(); ParIdingreso.ParameterName = "@idingreso"; ParIdingreso.SqlDbType = SqlDbType.Int; ParIdingreso.Value = Detalle_Ingreso.Idingreso; SqlCmd.Parameters.Add(ParIdingreso); SqlParameter ParIdarticulo = new SqlParameter(); ParIdarticulo.ParameterName = "@idarticulo"; ParIdarticulo.SqlDbType = SqlDbType.Int; ParIdarticulo.Value = Detalle_Ingreso.Idarticulo; SqlCmd.Parameters.Add(ParIdarticulo); SqlParameter ParPrecio_Compra = new SqlParameter(); ParPrecio_Compra.ParameterName = "@precio_compra"; ParPrecio_Compra.SqlDbType = SqlDbType.Money; ParPrecio_Compra.Value = Detalle_Ingreso.Precio_Compra; SqlCmd.Parameters.Add(ParPrecio_Compra); SqlParameter ParPrecio_Venta = new SqlParameter(); ParPrecio_Venta.ParameterName = "@precio_venta"; ParPrecio_Venta.SqlDbType = SqlDbType.Money; ParPrecio_Venta.Value = Detalle_Ingreso.Precio_Venta; SqlCmd.Parameters.Add(ParPrecio_Venta); SqlParameter ParStock_Actual = new SqlParameter(); ParStock_Actual.ParameterName = "@stock_actual"; ParStock_Actual.SqlDbType = SqlDbType.Int; ParStock_Actual.Value = Detalle_Ingreso.Stock_Actual; SqlCmd.Parameters.Add(ParStock_Actual); SqlParameter ParStock_Inicial = new SqlParameter(); ParStock_Inicial.ParameterName = "@stock_inicial"; ParStock_Inicial.SqlDbType = SqlDbType.Int; ParStock_Inicial.Value = Detalle_Ingreso.Stock_Inicial; SqlCmd.Parameters.Add(ParStock_Inicial); SqlParameter ParFecha_Produccion = new SqlParameter(); ParFecha_Produccion.ParameterName = "@fecha_produccion"; ParFecha_Produccion.SqlDbType = SqlDbType.Date; ParFecha_Produccion.Value = Detalle_Ingreso.Fecha_Produccion; SqlCmd.Parameters.Add(ParFecha_Produccion); SqlParameter ParFecha_Vencimiento = new SqlParameter(); ParFecha_Vencimiento.ParameterName = "@fecha_vencimiento"; ParFecha_Vencimiento.SqlDbType = SqlDbType.Date; ParFecha_Vencimiento.Value = Detalle_Ingreso.Fecha_Vencimiento; SqlCmd.Parameters.Add(ParFecha_Vencimiento); //Ejecutamos nuestro comando rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "NO se Ingreso el Registro"; } catch (Exception ex) { rpta = ex.Message; } return(rpta); }
//Método Insertar public string Insertar(DDetalle_Ingreso Detalle_Ingreso, ref SqlConnection SqlCon, ref SqlTransaction SqlTra) { string rpta = ""; try { SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = SqlCon; SqlCmd.Transaction = SqlTra; SqlCmd.CommandText = "spinsertar_detalle_ingreso"; SqlCmd.CommandType = CommandType.StoredProcedure; SqlParameter ParIddetalle_ingreso = new SqlParameter(); ParIddetalle_ingreso.ParameterName = "@iddetalle_ingreso"; ParIddetalle_ingreso.SqlDbType = SqlDbType.Int; ParIddetalle_ingreso.Direction = ParameterDirection.Output; SqlCmd.Parameters.Add(ParIddetalle_ingreso); SqlParameter ParIdingreso = new SqlParameter(); ParIdingreso.ParameterName = "@idingreso"; ParIdingreso.SqlDbType = SqlDbType.Int; ParIdingreso.Value = Detalle_Ingreso.Idingreso; SqlCmd.Parameters.Add(ParIdingreso); SqlParameter ParIdarticulo = new SqlParameter(); ParIdarticulo.ParameterName = "@idarticulo"; ParIdarticulo.SqlDbType = SqlDbType.Int; ParIdarticulo.Value = Detalle_Ingreso.Idarticulo; SqlCmd.Parameters.Add(ParIdarticulo); SqlParameter ParPrecio_Compra = new SqlParameter(); ParPrecio_Compra.ParameterName = "@precio_compra"; ParPrecio_Compra.SqlDbType = SqlDbType.Decimal; ParPrecio_Compra.Precision = 4; ParPrecio_Compra.Scale = 2; ParPrecio_Compra.Value = Detalle_Ingreso.Precio_Compra; SqlCmd.Parameters.Add(ParPrecio_Compra); SqlParameter ParPrecio_Venta = new SqlParameter(); ParPrecio_Venta.ParameterName = "@precio_venta"; ParPrecio_Venta.SqlDbType = SqlDbType.Decimal; ParPrecio_Venta.Precision = 4; ParPrecio_Venta.Scale = 2; ParPrecio_Venta.Value = Detalle_Ingreso.Precio_Venta; SqlCmd.Parameters.Add(ParPrecio_Venta); SqlParameter ParStock_Inicial = new SqlParameter(); ParStock_Inicial.ParameterName = "@stock_inicial"; ParStock_Inicial.SqlDbType = SqlDbType.Int; ParStock_Inicial.Value = Detalle_Ingreso.Stock_Inicial; SqlCmd.Parameters.Add(ParStock_Inicial); SqlParameter ParStock_Actual = new SqlParameter(); ParStock_Actual.ParameterName = "@stock_actual"; ParStock_Actual.SqlDbType = SqlDbType.Int; ParStock_Actual.Value = Detalle_Ingreso.Stock_Actual; SqlCmd.Parameters.Add(ParStock_Actual); SqlParameter ParFecha_Produccion = new SqlParameter(); ParFecha_Produccion.ParameterName = "@fecha_produccion"; ParFecha_Produccion.SqlDbType = SqlDbType.VarChar; ParFecha_Produccion.Size = 20; ParFecha_Produccion.Value = Detalle_Ingreso.Fecha_Produccion; SqlCmd.Parameters.Add(ParFecha_Produccion); SqlParameter ParFecha_Vencimiento = new SqlParameter(); ParFecha_Vencimiento.ParameterName = "@fecha_vencimiento"; ParFecha_Vencimiento.SqlDbType = SqlDbType.VarChar; ParFecha_Vencimiento.Size = 20; ParFecha_Vencimiento.Value = Detalle_Ingreso.Fecha_Vencimiento; SqlCmd.Parameters.Add(ParFecha_Vencimiento); //Ejecutamos nuestro comando rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "NO se Ingreso el Registro"; } catch (Exception ex) { rpta = ex.Message; } return(rpta); }
//Metodo Insertar public string Insertar(DDetalle_Ingreso Detalle_Ingreso, ref SqlConnection SqlConectar, ref SqlTransaction SqlTransaccion) { string respuesta = ""; try { //comandos SqlCommand SqlComando = new SqlCommand(); SqlComando.Connection = SqlConectar; SqlComando.Transaction = SqlTransaccion; SqlComando.CommandText = "Insertar_Detalle_Ingreso"; SqlComando.CommandType = CommandType.StoredProcedure; //parametros //parametro id detalle SqlParameter Parametro_Id_Detalle_Ingreso = new SqlParameter(); Parametro_Id_Detalle_Ingreso.ParameterName = "@IdDetalleIngreso"; Parametro_Id_Detalle_Ingreso.SqlDbType = SqlDbType.Int; Parametro_Id_Detalle_Ingreso.Direction = ParameterDirection.Output; SqlComando.Parameters.Add(Parametro_Id_Detalle_Ingreso); //parametro id ingreso SqlParameter Parametro_Id_Ingreso = new SqlParameter(); Parametro_Id_Ingreso.ParameterName = "@IdIngreso"; Parametro_Id_Ingreso.SqlDbType = SqlDbType.Int; Parametro_Id_Ingreso.Value = Detalle_Ingreso.Id_Ingreso; SqlComando.Parameters.Add(Parametro_Id_Ingreso); //parametro id articulo SqlParameter Parametro_Id_Articulo = new SqlParameter(); Parametro_Id_Articulo.ParameterName = "@IdArticulo"; Parametro_Id_Articulo.SqlDbType = SqlDbType.Int; Parametro_Id_Articulo.Value = Detalle_Ingreso.Id_Articulo; SqlComando.Parameters.Add(Parametro_Id_Articulo); //parametro precio compra SqlParameter Parametro_Precio_Compra = new SqlParameter(); Parametro_Precio_Compra.ParameterName = "@PrecioCompra"; Parametro_Precio_Compra.SqlDbType = SqlDbType.Money; Parametro_Precio_Compra.Value = Detalle_Ingreso.Precio_Compra; SqlComando.Parameters.Add(Parametro_Precio_Compra); //parametro precio venta SqlParameter Parametro_Precio_Venta = new SqlParameter(); Parametro_Precio_Venta.ParameterName = "@PrecioVenta"; Parametro_Precio_Venta.SqlDbType = SqlDbType.Money; Parametro_Precio_Venta.Value = Detalle_Ingreso.Precio_Venta; SqlComando.Parameters.Add(Parametro_Precio_Venta); //parametro stock actual SqlParameter Parametro_Stock_Actual = new SqlParameter(); Parametro_Stock_Actual.ParameterName = "@StockActual"; Parametro_Stock_Actual.SqlDbType = SqlDbType.Int; Parametro_Stock_Actual.Value = Detalle_Ingreso.Stock_Actual; SqlComando.Parameters.Add(Parametro_Stock_Actual); //parametro stock inicial SqlParameter Parametro_Stock_Inicial = new SqlParameter(); Parametro_Stock_Inicial.ParameterName = "@StockInicial"; Parametro_Stock_Inicial.SqlDbType = SqlDbType.Int; Parametro_Stock_Inicial.Value = Detalle_Ingreso.Stock_Inicial; SqlComando.Parameters.Add(Parametro_Stock_Inicial); //parametro fecha produccion SqlParameter Parametro_Fecha_Produccion = new SqlParameter(); Parametro_Fecha_Produccion.ParameterName = "@FechaProduccion"; Parametro_Fecha_Produccion.SqlDbType = SqlDbType.Date; Parametro_Fecha_Produccion.Value = Detalle_Ingreso.Fecha_Produccion; SqlComando.Parameters.Add(Parametro_Fecha_Produccion); //parametro fecha vencimiento SqlParameter Parametro_Fecha_Vencimiento = new SqlParameter(); Parametro_Fecha_Vencimiento.ParameterName = "@FechaVencimiento"; Parametro_Fecha_Vencimiento.SqlDbType = SqlDbType.Date; Parametro_Fecha_Vencimiento.Value = Detalle_Ingreso.Fecha_Vencimiento; SqlComando.Parameters.Add(Parametro_Fecha_Vencimiento); //ejecuta y lo envia en comentario respuesta = SqlComando.ExecuteNonQuery() == 1 ? "OK" : "No se ingreso el Registro"; } catch (Exception excepcion) { respuesta = excepcion.Message; } return(respuesta); }
//metodo de insertar public string Insertar(DDetalle_Ingreso Detalle_Ingreso, ref SqlConnection sqlCon, ref SqlTransaction SqlTra) { string rpta = ""; try { //conexion al procedimiento almacenado SqlCommand sqlcmd = new SqlCommand(); sqlcmd.Connection = sqlCon; sqlcmd.Transaction = SqlTra; sqlcmd.CommandText = "DetalleIngreso_Insertar"; sqlcmd.CommandType = CommandType.StoredProcedure; //conexion con variables del SP SqlParameter paridDetalle_Ingreso = new SqlParameter(); paridDetalle_Ingreso.ParameterName = "@idDetalle_ingreso"; paridDetalle_Ingreso.SqlDbType = SqlDbType.Int; paridDetalle_Ingreso.Direction = ParameterDirection.Output; sqlcmd.Parameters.Add(paridDetalle_Ingreso); SqlParameter paridIngreso = new SqlParameter(); paridIngreso.ParameterName = "@idIngreso"; paridIngreso.SqlDbType = SqlDbType.Int; paridIngreso.Value = Detalle_Ingreso.IdIngreso; sqlcmd.Parameters.Add(paridIngreso); SqlParameter paridArticulo = new SqlParameter(); paridArticulo.ParameterName = "@idArticulo"; paridArticulo.SqlDbType = SqlDbType.Int; paridArticulo.Value = Detalle_Ingreso.IdArticulo; sqlcmd.Parameters.Add(paridArticulo); SqlParameter parPrecio_Compra = new SqlParameter(); parPrecio_Compra.ParameterName = "@precio_Compra"; parPrecio_Compra.SqlDbType = SqlDbType.Money; parPrecio_Compra.Value = Detalle_Ingreso.Precio_Compra; sqlcmd.Parameters.Add(parPrecio_Compra); SqlParameter parPrecio_Venta = new SqlParameter(); parPrecio_Venta.ParameterName = "@precio_Venta"; parPrecio_Venta.SqlDbType = SqlDbType.Money; parPrecio_Venta.Value = Detalle_Ingreso.Precio_Venta; sqlcmd.Parameters.Add(parPrecio_Venta); SqlParameter parStock_Inicial = new SqlParameter(); parStock_Inicial.ParameterName = "@stock_Inicial"; parStock_Inicial.SqlDbType = SqlDbType.Int; parStock_Inicial.Value = Detalle_Ingreso.Stock_Inicial; sqlcmd.Parameters.Add(parStock_Inicial); SqlParameter parStock_Actual = new SqlParameter(); parStock_Actual.ParameterName = "@stock_Actual"; parStock_Actual.SqlDbType = SqlDbType.Int; parStock_Actual.Value = Detalle_Ingreso.Stock_Actual; sqlcmd.Parameters.Add(parStock_Actual); rpta = sqlcmd.ExecuteNonQuery() == 1 ? "OK" : "NO SE REALIZO EL REGISTRO"; } catch (Exception ex) { rpta = ex.Message; } return(rpta); }
public string ModificarIngreso(DDetalle_Ingreso Detalle_Ingreso) { string rpta = ""; SqlConnection SqlCon = new SqlConnection(); try { SqlCon.ConnectionString = Conexion.Cn; SqlCon.Open(); //Establecer el Comando SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = SqlCon; SqlCmd.CommandText = "speditar_datalle_ingreso"; SqlCmd.CommandType = CommandType.StoredProcedure; SqlCmd.Parameters.AddWithValue("@nombre", Detalle_Ingreso.Nombre); SqlCmd.Parameters.AddWithValue("@precio_compra", Detalle_Ingreso.Precio_Compra); SqlCmd.Parameters.AddWithValue("@precio_venta", Detalle_Ingreso.Precio_Venta); SqlCmd.Parameters.AddWithValue("@stock", Detalle_Ingreso.Stock_Inicial); SqlCmd.Parameters.AddWithValue("@fechaProd", Detalle_Ingreso.Fecha_Produccion); SqlCmd.Parameters.AddWithValue("@fechaVenc", Detalle_Ingreso.Fecha_Vencimiento); SqlCmd.Parameters.AddWithValue("@idDetalle", Detalle_Ingreso.Iddetalle_Ingreso); SqlCmd.Parameters.AddWithValue("@idArticulo", Detalle_Ingreso.Idarticulo); SqlCmd.Parameters.AddWithValue("@itbis", Detalle_Ingreso.ITBIS); //SqlParameter ParNombre = new SqlParameter(); //ParNombre.ParameterName = "@nombre"; //ParNombre.SqlDbType = SqlDbType.VarChar; //ParNombre.Size = 75; //ParNombre.Value = Detalle_Ingreso.Nombre; //SqlCmd.Parameters.Add(ParNombre); //SqlParameter ParPrecio_Compra = new SqlParameter(); //ParPrecio_Compra.ParameterName = "@precio_compra"; //ParPrecio_Compra.SqlDbType = SqlDbType.Money; //ParPrecio_Compra.Value = Detalle_Ingreso.Precio_Compra; //SqlCmd.Parameters.Add(ParPrecio_Compra); //SqlParameter ParPrecio_Venta = new SqlParameter(); //ParPrecio_Venta.ParameterName = "@precio_venta"; //ParPrecio_Venta.SqlDbType = SqlDbType.Money; //ParPrecio_Venta.Value = Detalle_Ingreso.Precio_Venta; //SqlCmd.Parameters.Add(ParPrecio_Venta); //SqlParameter ParStock_Inicial = new SqlParameter(); //ParStock_Inicial.ParameterName = "@stock"; //ParStock_Inicial.SqlDbType = SqlDbType.Int; //ParStock_Inicial.Value = Detalle_Ingreso.Stock_Inicial; //SqlCmd.Parameters.Add(ParStock_Inicial); //SqlParameter ParFecha_Produccion = new SqlParameter(); //ParFecha_Produccion.ParameterName = "@fechaProd"; //ParFecha_Produccion.SqlDbType = SqlDbType.Date; //ParFecha_Produccion.Value = Detalle_Ingreso.Fecha_Produccion; //SqlCmd.Parameters.Add(ParFecha_Produccion); //SqlParameter ParFecha_Vencimiento = new SqlParameter(); //ParFecha_Vencimiento.ParameterName = "@fechaVenc"; //ParFecha_Vencimiento.SqlDbType = SqlDbType.Date; //ParFecha_Vencimiento.Value = Detalle_Ingreso.Fecha_Vencimiento; //SqlCmd.Parameters.Add(ParFecha_Vencimiento); //SqlParameter ParIdingreso = new SqlParameter(); //ParIdingreso.ParameterName = "@idDetalle"; //ParIdingreso.SqlDbType = SqlDbType.Int; //ParIdingreso.Value = Detalle_Ingreso.Iddetalle_Ingreso; //SqlCmd.Parameters.Add(ParIdingreso); //SqlParameter ParIdarticulo = new SqlParameter(); //ParIdarticulo.ParameterName = "@idArticulo"; //ParIdarticulo.SqlDbType = SqlDbType.Int; //ParIdarticulo.Value = Detalle_Ingreso.Idarticulo; //SqlCmd.Parameters.Add(ParIdarticulo); //SqlParameter ParITBIS = new SqlParameter(); //ParITBIS.ParameterName = "@itbis"; //ParITBIS.SqlDbType = SqlDbType.Int; //ParITBIS.Value = Detalle_Ingreso.ITBIS; //SqlCmd.Parameters.Add(ParITBIS); //Ejecutamos nuestro comando rpta = SqlCmd.ExecuteNonQuery() == 2 ? "Datos modificados exitosamente" : "NO se Ingreso el Registro"; } catch (Exception ex) { rpta = ex.Message; } finally { SqlCon.Close(); } return(rpta); }