public void rescatarUltimaVenta() { daoVenta = new VentaDao(); Venta v = (Venta)daoVenta.buscar(""); labelNumeroDeVenta.Content = "venta n° " + (v.IdVenta + 1).ToString("D10"); }
public void agregarProductoToCarroDeCompra(string codigo) { bool repetido = false; if (carroDeComprasList.Count > 0) { foreach (var carro in carroDeComprasList) { if (carro.Codigo == codigo) { repetido = true; if (stockSuficiente(carro.Codigo, (1 + carro.Cantidad))) { carro.Cantidad = carro.Cantidad + 1; carro.SubTotal = carro.Precio * carro.Cantidad; gridCarroDeCompras.Items.Refresh(); break; } else { break; } } } } if (repetido == false) { daoProducto = new ProductoDao(); Producto p = (Producto)daoProducto.buscar(codigoProducto); if (p.Nombre != null) { if (p.Stock >= 1) { carroDeComprasList.Add( new CarroDeCompra { Nombre = p.Nombre, Codigo = codigoProducto, Cantidad = 1, Precio = p.PrecioVenta, SubTotal = (p.PrecioVenta * 1) }); } else { Mensaje mensaje = new Mensaje(); mensaje.labelTexto.Content = "La cantidad seleccionada sobrepasa el stock \ndel producto " + p.Nombre + "." + " El stock máximo es de " + p.Stock + " unidades."; mensaje.Show(); } } else { Mensaje mensaje = new Mensaje(); mensaje.labelTexto.Content = "Este producto aún no ha sido creado en el sistema."; mensaje.Show(); } } }
public VerDetalleVenta(int idVenta) { InitializeComponent(); this.daoDetalleVenta = new DetalleVentaDao(); this.idVenta = idVenta; gridDetalleVenta.Cursor = Cursors.Wait; detalleVentaWorker.DoWork += detalleVentaWorker_DoWork; detalleVentaWorker.RunWorkerCompleted += detalleVentaWorker_RunWorkerComplete; if (!detalleVentaWorker.IsBusy) { detalleVentaWorker.RunWorkerAsync(); } }
public EditarProducto() { InitializeComponent(); cajasDeTexto = new TextBox[6]; cargarCajasDeTexto(); buscarCajasDeTextoVacias = new BuscarTextBoxVacios(); agregarEventosCajas_ComboBox(); daoProducto = new ProductoDao(); daoCategoria = new CategoriaDao(); categoriaWorker.DoWork += categoriaWorker_DoWork; categoriaWorker.RunWorkerCompleted += categoriaWorker_RunWorkerCompleted; categoriaWorker.RunWorkerAsync(); soloNumeros = new SoloNumeros(); }
public CrearProducto() { InitializeComponent(); comproboLaExistenciaDeProducto = false; cajasDeTexto = new TextBox[6]; cargarCajasDeTexto(); buscarCajasDeTextoVacias = new BuscarTextBoxVacios(); agregarEventosCajas_ComboBox(); daoProducto = new ProductoDao(); daoCategoria = new CategoriaDao(); categoriaWorker.DoWork += categoriaWorker_DoWork; categoriaWorker.RunWorkerCompleted += categoriaWorker_RunWorkerCompleted; categoriaWorker.RunWorkerAsync("" /*Buscar vacio*/); soloNumeros = new SoloNumeros(); }
private List <IProviderInfo> GetProvidersInfoInternal(int linkId = -1, FolderType folderType = FolderType.DEFAULT, string searchText = null) { var querySelect = new SqlQuery(TableTitle) .Select("id", "provider", "customer_title", "user_name", "password", "token", "user_id", "folder_type", "create_on", "url") .Where("tenant_id", TenantID); if (folderType == FolderType.USER || folderType == FolderType.DEFAULT && linkId == -1) { querySelect.Where(Exp.Eq("user_id", SecurityContext.CurrentAccount.ID.ToString())); } if (linkId != -1) { querySelect.Where("id", linkId); } if (folderType != FolderType.DEFAULT) { querySelect.Where("folder_type", (int)folderType); } if (!string.IsNullOrEmpty(searchText)) { querySelect.Where(AbstractDao.BuildSearch("customer_title", searchText)); } try { using (var db = GetDb()) { return(db.ExecuteList(querySelect).ConvertAll(ToProviderInfo).Where(p => p != null).ToList()); } } catch (Exception e) { Global.Logger.Error(string.Format("GetProvidersInfoInternal: linkId = {0} , folderType = {1} , user = {2}", linkId, folderType, SecurityContext.CurrentAccount.ID), e); return(new List <IProviderInfo>()); } }
private void botonGuardarVenta_Click(object sender, RoutedEventArgs e) { if (gridCarroDeCompras.Items.Count > 0) { MontoDePago monto = new MontoDePago(); monto.labelTotal.Content = labelTotalCarritoDeCompras.Content; monto.ShowDialog(); if (monto.DialogResult.HasValue && monto.DialogResult.Value) { daoVenta = new VentaDao(); Venta venta = new Venta(); venta.Total = Convert.ToInt32(labelTotalCarritoDeCompras.Content);//monto total de la venta venta.Fecha = DateTime.Now; venta.Anulada = false; int idVenta = 0; idVenta = daoVenta.crear(venta); if (idVenta > 0) { daoDetalleVenta = new DetalleVentaDao(); foreach (var carro in carroDeComprasList) { DetalleVenta detalleVenta = new DetalleVenta(); detalleVenta.IdVenta = idVenta; detalleVenta.IdProducto = carro.Codigo; detalleVenta.PrecioVenta = carro.Precio; detalleVenta.Cantidad = carro.Cantidad; detalleVenta.SubTotal = carro.SubTotal; detalleVenta.Anulado = false; if (daoDetalleVenta.crear(detalleVenta) != 2) { MessageBox.Show("No se ha podido completar la operación", "Mensaje del sistema", MessageBoxButton.OK, MessageBoxImage.Error); break; } } reiniciarElemntosDeCarroDeCompras(); cargoProductos = false; cargoVentas = false; rescatarUltimaVenta(); MessageBox.Show("¡La venta fue guardada en el sistema!", "Mensaje del sistema", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("No se ha podido completar la operación", "Mensaje del sistema", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("La venta ha sido cancelada.", "Mensaje del sistema", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBoxResult result = MessageBox.Show("Debe haber productos para guardar una nueva venta", "Mensaje del sistema", MessageBoxButton.OK, MessageBoxImage.Exclamation); if (result == MessageBoxResult.OK) { checkComenzarToEscanear.Focus(); } } }
public EditarCategoria() { InitializeComponent(); daoCategoria = new CategoriaDao(); }