protected void Page_Load(object sender, EventArgs e) { Utilidades.SCritpValidacion(); if (!Page.IsPostBack) { LlenarDropCliente(); LlenarDrop(); dt.Columns.AddRange(new DataColumn[5] { new DataColumn("ID Articulo"), new DataColumn(" Precio"), new DataColumn("Cantidad"), new DataColumn("Nombre"), new DataColumn("ITBS") }); ViewState["Detalle"] = dt; artig = new Entidades.Articulos(); listadoArticulos = new List <Entidades.Articulos>(); listaRelaciones = new List <Entidades.FacturaDetalles>(); facturaG = new Entidades.Facturas(); DropDownTipoVenta.Text = ""; } }
protected void Buscar_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(TextBoxBuscar.Text)) { Utilidades.ShowToastr(this, "ID Vacio", "Resultados", "error"); } else { int id = Utilidades.TOINT(TextBoxBuscar.Text); facturaG = BLL.FacturaBLL.Buscarb(f => f.IdFactura == id); if (facturaG != null) { limpiar(); listaRelaciones = BLL.FacturaDetallesBLL.GetList(A => A.IdFactura == facturaG.IdFactura); TextBoxBuscar.Text = facturaG.IdFactura.ToString(); if (facturaG != null) { if (listaRelaciones.Count == 0) { Utilidades.ShowToastr(this, "No se ha registrado Articulos con este ID", "Resultados", "error"); } else { TextBoxVendedor.Text = facturaG.NombreUsuario; TexboxClienteCompro.Text = facturaG.Cliente; TexboxCantidad.Text = Convert.ToString(facturaG.CantidadProd); TextFecha.Text = Convert.ToString(facturaG.FechaVenta); TextBoxTotal.Text = Convert.ToString(facturaG.Total); DropDownTipoVenta.Text = Convert.ToString(facturaG.TipoVenta); DropDownTipoVenta.Enabled = false; DropDownCliente.Enabled = false; Agregar.Enabled = false; DropArticulo.Enabled = false; TextBoxCantidad.Enabled = false; BotonCalcularDevuelta.Enabled = false; TextMontoRecibido.Enabled = false; ButtonGurdar.Enabled = false; DescuentoTextBox.Enabled = false; foreach (var relacion in listaRelaciones) { listadoArticulos.Add(BLL.ArticuloBLL.Buscar(A => A.IdArticulo == relacion.IdArticulo)); } LlenarRegistro(listaRelaciones); Utilidades.ShowToastr(this, "Sus Resultados", "Resultados", "success"); } } } else { Utilidades.ShowToastr(this, "No existe factura", "Error", "error"); limpiarFac(); } } }
public void EliminaTest() { int id = 55; factura = BLL.FacturaBLL.Buscar(c => c.IdFactura == id); Assert.IsTrue(FacturaBLL.Eliminar(factura)); }
public void LlenarDataGrid(Entidades.Facturas factura) { ProductodataGridView.DataSource = null; ProductodataGridView.DataSource = factura.Relacion.ToList(); this.ProductodataGridView.Columns["Id"].Visible = false; this.ProductodataGridView.Columns["FacturaId"].Visible = false; this.ProductodataGridView.Columns["Producto"].Visible = false; }
public void ModificarTest() { int id = 55; factura = BLL.FacturaBLL.Buscar(c => c.IdFactura == id); factura.Total = 200; Assert.IsTrue(FacturaBLL.Mofidicar(factura)); }
private void Limpiar() { factura = new Entidades.Facturas(); facturaIdTextBox.Clear(); fechaDateTimePicker.Value = DateTime.Today; costoMaskedTextBox.Clear(); precioMaskedTextBox.Clear(); importeMaskedTextBox.Clear(); cantidadNumericUpDown.Value = 0; CamposVacioserrorProvider.Clear(); DetalledataGridView.DataSource = null; productosComboBox.Text = null; }
private void Guardarbutton_Click(object sender, EventArgs e) { if (Validar()) { if (FormaPagoComboBox.Text == "Contado") { if (string.IsNullOrEmpty(RecibidomaskedTextBox.Text)) { RecibidoerrorProvider.SetError(RecibidomaskedTextBox, "Por favor llenar el campo."); } else if (string.IsNullOrEmpty(DevueltatextBox.Text)) { DevueltaerrorProvider.SetError(DevueltatextBox, "Por favor llenar el campo."); } else { Factura = LlenarCampos(); if (BLL.FacturasBLL.Guardar(Factura)) { ReducirExistenciaProducto(CantidadnumericUpDown.Value); FacturaIdmaskedTextBox.Text = Factura.FacturaId.ToString(); MessageBox.Show("Guardado con exito."); RecibidomaskedTextBox.Enabled = false; } else { MessageBox.Show("Error! no se pudo guardar."); } } } else if (FormaPagoComboBox.Text == "Credito") { Factura = LlenarCampos(); if (BLL.FacturasBLL.Guardar(Factura)) { FacturaIdmaskedTextBox.Text = Factura.FacturaId.ToString(); ReducirExistenciaProducto(CantidadnumericUpDown.Value); MessageBox.Show("Guardado con exito."); RecibidomaskedTextBox.Enabled = false; } else { MessageBox.Show("Error! no se pudo guardar."); } } } }
public void BuscarTest() { int id = 55; //ID Varia dependiendo lo registrado en la base de datos bool bandera = false; factura = FacturaBLL.Buscar(p => p.IdFactura == id); if (factura != null) { bandera = true; } else { bandera = false; } Assert.IsTrue(bandera); }
public static bool Eliminar(Entidades.Facturas factura) { using (var Context = new DAL.Respository <Entidades.Facturas>()) { try { return(Context.Eliminar(factura)); } catch (Exception) { throw; } } return(false); }
protected void Button3_Click(object sender, EventArgs e) { var user = BLL.UserBLL.Buscar(p => p.NombreUsuario == Base.Usuario); if (user.Tipo != "Administrador") { Utilidades.ShowToastr(this, "No es Administrador", "Error", "error"); } else { if (string.IsNullOrWhiteSpace(TextBoxBuscar.Text)) { Utilidades.ShowToastr(this, "Campo Id Vacio", "Error", "info"); } else { int id = Utilidades.TOINT(TextBoxBuscar.Text); facturaG = BLL.FacturaBLL.Buscarb(f => f.IdFactura == id); if (facturaG != null) { if (BLL.FacturaBLL.EliminarRelacion(facturaG)) { SumarExistencia(); limpiar(); facturaG = new Entidades.Facturas(); Utilidades.ShowToastr(this, "Elimino Correctamente", "ELIMINADO", "success"); } else { Utilidades.ShowToastr(this, "Problemas Al Eliminar", "Error", "error"); } } else { Utilidades.ShowToastr(this, "No hay Factura", "Informacion", "info"); } } } }
public static Entidades.Facturas Buscar(int id) { var factura = new Entidades.Facturas(); using (var conec = new DAL.FacturacionDb()) { try { factura = conec.Factura.Find(id); factura.Productos.Count(); } catch (Exception) { throw; } } return(factura); }
public void LlenarDatos(Entidades.FacturaDetalles detalle) { int id = 0; int idCliente = 0; int cantidad = 0; idCliente = Utilidades.TOINT(DropDownCliente.Text); var clientec = BLL.ClientesBLL.Buscar(p => p.ClienteId == idCliente); if (facturaG != null) { id = facturaG.IdFactura; } foreach (GridViewRow dr in FacturaGrid.Rows) { detalle.AgregarDetalle(Convert.ToInt32(dr.Cells[0].Text), 0, 0, Convert.ToDecimal(dr.Cells[1].Text), Convert.ToInt32(dr.Cells[2].Text), Convert.ToString(dr.Cells[3].Text), Convert.ToDecimal(dr.Cells[4].Text) ); cantidad++; BotonCalcularDevuelta.Focus(); CalcularMonto(); } if (TextBoxTotal.Text == "" && TextBoxSubTotal.Text == "") { CalcularMonto(); } else { if (clientec != null) { facturaG = new Entidades.Facturas(0, Base.Usuario, DateTime.Now, clientec.Nombres, DropDownTipoVenta.Text, cantidad, Convert.ToDecimal(TextBoxTotal.Text)); } else { Utilidades.ShowToastr(this, "Error cliente vacio", "error"); } } }
private void Guardarbutton_Click(object sender, EventArgs e) { if (!Validar()) { MessageBox.Show("Por favor llenar los campos vacios."); } else { factura = LlenarCampos(); if (BLL.FacturasBLL.GuardarBLL(factura)) { MessageBox.Show("Factura Guardada."); } else { MessageBox.Show("No se guardo."); } } Limpiar(); }
private void Limpiar() { Detalle = new Entidades.FacturasProductos(); Factura = new Entidades.Facturas(); FacturaIdmaskedTextBox.Clear(); ClienteIdmaskedTextBox.Clear(); NombreClientetextBox.Clear(); MontotextBox.Clear(); FechadateTimePicker.Value = DateTime.Now; ProductoIdmaskedTextBox.Clear(); DescripcionProductotextBox.Clear(); ProductodataGridView.DataSource = null; CantidadnumericUpDown.Value = 0; PreciotextBox.Clear(); DevueltatextBox.Clear(); RecibidomaskedTextBox.Clear(); ComentariotextBox.Clear(); NombreClienteerrorProvider.Clear(); CantidaderrorProvider.Clear(); ProductoerrorProvider.Clear(); RecibidoerrorProvider.Clear(); GriderrorProvider.Clear(); ClienteIderrorProvider.Clear(); FacturaIderrorProvider.Clear(); DevueltaerrorProvider.Clear(); FormaPagoComboBox.Text = null; ClienteIdmaskedTextBox.Enabled = true; ProductoIdmaskedTextBox.Enabled = true; FechadateTimePicker.Enabled = true; ComentariotextBox.Enabled = true; FormaPagoComboBox.Enabled = true; ProductodataGridView.Enabled = true; RecibidomaskedTextBox.Enabled = false; FacturaIdmaskedTextBox.Enabled = true; CantidadnumericUpDown.Enabled = false; }
public static bool GuardarBLL(Entidades.Facturas factura) { using (var conec = new DAL.FacturacionDb()) { try { conec.Factura.Add(factura); foreach (var g in factura.Productos) { conec.Entry(g).State = System.Data.Entity.EntityState.Unchanged; } conec.SaveChanges(); return(true); } catch (Exception) { throw; } } }
private void VerificarExistenciaFactura() { int id = Utilidades.TOINT(FacturaIdmaskedTextBox.Text); Factura = BLL.FacturasBLL.Buscar(p => p.FacturaId == id); }
private void LlenarGrid(Entidades.Facturas factura) { DetalledataGridView.DataSource = null; DetalledataGridView.DataSource = factura.Productos; }