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)); }
//metodo insertar que llama a insertar de dcategoria en datos public static string Insertar(int idtrabajador, int idproveedor, DateTime fecha, string tipo_comprobante, string serie, string correlativo, decimal igv, string estado, DataTable dDetalles) { 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; //========================================================= //recibo los detalles en una lista para enviarlo como lista a Insertar List <DDetalle_Ingreso> detalles = new List <DDetalle_Ingreso>(); foreach (DataRow row in dDetalles.Rows) { DDetalle_Ingreso detalle = new DDetalle_Ingreso(); //iddetalle_ingreso autogenerado,idingreso se obtendra de la clase 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()); //agrego a la lista el objeto detalles.Add(detalle); } return(obj.Insertar(obj, detalles)); }
// metodo Insertar public static string Insertar(int idtrabajador, int idproveedor, DateTime fecha, string tipo_comprobante, string serie, string correlativo, decimal igv, string estado, DataTable dtDetalles)//en el parametro DataTable dtDetalle //recibimos todos los parametros { DIngreso Obj = new DIngreso(); //Obj.Idingreso = idingreso; 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; // en una lista metemos todos los detalles del DataTable dtDetalles List <DDetalle_Ingreso> detalles = new List <DDetalle_Ingreso>(); foreach (DataRow row in dtDetalles.Rows)//creamos un objeto DataRow de dtDetalles y recorremos todas las filas y le metemos en row { 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)); //devolvemos el objeto con todos los atributos }
public static string Insertar(int IdEmpleado, int idproveedor, DateTime fecha, string tipoComprobante, string serie, string correlativo, decimal iva, string estado, DataTable dtDetalles) { DIngreso Obj = new DIngreso(); Obj.IdEmpleado = IdEmpleado; Obj.IdProveedor = idproveedor; Obj.Fecha = fecha; Obj.TipoComprobante = tipoComprobante; Obj.Serie = serie; Obj.Correlativo = correlativo; Obj.Iva = iva; Obj.Estado = estado; List <DDetalle_Ingreso> detalles = new List <DDetalle_Ingreso>(); foreach (DataRow row in dtDetalles.Rows) { DDetalle_Ingreso detalle = new DDetalle_Ingreso(); detalle.IdProducto = Convert.ToInt32(row["Id Producto"].ToString()); detalle.Precio_Compra = Convert.ToDecimal(row["Precio de compra"].ToString()); detalle.Precio_Venta = Convert.ToDecimal(row["Precio de 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 de produccion"].ToString()); detalle.Fecha_Vencimiento = Convert.ToDateTime(row["Fecha de vencimiento"].ToString()); detalles.Add(detalle); } return(Obj.Insertar(Obj, detalles)); }
//metodo insertar public static string Insertar(int IdTrabajador, int IdProveedor, DateTime Fecha, decimal PrecioTotal, string Estado, DataTable DtDetalles) { DIngreso Objeto = new DIngreso(); Objeto.Id_Trabajador = IdTrabajador; Objeto.Id_Proveedor = IdProveedor; Objeto.Fecha = Fecha; Objeto.Precio_Total = PrecioTotal; Objeto.Estado = Estado; List <DDetalle_Ingreso> Detalles = new List <DDetalle_Ingreso>(); foreach (DataRow row in DtDetalles.Rows) { DDetalle_Ingreso Detalle = new DDetalle_Ingreso(); Detalle.Id_Articulo = Convert.ToInt32(row["Id_Articulo"].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(Objeto.Insertar(Objeto, Detalles)); }
//Método que llama el método editat de la clase DDetalle_Ingreso de la capa de datos public static string Editar(int iddetalleingreso, decimal precio_compra, decimal precio_venta_actual, int stock_inicial, decimal porcentaje, decimal utilidad_actual, DateTime fecha_produccion, DateTime fecha_vencimiento) { DDetalle_Ingreso Obj = new DDetalle_Ingreso(); Obj.Iddetalle_Ingreso = iddetalleingreso; Obj.Precio_Compra = precio_compra; Obj.Precio_Venta_Actual = precio_venta_actual; Obj.Stock_Inicial = stock_inicial; Obj.Porcentaje = porcentaje; Obj.Utilidad_Actual = utilidad_actual; Obj.Fecha_Produccion = fecha_produccion; Obj.Fecha_Vencimiento = fecha_vencimiento; return(Obj.Editar(Obj)); }
//Método para actualizzr los precios cada vez que se genere un ingreso de articulos public static string EditarPrecios(DataTable dtDetalles) { DIngreso Obj = new DIngreso(); 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_Venta_Actual = Convert.ToDecimal(row["precio_venta_actual"].ToString()); detalles.Add(detalle); } return(Obj.EditarPrecios(detalles)); }
//Método para actualizar el stock de articulos despues de cada venta public static string updateStock(DataTable dtDetalles) { DDetalle_Ingreso Obj = new DDetalle_Ingreso(); 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.Iddetalle_Ingreso = Convert.ToInt32(row["iddetalle_ingreso"].ToString()); detalle.Stock_Actual = Convert.ToInt32(row["stock_actual"].ToString()); detalles.Add(detalle); } return(Obj.updateStock(detalles)); }
public static string ModificarDetalle(int iddetalle_ingreso, int idarticulo, string nombre, decimal precio_compra, decimal precio_venta, int stock_inicial, DateTime fecha_produccion, DateTime fecha_vencimiento, int itbis) { DDetalle_Ingreso dDetalle_Ingreso = new DDetalle_Ingreso(); dDetalle_Ingreso.Iddetalle_Ingreso = iddetalle_ingreso; dDetalle_Ingreso.Idarticulo = idarticulo; dDetalle_Ingreso.Nombre = nombre; dDetalle_Ingreso.Precio_Compra = precio_compra; dDetalle_Ingreso.Precio_Venta = precio_venta; dDetalle_Ingreso.Stock_Inicial = stock_inicial; dDetalle_Ingreso.Fecha_Produccion = fecha_produccion; dDetalle_Ingreso.Fecha_Vencimiento = fecha_vencimiento; dDetalle_Ingreso.ITBIS = itbis; return(dDetalle_Ingreso.ModificarIngreso(dDetalle_Ingreso)); }
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; //Vamos a recibir todos los detalles de éste parámetro: dtDetalles: //Creo un objeto: se va a llamar: detalles. List <DDetalle_Ingreso> detalles = new List <DDetalle_Ingreso>(); //Voy recorriendo fila por fila. Creo un objeto del tipo DataRow, se llama row. Va recorriendo... //... del parámetro dtDetalles todas las filas que tenga. 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 es una lista de todos esos objetos de DDetalle_Ingreso. //Digo detalles y agrego (Add) ese objeto (detalle) detalles.Add(detalle); } //Le envío primero el objeto y luego los detalles. //Quién lo recibe? el objeto Insertar de mi clase DIngreso return(Obj.Insertar(Obj, detalles)); }
public static string Insertar(int idEmpleado, DateTime fecha, string serie, string estado, DataTable dtDetalle) { DIngreso obj = new DIngreso(); obj.IdEmpleado = idEmpleado; obj.Fecha = fecha; obj.Serie = serie; obj.Estado = estado; List <DDetalle_Ingreso> Detalles = new List <DDetalle_Ingreso>(); foreach (DataRow row in dtDetalle.Rows) { DDetalle_Ingreso objDetalle = new DDetalle_Ingreso(); objDetalle.IdArticulo = Convert.ToInt32(row["idArticulo"].ToString()); objDetalle.Precio_Compra = Convert.ToDecimal(row["PRECIO DE COMPRA"].ToString()); objDetalle.Precio_Venta = Convert.ToDecimal(row["PRECIO DE VENTA"].ToString()); objDetalle.Stock_Inicial = Convert.ToInt32(row["STOCK INICIAL"].ToString()); objDetalle.Stock_Actual = Convert.ToInt32(row["STOCK INICIAL"].ToString()); Detalles.Add(objDetalle); } return(obj.Insertar(obj, Detalles)); }
//Método que llama al método que muestra el stock el precio y el total de ganancias public static DataTable MostrarDetalleGanancias(int textoBuscar) { DDetalle_Ingreso Obj = new DDetalle_Ingreso(); return(Obj.MostrarGanancias(textoBuscar)); }