public static List<Producto> BuscarProducto() { List<Producto> lstProducto = new List<Producto>(); SqlConnection conn = new SqlConnection(Properties.Settings.Default.inf245g4ConnectionString); SqlCommand cmd = new SqlCommand(); SqlDataReader reader; cmd.CommandText = "SELECT nombre FROM Producto order by 1"; cmd.CommandType = CommandType.Text; cmd.Connection = conn; try { conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { Producto e = new Producto(); e.Nombre = reader["nombre"].ToString(); lstProducto.Add(e); } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.StackTrace.ToString()); } return lstProducto; }
public ProductoxOrdenCompra(Consolidado c,int idOrden) { this.cantidad = Convert.ToString(c.Cantidad); this.producto = c.Producto; this.idOrden = idOrden; this.PrecioUnitario = c.Costo; }
public ProductoMantenerViewModel(IWindowManager windowmanager, Producto p) : this(windowmanager) { TxtNombre = p.Nombre; TxtCodigo = p.CodigoProd; txtAbreviatura = p.Abreviatura; TxtDescrip = p.Descripcion; TxtStockMin = p.StockMin; txtStockMax = p.StockMax; Percepcion = p.Percepcion == 0 ? false : true; Editar = false; estado = p.IdProducto; }
internal List<ProductoCant> ListaProductos(string idSolicitudAB) { List<ProductoCant> productos = new List<ProductoCant>(); ProductoSQL pGw = new ProductoSQL(); string where = "WHERE idSolicitudAB=@idSolicitudAB"; db.cmd.Parameters.AddWithValue("@idSolicitudAB", idSolicitudAB); db.cmd.CommandText = "SELECT * FROM ProductoxSolicitudAb " + where; try { db.conn.Open(); SqlDataReader reader = db.cmd.ExecuteReader(); Producto p = new Producto(); while (reader.Read()) { ProductoCant pa = new ProductoCant(); pa.IdProducto= reader.IsDBNull(reader.GetOrdinal("idProducto")) ? -1 : int.Parse(reader["idProducto"].ToString()); p = pGw.Buscar_por_CodigoProducto(pa.IdProducto); pa.CodigoProd = p.CodigoProd.ToString(); pa.Nombre = p.Nombre; pa.Can = reader.IsDBNull(reader.GetOrdinal("cantidad")) ? null : reader["cantidad"].ToString(); pa.CanAtend = reader.IsDBNull(reader.GetOrdinal("cantidadAtendida")) ? null : reader["cantidadAtendida"].ToString(); productos.Add(pa); } db.cmd.Parameters.Clear(); db.conn.Close(); } catch (SqlException e) { Console.WriteLine(e.ToString()); } catch (Exception e) { Console.WriteLine(e.StackTrace.ToString()); } return productos; }
public VentaRegistrarViewModel() { lstVenta = new List<DetalleVenta>(); lstPagos = new List<VentaPago>(); lstVentaServicios = new List<DetalleVentaServicio>(); prod = new Producto(); IGV = 0.18; PUNTO = 30; subt = 0; desc = 0; igv_total = 0; montopago = 0; TiendaSQL tiendSQL = new TiendaSQL(); this.idTienda = tiendSQL.obtenerTienda(Int32.Parse(Thread.CurrentPrincipal.Identity.Name)); ModoPagoSQL mpsql = new ModoPagoSQL(); LstModosPago = mpsql.BuscarModosPago(); }
public void Acciones(object sender) { if (ventanaAccion == 0) { Actualizar(); } else if (ventanaAccion == 1) { productoSel = ((sender as DataGrid).SelectedItem as Producto); if (ventaRegistrarViewModel != null) { ventaRegistrarViewModel.Prod = productoSel; this.TryClose(); } } else if (ventanaAccion == 2) { productoSel = ((sender as DataGrid).SelectedItem as Producto); if (mantenerTiendaViewModel != null) { mantenerTiendaViewModel.TxtCodProducto = productoSel.CodigoProd; this.TryClose(); } } else if (ventanaAccion == 3) { productoSel = ((sender as DataGrid).SelectedItem as Producto); if (mantenerNotaDeSalidaViewModel != null) { mantenerNotaDeSalidaViewModel.SelectedProducto = productoSel; this.TryClose(); } } else if (ventanaAccion == 4) { productoSel = ((sender as DataGrid).SelectedItem as Producto); if (mantenerNotaDeIngresoViewModel != null) { mantenerNotaDeIngresoViewModel.SelectedProducto = productoSel; this.TryClose(); } } else if (ventanaAccion == 5) { productoSel = ((sender as DataGrid).SelectedItem as Producto); if (proformaViewModel != null) { proformaViewModel.Prod = productoSel; this.TryClose(); } } else if (ventanaAccion == 6) { productoSel = ((sender as DataGrid).SelectedItem as Producto); if (proformaViewModel != null) { proformaViewModel.Prod = productoSel; this.TryClose(); } } else if (ventanaAccion == 7) { productoSel = ((sender as DataGrid).SelectedItem as Producto); if (ProductoMovimientosViewModel != null) { ProductoMovimientosViewModel.ProductoSeleccionado = productoSel; ProductoMovimientosViewModel.TxtProducto = productoSel.CodigoProd; this.TryClose(); } } if (pvm != null) { productoSel = ((sender as DataGrid).SelectedItem as Producto); pvm.P = productoSel; this.TryClose(); } }
public void GuardarProducto() { bool isCorrect = true; if (TxtNombre == null || TxtNombre.Equals("")) { TxtNombre = ""; TxtNombreChanged = true; isCorrect = false; } if (TxtAbreviatura == null || TxtAbreviatura.Equals("")) { TxtAbreviatura = ""; TxtAbreviaturaChanged = true; isCorrect = false; } if ((TxtStockMax < TxtStockMin) || string.IsNullOrWhiteSpace(TxtStockMin.ToString()) || string.IsNullOrWhiteSpace(TxtStockMax.ToString()) || !(eval.esNumeroEntero(TxtStockMax.ToString())) || !(eval.esNumeroEntero(TxtStockMin.ToString()))) { isCorrect = false; } if ((TxtStockMin < 0) || TxtStockMax < 0) { isCorrect = false; } if (isCorrect) { Producto p = new Producto(); p.Nombre = TxtNombre; p.Abreviatura = TxtAbreviatura; p.CodigoProd = TxtCodigo; p.IdLinea = SelectedValue; p.IdSubLinea = SelectedValueSub; p.IdUnidad = SelectedValueUnid; p.Percepcion = Percepcion == true ? 1 : 0; p.Descripcion = TxtDescrip; p.StockMin = TxtStockMin; p.StockMax = TxtStockMax; if (estado == 0) { pSQL.AgregarProducto(p); _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Se agregó el producto correctamente")); //1: Agregar, 2: Editar, 3: Eliminar, 4: Recuperar, 5: Desactivar DataObjects.Seguridad.LogSQL.RegistrarActividad("Registrar producto", p.CodigoProd, 1); TxtAbreviatura = ""; TxtNombre = ""; Percepcion = false; TxtDescrip = ""; TxtStockMin = 0; TxtStockMin = 0; } else { p.IdProducto = estado; pSQL.ActualizarProducto(p); //1: Agregar, 2: Editar, 3: Eliminar, 4: Recuperar, 5: Desactivar DataObjects.Seguridad.LogSQL.RegistrarActividad("Actualizar producto", p.CodigoProd , 2); _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Se actualizó el producto correctamente")); } } if (!isCorrect) _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Alerta: Verificar los datos")); }
public ProformaViewModel() { lstProforma = new List<Proforma>(); prod = new Producto(); }
//Botones: public void CargarProductos() { string referencia = TxtDoc; if (string.IsNullOrWhiteSpace(referencia)) { _windowManager.ShowDialog(new AlertViewModel(_windowManager, "No se ha ingresado ningun Documento de Referencia")); return; } string mot = this.selectedMotivo; if (string.Compare(mot, "Orden de Compra", true) == 0) { List<ProductoxOrdenCompra> poc = new List<ProductoxOrdenCompra>(); poc = SelectedOrden.LstProducto; List<ProductoCant> lpcan = new List<ProductoCant>(); for (int i = 0; i < poc.Count; i++) { ProductoCant pcan = new ProductoCant(); pcan.IdProducto = poc.ElementAt(i).Producto.IdProducto; pcan.Can = poc.ElementAt(i).Cantidad; pcan.CodigoProd = poc.ElementAt(i).Producto.CodigoProd; pcan.Nombre = poc.ElementAt(i).Producto.Nombre; pcan.CanAtend = poc.ElementAt(i).CantAtendida.ToString(); pcan.CanAtender = poc.ElementAt(i).CantidadAtender; pcan.Ubicaciones = new List<Ubicacion>(); lpcan.Add(pcan); } LstProductos = new List<ProductoCant>(lpcan); } else { if (string.Compare(mot, "Traslado Externo", true) == 0) { if (selectedGuia == null) { _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Ingrese un código de guía de remisión valido")); } else { LstProductos = selectedGuia.Nota.LstProducto; } } else { if (string.Compare(mot, "Devolucion", true) == 0) { List<DevolucionProducto> dv = new List<DevolucionProducto>(); DevolucionSQL dsql = new DevolucionSQL(); dv = dsql.BuscarProductos(-1, -1, null, SelectedDevolucion.IdDevolucion); List<ProductoCant> lpcan = new List<ProductoCant>(); for (int i = 0; i < dv.Count; i++) { ProductoCant pcan = new ProductoCant(); Producto p = new Producto(); ProductoSQL pgw = new ProductoSQL(); p = pgw.Buscar_por_CodigoProducto(dv.ElementAt(i).IdProducto); pcan.IdProducto = p.IdProducto; pcan.Nombre = p.Nombre; pcan.Can = "0"; pcan.CanAtend = "0"; pcan.CanAtender = dv.ElementAt(i).Devuelto.ToString(); pcan.Ubicaciones = new List<Ubicacion>(); pcan.CodigoProd = p.CodigoProd; lpcan.Add(pcan); } LstProductos = new List<ProductoCant>(lpcan); } else { if (string.Compare(mot, "Abastecimiento", true) == 0) { List<ProductoCant> psa = new List<ProductoCant>(); ProductoxSolicitudAbSQL pasql = new ProductoxSolicitudAbSQL(); psa = pasql.ListaProductos(SelectedSolicitud.idSolicitudAB.ToString()); List<ProductoCant> lpcan = new List<ProductoCant>(); for (int i = 0; i < psa.Count; i++) { ProductoCant pcan = new ProductoCant(); pcan.IdProducto = psa.ElementAt(i).IdProducto; pcan.Can = psa.ElementAt(i).Can; pcan.CodigoProd = psa.ElementAt(i).CodigoProd; pcan.Nombre = psa.ElementAt(i).Nombre; pcan.CanAtend = "0"; pcan.CanAtender = psa.ElementAt(i).CanAtend; pcan.Ubicaciones = new List<Ubicacion>(); lpcan.Add(pcan); } LstProductos = new List<ProductoCant>(lpcan); } } } } NotifyOfPropertyChange(() => LstProductos); if (LstProductos != null) { EstadoMot = false; Estado = false; } }
public Producto Buscar(string codProducto, int idTienda) { Producto prod = new Producto(); db.cmd.CommandText = "select * from Producto where codProducto=@codProducto"; db.cmd.Parameters.AddWithValue("@codProducto", codProducto); try { if (tipo) db.conn.Open(); SqlDataReader reader = db.cmd.ExecuteReader(); if (!reader.HasRows) { MessageBox.Show("El producto ingreasado no existe en el sistema", "AVISO", MessageBoxButton.OK, MessageBoxImage.Error); return null; } while (reader.Read()) { prod.IdProducto = Convert.ToInt32(reader["idProducto"].ToString()); prod.CodigoProd = reader["codProducto"].ToString(); prod.Nombre = reader["nombre"].ToString(); prod.UnidadMedida = new DataObjects.Almacen.UnidadMedidaSQL().BuscarUnidadById(Convert.ToInt32(reader["idUnidad"].ToString())); } db.cmd.Parameters.Clear(); if (tipo) db.conn.Close(); reader.Close(); db.cmd.Parameters.Clear(); } catch (SqlException e) { MessageBox.Show(e.Message); } db.cmd.CommandText = "select * from ProductoxTienda where idProducto=" + prod.IdProducto + " AND idTienda=" + idTienda; try { if (tipo) db.conn.Open(); SqlDataReader rs = db.cmd.ExecuteReader(); if (!rs.HasRows) { MessageBox.Show("El producto ingresado no esta en la tienda", "AVISO", MessageBoxButton.OK, MessageBoxImage.Error); return null; } while (rs.Read()) { prod.Precio = Double.Parse(rs["precioVenta"].ToString()); } db.cmd.Parameters.Clear(); if (tipo) db.conn.Close(); db.cmd.Parameters.Clear(); rs.Close(); } catch (SqlException e) { MessageBox.Show(e.Message); } return prod; }
public int Insertar(ProveedorxProducto pp) { Producto p = new ProductoSQL().Buscar_por_CodigoProducto(pp.Producto.CodigoProd); int k = 0; if (p != null) { DBConexion DB = new DBConexion(); SqlConnection conn = DB.conn; SqlCommand cmd = DB.cmd; SqlDataReader reader; cmd.CommandText = "IF NOT EXISTS(SELECT 1 from ProveedorxProducto where idProveedor = @idProveedor and idProducto = @idProducto )" + "Insert into ProveedorxProducto(idProducto,idProveedor,codComercial,precio, estado,descripcion,fechaReg,fechaAct) " + "VALUES (@idProducto,@idProveedor,@codComercial,@precio,@estado,@descripcion,GETDATE(),GETDATE() )" + " else " + "UPDATE ProveedorxProducto set fechaAct = GETDATE() , precio = @precio , descripcion = @descripcion ,codComercial = @codComercial " + " , estado = @estado where idProveedor = @idProveedor and idProducto = @idProducto "; cmd.Parameters.AddWithValue("@idProveedor", pp.IdProveedor); cmd.Parameters.AddWithValue("@idProducto", p.IdProducto); cmd.Parameters.AddWithValue("@codComercial", pp.CodComercial); cmd.Parameters.AddWithValue("@precio", pp.Precio); cmd.Parameters.AddWithValue("@estado", 1); cmd.Parameters.AddWithValue("@fechaReg", DateTime.Now); cmd.Parameters.AddWithValue("@fechaAct", DateTime.Now); cmd.Parameters.AddWithValue("@descripcion", pp.Descripcion); cmd.CommandType = CommandType.Text; cmd.Connection = conn; try { conn.Open(); k = cmd.ExecuteNonQuery(); reader = cmd.ExecuteReader(); if (reader.Read()) { p = new Producto(); p.IdProducto = Convert.ToInt32(reader["idProducto"].ToString()); p.Nombre = reader["nombre"].ToString(); p.CodigoProd = reader["codProducto"].ToString(); } conn.Close(); } catch (Exception e) { MessageBox.Show(e.StackTrace.ToString()); } } return k; }
public void BuscarProductos(MadeInHouse.Dictionary.DynamicGrid almacen, MadeInHouse.Dictionary.DynamicGrid ubicacionCol) { if (TxtProducto == null || TxtProducto == "") { _windowManager.ShowWindow(new ProductoBuscarViewModel(_windowManager, this, 7, idTienda)); } else { ProductoCant pc = new ProductoCant(); //Buscar producto del textBox Inicial: if (productoSeleccionado == null) { ProductoSQL prodSQL = new ProductoSQL(); List<Producto> lstProd; lstProd = prodSQL.BuscarProducto(TxtProducto); if (lstProd == null) _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Producto no existente con ese código")); else { pc.Nombre = lstProd[0].Nombre; pc.IdProducto = lstProd[0].IdProducto; pc.CodigoProd = TxtProducto; productoSeleccionado = null; } } else { pc.Nombre = ProductoSeleccionado.Nombre; pc.IdProducto = ProductoSeleccionado.IdProducto; pc.CodigoProd = ProductoSeleccionado.CodigoProd; productoSeleccionado = null; } ubicacionCol.SelectedProduct = pc; almacen.UbicarProducto(pc.IdProducto); pc = null; } }