private void btnAgregar_Click(object sender, EventArgs e) { if (cantidadTextBox.Text.Equals("0") || precioCompraTextBox.Text.Equals("0") || idProductoCComboBox.SelectedValue == null || totalProductoTextBox.Text.Equals("0")) { MessageBox.Show("Debe Ingresar todos los campos"); } else { Compras totalcompra = new Compras(); detalles = (DetallesCompra)detallesCompraBindingSource.Current; totalcompra = (Compras)comprasBindingSource.Current; totalcompra.totalaPagar = totalcompra.totalaPagar + detalles.totalProducto; comprasBindingSource.DataSource = totalcompra; listaDetalles.Add(detalles); compras.AgregarDetalles(detalles); detallesCompraBindingSource.EndEdit(); detallesCompraBindingSource.AddNew(); detallesCompraBindingSource1.DataSource = listaDetalles; detallesCompraBindingSource1.ResetBindings(true); idProveedorComboBox.Enabled = false; } }
private bool DetalleRepetido(int id) { if (DetallesCompra.Any(dc => dc.ID_ITEM == id)) { MessageBox.Show("Detalle repetido.", Application.Current.Resources["NombreAplicacion"].ToString(), MessageBoxButton.OK, MessageBoxImage.Exclamation); return(true); } return(false); }
public void EliminarDetalleCompra(DetallesCompra dc) { IDbConnection cn = Conexion.Conexion.Conectar(); DynamicParameters paramentros = new DynamicParameters(); paramentros.Add("@id", dc.idDetalleCompra, DbType.Int32); cn.Open(); cn.Execute("sp_EliminarDetalleCompra", paramentros, commandType: CommandType.StoredProcedure); cn.Close(); }
public void Guardar() { try { if (ClsVerificarCaja.CajaEstado()) { if (ClsVerificarCaja.SaldoEnCaja() >= Convert.ToDecimal(txtTotalCompra.EditValue)) { if ((int)txtCveCompra.EditValue == 0) { Compra entity = new Compra { CveUsuario = Convert.ToInt32(new clsModificarConfiguracion().configGetValue("IDUsuarioApp")), TotalCompra = Convert.ToDecimal(txtTotalCompra.EditValue), FechaCompra = DateTime.Today.Date, Estado = true }; txtCveCompra.EditValue = new LogicaCompras().AgregarCompra(entity); foreach (DataRow fila in _dtArticulos.Rows) { DetallesCompra detcomp = new DetallesCompra { CveCompra = entity.CveCompra, PesoCantidad = Convert.ToDecimal(fila[1]), TipodeCompra = fila[0].ToString(), PrecioCompra = Convert.ToDecimal(fila[2]), TotalPrecioArticulo = Convert.ToDecimal(fila[3]), }; new LogicaCompras().AgregarDetalle(detcomp); } ImprimirNotaCompra(); } else { XtraMessageBox.Show("Ya se ha Guardado la compra solo se puede Imprimir el Ticket ", "Datos Guardados"); ImprimirNotaCompra(); } //Nuevo(); } else { XtraMessageBox.Show("No puede Comprar mas de lo disponible en la CAJA Actual"); } } else { XtraMessageBox.Show("La Caja del Dia de hoy ya se ha cerrado\n SISTEMA BLOQUEADO", "Caja Cerrada", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "Error al Guardar la compra"); } }
private void cantidadTextBox_TextChanged(object sender, EventArgs e) { if (cantidadTextBox.Text != "" && precioCompraTextBox.Text != "") { int cantidad = Convert.ToInt32(cantidadTextBox.Text); float precio = float.Parse(precioCompraTextBox.Text); detalles = (DetallesCompra)detallesCompraBindingSource.Current; detalles.totalProducto = (precio * cantidad); detallesCompraBindingSource.DataSource = detalles; } }
private void AgregarDetalle() { var ventanaDetalle = new EdicionDetalleCompra { DataContext = new EdicionDetalleCompraViewModel(true, new DETALLE_COMPRA()) }; var resultado = ventanaDetalle.ShowDialog(); if (resultado.HasValue && resultado.Value && !DetalleRepetido(((EdicionDetalleCompraViewModel)ventanaDetalle.DataContext).DetalleCompra.ID_ITEM)) { DetallesCompra.Add(((EdicionDetalleCompraViewModel)ventanaDetalle.DataContext).DetalleCompra); } }
internal void guardarCompra(Compras C) { DetallesCompra detalles = new DetallesCompra(); mCompra.guardarCompra(C); for (int i = 0; i < C.detalles.Count; i++) { detalles = C.detalles[i]; detalles.idCompra = retornoId(); CDetalles.guardarDetallesCompra(detalles); } mCompra.procesarCompra(retornoId()); }
public void RegistrarDetalleCompra(DetallesCompra dc) { IDbConnection cn = Conexion.Conexion.Conectar(); DynamicParameters paramentros = new DynamicParameters(); paramentros.Add("@idCompra", dc.idCompra, DbType.Int32); paramentros.Add("@idInventario", dc.idInventario, DbType.Int32); paramentros.Add("@cantidad", dc.cantidad, DbType.Int32); paramentros.Add("@precio", dc.precio, DbType.Double); paramentros.Add("@total", dc.total, DbType.Double); cn.Open(); cn.Execute("sp_InsertarDetalleCompra", paramentros, commandType: CommandType.StoredProcedure); cn.Close(); }
private void QuitarDetalle() { DetallesCompra.Remove(DetalleCompraSeleccionado); }
private bool PuedoGrabar() { return(DetallesCompra.Count() > 0); }
public void AgregarDetalle(DetallesCompra detalle) { _entidades.DetallesCompras.InsertOnSubmit(detalle); _entidades.SubmitChanges(); }
private void btnComprar_Click(object sender, EventArgs e) { if (dtvDetallesCompra.Rows.Count == 0) { MessageBox.Show("¡Aún no hay nada en el carrito!", "Carrito Vacío", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { DialogResult result = MessageBox.Show("¿Desea agregar algo más antes de comprar?", "Validación", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { using (RestauranteBDEntities1 bd = new RestauranteBDEntities1()) { Compraas compra = new Compraas(); String nombre = lblUsuario.Text; compra.fechadeCompra = Convert.ToDateTime(dtpFecha.Text); compra.totalaPagar = Convert.ToDecimal(lblTotalAPagar.Text); compra.idProveedor = Convert.ToInt32(provee); compra.nombredeUsuario = nombre.ToString(); int idProv = int.Parse(provee); proveedor = bd.Proveedores.Where(Id => Id.idProveedor == idProv).First(); proveedor.estado = "Activo"; bd.Entry(proveedor).State = System.Data.Entity.EntityState.Modified; bd.SaveChanges(); bd.Compraas.Add(compra); bd.SaveChanges(); DetallesCompra detalleC = new DetallesCompra(); for (int i = 0; i < dtvDetallesCompra.RowCount; i++) { String idProdC = dtvDetallesCompra.Rows[i].Cells[0].Value.ToString(); int idProdConv = Convert.ToInt32(idProdC); String cantidad = dtvDetallesCompra.Rows[i].Cells[3].Value.ToString(); int cantiConver = Convert.ToInt32(cantidad); String precio = dtvDetallesCompra.Rows[i].Cells[2].Value.ToString(); Double precioConv = Convert.ToDouble(precio); String total = dtvDetallesCompra.Rows[i].Cells[4].Value.ToString(); Decimal totalConv = Convert.ToDecimal(total); detalleC.idCompra = Convert.ToInt32(lblCodigo.Text); detalleC.idProductoC = idProdConv; detalleC.cantidad = cantiConver; detalleC.precioCompra = precioConv; detalleC.totalProducto = totalConv; int idProd = idProdConv; prodCompra = bd.ProductosCompra.Where(Id => Id.idProductoC == idProd).First(); prodCompra.estado = "Activo"; bd.Entry(prodCompra).State = System.Data.Entity.EntityState.Modified; bd.SaveChanges(); bd.DetallesCompra.Add(detalleC); bd.SaveChanges(); Almacen almaceen = new Almacen(); var lista = from almacen in bd.Almacen where almacen.idProductoC == idProdConv select almacen; if (lista.Count() > 0) { int idA = int.Parse(dtvDetallesCompra.Rows[i].Cells[0].Value.ToString()); int CantidadProd = int.Parse(dtvDetallesCompra.Rows[i].Cells[3].Value.ToString()); almaceen = bd.Almacen.Where(VerificarID => VerificarID.idProductoC == idA).First(); almaceen.cantidadDisponible = almaceen.cantidadDisponible + CantidadProd; bd.Entry(almaceen).State = System.Data.Entity.EntityState.Modified; bd.SaveChanges(); } else { almaceen.idProductoC = idProdConv; almaceen.cantidadDisponible = int.Parse(dtvDetallesCompra.Rows[i].Cells[3].Value.ToString()); bd.Almacen.Add(almaceen); bd.SaveChanges(); } } MessageBox.Show("¡Venta Realizada con éxito! \n\nCON UN TOTAL DE: $" + lblTotalAPagar.Text, "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cmbProveedores.Enabled = true; dtvDetallesCompra.Rows.Clear(); } RetornoId(); txtCodigoProd.Text = ""; txtNombreProd.Text = ""; txtPrecio.Text = ""; nupCantidad.Value = 0; txtTotal.Text = ""; } } }
public void EliminarDetalleCompra(DetallesCompra dc) { mDetallesCompra.EliminarDetalleCompra(dc); }
public void RegistrarDetalleCompra(DetallesCompra dc) { mDetallesCompra.RegistrarDetalleCompra(dc); }
internal void guardarDetallesCompra(DetallesCompra DC) { mDetalles.guardarDetallesCompra(DC); }