public void EditarVenta(int pk, String des, String idClient, String name, String email, String phone, double dis) { FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Sale_Bill Venta = dc.Sale_Bill.First(c => c.SalBil_Pk == pk); Venta.SalBil_Description = des; Venta.SalBil_IdClient = idClient; Venta.SalBil_ClientName = name; Venta.SalBil_ClientEmail = email; Venta.SalBil_PhoneClient = phone; double cGross = 0; foreach (BOP_FAJAS_spListarDetalleVentasResult DBB in spListarDetalleVentas(pk)) { cGross += Convert.ToDouble(DBB.Pro_SalePrice * DBB.DetSalBil_Quantity - DBB.DetSalBil_Detail); Product_Detail Producto = dc.Product_Detail.FirstOrDefault(c => c.ProDet_PK == DBB.DetBil_FK_ProDet); Producto.ProDet_Quantity -= (int)DBB.DetSalBil_Quantity; dc.SubmitChanges(); } Venta.SalBil_GrossTotal = cGross; Venta.SalBil_Tax = cGross * 0.13; Venta.SalBil_Discount = dis; Venta.SalBil_NetTotal = cGross - dis + cGross * 0.13; Venta.SalBil_Status = "A"; dc.SubmitChanges(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString.Count != 0) { string sPK = Request.QueryString["Ve"].ToString(); string sES = Request.QueryString["Es"].ToString(); if (!sPK.Equals("")) { Venta = MV.ConsultarVenta(Convert.ToInt32(Request.QueryString["Ve"].ToString())); if (sES.Equals("A")) { btnAgregarVenta.Text = "Eliminar"; formulario.Visible = false; btnVerFactura.Visible = true; } AsigarVenta(Venta); } if (sPK.Equals("")) { Response.Redirect("Ventas.aspx"); } } } }
public Sale_Bill RegistrarVenta() { FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Sale_Bill Venta = new Sale_Bill(); Venta.SalBil_Date = DateTime.Now; Venta.SalBil_Description = ""; Venta.SalBil_IdClient = ""; Venta.SalBil_ClientName = ""; Venta.SalBil_ClientEmail = ""; Venta.SalBil_PhoneClient = ""; Venta.SalBil_Discount = 0; Venta.SalBil_GrossTotal = 0; Venta.SalBil_NetTotal = 0; Venta.SalBil_Tax = 0; Venta.SalBil_FK_Com = 1; Venta.SalBil_Status = "P"; dc.Sale_Bill.InsertOnSubmit(Venta); dc.SubmitChanges(); return(Venta); }
protected void btnCancelarVenta_Click(object sender, EventArgs e) { Venta = MV.ConsultarVenta(Convert.ToInt32(Request.QueryString["Ve"].ToString())); if (Venta.SalBil_Status.Equals("P")) { MV.EliminarVenta(Venta.SalBil_Pk); } Response.Redirect("Ventas.aspx"); }
protected void btnAgregar_Click(object sender, EventArgs e) { if (!txtProducto.Text.Equals("") && !txtCantidad.Text.Equals("") && !txtPrecio.Text.Equals("")) { Venta = MV.ConsultarVenta(Convert.ToInt32(Request.QueryString["Ve"].ToString())); Subtotal = Subtotal + MV.RegistrarDetalleVenta(Venta.SalBil_Pk, Convert.ToInt32(ddlProductos.SelectedValue), Convert.ToDouble(txtPrecio.Text), Convert.ToInt32(txtCantidad.Text)); dgDetalle.DataBind(); } Totales(); }
protected void AsigarVenta(Sale_Bill bill) { txtDescripcion.Text = bill.SalBil_Description; txtCedula.Text = bill.SalBil_IdClient; txtCorreo.Text = bill.SalBil_ClientEmail; txtNombre.Text = bill.SalBil_ClientName; txtTelefono.Text = bill.SalBil_PhoneClient; txtDescuento.Text = bill.SalBil_Discount.ToString(); lblSubTotal.Text = "SubTotal: ₡" + bill.SalBil_GrossTotal.ToString(); lblDescuento.Text = "Descuento: ₡" + bill.SalBil_Discount.ToString(); lblImpuesto.Text = "13% IVI: ₡" + bill.SalBil_Tax.ToString(); lblNeto.Text = "TOTAL: ₡" + bill.SalBil_NetTotal.ToString(); }
protected void btnAgregarVenta_Click(object sender, EventArgs e) { if (((Button)sender).Text.Equals("Guardar")) { Venta = MV.ConsultarVenta(Convert.ToInt32(Request.QueryString["Ve"].ToString())); MV.EditarVenta(Venta.SalBil_Pk, txtDescripcion.Text, txtCedula.Text, txtNombre.Text, txtCorreo.Text, txtTelefono.Text, Convert.ToDouble(txtDescuento.Text)); Response.Redirect("MantenimientoVenta.aspx?Ve=" + Venta.SalBil_Pk + "&Es=A"); } if (((Button)sender).Text.Equals("Eliminar")) { Venta = MV.ConsultarVenta(Convert.ToInt32(Request.QueryString["Ve"].ToString())); MV.EliminarVenta(Venta.SalBil_Pk); Response.Redirect("Ventas.aspx"); } }
public void EliminarVenta(int pk) { FAJA_MODELDataContext dc = new FAJA_MODELDataContext(); Sale_Bill Venta = dc.Sale_Bill.First(c => c.SalBil_Pk == pk); if (Venta.SalBil_Status.Equals("A")) { foreach (BOP_FAJAS_spListarDetalleVentasResult DBB in spListarDetalleVentas(pk)) { Product_Detail Producto = dc.Product_Detail.FirstOrDefault(c => c.ProDet_PK == DBB.DetBil_FK_ProDet); Producto.ProDet_Quantity += (int)DBB.DetSalBil_Quantity; dc.SubmitChanges(); } } Venta.SalBil_Status = "I"; dc.SubmitChanges(); }