public void InsertarVentas(Entidades.Venta entidad) { try { SqlCommand sqlCommand = new SqlCommand("proc_VentasInsert", Conexion.SqlConnection); sqlCommand.CommandTimeout = 20; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@factura", entidad.Factura); sqlCommand.Parameters.AddWithValue("@FECHA", entidad.Fecha); sqlCommand.Parameters.AddWithValue("@ID_CLIENTE", entidad.IdCliente); sqlCommand.Parameters.AddWithValue("@ID_VENDEDOR", entidad.IdVendedor); sqlCommand.Parameters.AddWithValue("@ID_PROD", entidad.IdProduccto); sqlCommand.Parameters.AddWithValue("@CANTIDAD", entidad.Cantidad); if (Conexion.SqlConnection.State == System.Data.ConnectionState.Closed) { Conexion.SqlConnection.Open(); } sqlCommand.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show("No se pudo Escribir " + ex.Message, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { if (Conexion.SqlConnection.State == System.Data.ConnectionState.Open) { Conexion.SqlConnection.Close(); } } }
public void RebajarConceptos(Entidades.Venta entidad) { try { SqlCommand sqlCommand = new SqlCommand("proc_VentasRebajar", Conexion.SqlConnection); sqlCommand.CommandTimeout = 20; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@ID_PROD", entidad.IdProduccto); sqlCommand.Parameters.AddWithValue("@CANTIDAD", entidad.Cantidad); if (Conexion.SqlConnection.State == System.Data.ConnectionState.Closed) { Conexion.SqlConnection.Open(); } sqlCommand.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show("No se pudo Escribir " + ex.Message, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { if (Conexion.SqlConnection.State == System.Data.ConnectionState.Open) { Conexion.SqlConnection.Close(); } } }
private void actualizarGanancia() { Entidades.Venta entVentas = new Entidades.Venta(); DataSet Ds = new DataSet(); Ds.Reset(); Ds = entVentas.obtenerGanancia(DateTime.Parse(dtpFechaCaja.Text.ToString()), DateTime.Parse(dtpFechaCaja.Text.ToString())); lblGanancia.Text = Ds.Tables[0].Rows[0]["Ganancia"].ToString(); }
private void actualizarGanancia() { Entidades.Venta entVentas = new Entidades.Venta(); DataSet Ds = new DataSet(); Ds.Reset(); Ds = entVentas.obtenerGanancia(fg.appFechaSistema(), fg.appFechaSistema()); lblGanancia.Text = Ds.Tables[0].Rows[0]["Ganancia"].ToString(); }
/// <summary> /// Loopea entre todos los consignatarios y devuelve una lista de todas las tablas de ventas /// </summary> /// <param name="lista"></param> /// <returns></returns> public static List <Entidades.Venta> srapTablaVentas(List <Entidades.Venta> lista) { #region Iniciar driver IWebDriver driver = null; while (!success & retry > 0) { try { driver = General.SeleniumUtility.iniciarDriver(driver, "firefox"); driver.Navigate().GoToUrl("http://www.mercadodeliniers.com.ar/dll/hacienda1.dll/haciinfo000007"); success = true; } catch (Exception e) { Console.WriteLine("MONEDA: Error al iniciar el driver"); retry--; } } #endregion int cant_consignatarios = driver.FindElements(By.XPath("/html/body/table/tbody/tr[1]/td/table[2]/tbody/tr/td/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td[1]/table/tbody/tr[3]/td[2]/select/option")).Count; DateTime fechadato = Convert.ToDateTime(driver.FindElement(By.XPath("//*[@id='datepicker1']")).GetAttribute("value")); for (int i = 1; i <= cant_consignatarios; i++) { // datos generales de la venta Entidades.Venta venta = new Entidades.Venta(); venta.id = 1; venta.fecha = fechadato; venta.especie = "vacunos"; venta.tipo = "faena"; // agregamos el consignatario IWebElement consignatarioweb = driver.FindElement(By.XPath("/html/body/table/tbody/tr[1]/td/table[2]/tbody/tr/td/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td[1]/table/tbody/tr[3]/td[2]/select/option[" + i + "]")); IWebElement ddlconsignatarios = driver.FindElement(By.XPath("/html/body/table/tbody/tr[1]/td/table[2]/tbody/tr/td/table/tbody/tr[1]/td[1]/table/tbody/tr[2]/td[1]/table/tbody/tr[3]/td[2]/select")); Entidades.Consignatario consignatario = new Entidades.Consignatario(); consignatario.id = 1; consignatario.nombre = consignatarioweb.Text; venta.consignatario = consignatario; consignatarioweb.Click(); driver.FindElement(By.XPath("//input[@id='Aceptar']")).Click(); // agregamos los items venta = scrapVentasxConsignatario(driver, venta); lista.Add(venta); } driver.Quit(); return(lista); }
//-------------------------- //CODIGO DEL BOTON DE GRABAR //-------------------------- private void Grabar() { try { if (VentaNegocio == null) { VentaNegocio = new Negocios.Venta(); } string factura = Factura(); //Verificar si existe el No. de Record bool valida = false; valida = Convert.ToBoolean(VentaNegocio.MostrarBuscar(factura)); if (TextBox_Vendedor.Text == string.Empty && TextBox_Cliente.Text == string.Empty) { MessageBox.Show("Agregar Vendedor y Cliente"); } else { if (DGV_Data.Rows.Count > 0) { if (VentaEntidad == null) { VentaEntidad = new Entidades.Venta(); } VentaEntidad.Factura = factura; VentaEntidad.Fecha = DateTime.Now; VentaEntidad.IdCliente = int.Parse(TextBox_Cliente.Text); VentaEntidad.IdVendedor = int.Parse(TextBox_Vendedor.Text); for (int i = 0; i <= DGV_Data.Rows.Count - 1; i++) { VentaEntidad.IdProduccto = Convert.ToInt16(DGV_Data.Rows[i].Cells[0].Value.ToString()); VentaEntidad.Cantidad = Convert.ToInt16(DGV_Data.Rows[i].Cells[2].Value.ToString()); VentaNegocio.InsertarVentas(VentaEntidad); } TicketFactura(); SetupColumnsCargadas(); LimpiarProductos(); TextBox_Cliente.Text = string.Empty; TextBox_Vendedor.Text = string.Empty; Label_MostrarTotalPagar.Text = string.Empty; MessageBox.Show("Gracias por preferirnos"); } } } catch (Exception ex) { MessageBox.Show("Error:" + ex); } }
private void btnConfirmarVenta_Click(object sender, EventArgs e) { try { Entidades.Venta Venta = new Entidades.Venta(); Venta.guardarVentaYSusArticulos(); ponerValoresEnDefault(); fg.eliminarBotones(grdItemsVenta, "SELECCIONAR"); Venta.actualizaMovimientoVentas(fg.appFechaSistema()); MessageBox.Show("Venta confirmada correctamente.", "Venta Confirmada.", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); } }
private void aceptarArticulo() { try { if (!(validarBusqueda())) { return; } //MessageBox.Show("Seleccionó ID: " + DsArt.Tables[0].Rows[0]["CÓDIGO"].ToString() + " DESCRIPCION: " + DsArt.Tables[0].Rows[0]["DESCRIPCIÓN"].ToString()); Entidades.Articulo Articulo = new Entidades.Articulo(); Entidades.Venta Venta = new Entidades.Venta(); DataSet DsArticulo = new DataSet(); UInt64 IdArticulo; Int32 Cantidad; if (txtCantidad.Text.Trim() == "") { txtCantidad.Text = "1"; } IdArticulo = UInt64.Parse(grdResultados.Rows[filaSeleccionada].Cells["ID"].Value.ToString()); DsArticulo = Articulo.obtenerArticulos(IdArticulo.ToString()); if (DsArticulo.Tables[0].Rows.Count > 0) { IdArticulo = UInt64.Parse(DsArticulo.Tables[0].Rows[0]["CÓDIGO"].ToString()); Cantidad = Int32.Parse(txtCantidad.Text); Venta.guardarArticuloVentaTemporal(IdArticulo, Cantidad); } else { MessageBox.Show("Artículo inexistente en la Base de Datos"); } this.Close(); } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); } }
/// <summary> /// Scrapea los valores para cada fila de la tabla de ventas para un consignatario específico /// </summary> /// <param name="driver"></param> /// <param name="venta"></param> /// <returns></returns> public static Entidades.Venta scrapVentasxConsignatario(IWebDriver driver, Entidades.Venta venta) { IList <IWebElement> ventasweb = driver.FindElements(By.XPath("/html/body/table/tbody/tr[1]/td/table[2]/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr")); if (ventasweb.Count == 1) { return(null); } foreach (IWebElement ventaweb in ventasweb) { Entidades.ItemVenta item = new Entidades.ItemVenta(); item.id = 1; try { item.remitente = ventaweb.FindElement(By.XPath(".//td[1]")).Text; } catch (Exception) { continue; } if (item.remitente.Trim() == "Total") { continue; } item.localidad = ventaweb.FindElement(By.XPath(".//td[2]")).Text; item.provincia = ventaweb.FindElement(By.XPath(".//td[3]")).Text; item.cabezas = Convert.ToInt32(ventaweb.FindElement(By.XPath(".//td[4]")).Text); item.categoria = ventaweb.FindElement(By.XPath(".//td[5]")).Text; item.kgs = Convert.ToDouble(ventaweb.FindElement(By.XPath(".//td[6]")).Text); item.promedio = Convert.ToDouble(ventaweb.FindElement(By.XPath(".//td[7]")).Text); item.precio = Convert.ToDouble(ventaweb.FindElement(By.XPath(".//td[8]")).Text); venta.items.Add(item); } return(venta); }
private void btnAceptar_Click(object sender, EventArgs e) { try { //MessageBox.Show("Seleccionó ID: " + DsArt.Tables[0].Rows[0]["CÓDIGO"].ToString() + " DESCRIPCION: " + DsArt.Tables[0].Rows[0]["DESCRIPCIÓN"].ToString()); Entidades.Articulo Articulo = new Entidades.Articulo(); Entidades.Venta Venta = new Entidades.Venta(); DataSet DsArticulo = new DataSet(); Int64 IdArticulo; Int32 Cantidad; IdArticulo = Int64.Parse(grdResultados.Rows[filaSeleccionada].Cells["ID"].Value.ToString()); DsArticulo = Articulo.obtenerArticulos(IdArticulo.ToString()); if (DsArticulo.Tables[0].Rows.Count > 0) { IdArticulo = Int64.Parse(DsArticulo.Tables[0].Rows[0]["CÓDIGO"].ToString()); Cantidad = Int32.Parse(txtCantidad.Text); Venta.guardarArticuloVentaTemporal(IdArticulo, Cantidad); } else { MessageBox.Show("Artículo inexistente en la Base de Datos"); } this.Hide(); } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); } }
private void TicketFactura() { if (VentaEntidad == null) { VentaEntidad = new Entidades.Venta(); } if (Ticket == null) { Ticket = new Negocios.Ticket(); } // [email protected] //imprime una linea de descripcion Ticket.TextoCentro("**********************************"); Ticket.TextoCentro("* Empresa xxxxx *"); Ticket.TextoCentro("**********************************"); Ticket.TextoCentro("**********************************"); Ticket.TextoIzquierda("Dirc: xxxx"); Ticket.TextoIzquierda("Tel: xxxx "); Ticket.TextoIzquierda("Rnc: xxxx"); Ticket.TextoIzquierda(""); Ticket.TextoCentro("Factura de Venta"); //imprime una linea de descripcion Ticket.TextoIzquierda("No Fac: " + VentaEntidad.Factura.ToString()); Ticket.TextoIzquierda("Fecha: " + DateTime.Now.ToShortDateString() + " Hora: " + DateTime.Now.ToShortTimeString()); Ticket.TextoIzquierda("Le Atendio: " + VendedorNombre); Ticket.TextoIzquierda(""); Negocios.Ticket.LineasGuion();//------------------------- Negocios.Ticket.EncabezadoVenta(); Negocios.Ticket.LineasGuion(); //Detalle de la factura foreach (DataGridViewRow rows in DGV_Data.Rows) { if (rows.Cells[1].Value.ToString().Length > 15) { Ticket.AgregaArticulo(articulo: rows.Cells[1].Value.ToString().Substring(0, 15).ToLower(), int.Parse(rows.Cells[2].Value.ToString()), //Cantidad int.Parse(rows.Cells[3].Value.ToString()), //Precio double.Parse(rows.Cells[4].Value.ToString())); //SubTotal } else { Ticket.AgregaArticulo(articulo: rows.Cells[1].Value.ToString().ToLower(), int.Parse(rows.Cells[2].Value.ToString()), //Cantidad int.Parse(rows.Cells[3].Value.ToString()), //Precio double.Parse(rows.Cells[4].Value.ToString())); //SubTotal } //imprime una linea de descripcion } Negocios.Ticket.LineasGuion(); Ticket.AgregaTotales("Sub-Total", double.Parse(Label_MostrarTotalPagar.Text)); // imprime linea con Subtotal Ticket.AgregaTotales("Descuento", double.Parse("000")); // imprime linea con decuento total Ticket.AgregaTotales("Mas ITBIS", double.Parse("000")); // imprime linea con ITBis total Ticket.TextoIzquierda(" "); Ticket.AgregaTotales("Total", double.Parse(Label_MostrarTotalPagar.Text)); // imprime linea con total Ticket.TextoIzquierda(" "); Ticket.AgregaTotales("Efectivo Entregado: ", double.Parse(Label_MostrarTotalPagar.Text)); Ticket.AgregaTotales("Efectivo Devuelto: ", double.Parse("000")); // Ticket1.LineasTotales(); // imprime linea Ticket.TextoIzquierda(" "); Ticket.TextoCentro("**********************************"); Ticket.TextoCentro("* Gracias por preferirnos *"); Ticket.TextoCentro("**********************************"); Ticket.TextoIzquierda(" "); if (Impresora == null) { Impresora = new Negocios.Impresora(); } if (Impresora.impresoraDisponible.Count > 0) { Ticket.ImprimirTiket(); //Imprimir } // ticket.ImprimirTiket(Impresora.impresoraDisponible[3].ToString()); //Imprimir }
private void txtCodigoArticulo_KeyPress(object sender, KeyPressEventArgs e) { try { fg.keyPressNumerosDecimales(e, txtCodigoArticulo); if (e.KeyChar == 13 && txtCodigoArticulo.Text.Length > 0 ) { //SI APRETO ENTER EJECUTO ESTE CODIGO if (txtCodigoArticulo.Text == "1") { ArtGeneral(); txtCodigoArticulo.Text = String.Empty; return; } DataSet DsArticulo = new DataSet(); Entidades.Articulo Articulo = new Entidades.Articulo(); Entidades.Venta Venta = new Entidades.Venta(); if (txtCantidad.Text.Trim() == "") { txtCantidad.Text = "1"; } DsArticulo = Articulo.obtenerArticulos(txtCodigoArticulo.Text); if (DsArticulo.Tables[0].Rows.Count > 0) { Venta.guardarArticuloVentaTemporal(UInt64.Parse(txtCodigoArticulo.Text), Int32.Parse(txtCantidad.Text)); } else { buscarArticuloYGuardarVentaTemporal(); } cargarArticulosEnGrilla(); //grdItemsVenta = fg.formatoGrilla(grdItemsVenta, 9); txtCodigoArticulo.Text = String.Empty; txtCantidad.Text = "1"; txtCodigoArticulo.Focus(); } } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); } }
private bool Salir() { try { if (grdItemsVenta.RowCount > 0) { Boolean deseaContinuar = (MessageBox.Show("Se cerrará el formulario sin confirmar la Venta. ¿Desea continuar de todos modos?", "Cancelar Venta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes); if (!(deseaContinuar)) { return false; } } Entidades.Venta Venta = new Entidades.Venta(); Venta.borrarArticulosVenta_Temporal(); return true; } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); return false; } }
private void frmNuevaVenta_Load(object sender, EventArgs e) { try { Entidades.Venta Venta = new Entidades.Venta(); btnConfirmarVenta.Focus(); Venta.borrarArticulosVenta_Temporal(); ponerValoresEnDefault(); actualizarGrilla(); } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); } }
private void btnEliminarArticulo_Click(object sender, EventArgs e) { try { Boolean encontreUnRegistros = false; Entidades.Venta Venta = new Entidades.Venta(); foreach (DataGridViewRow row in grdItemsVenta.Rows) { DataGridViewCheckBoxCell celda = row.Cells["SELECCIONAR"] as DataGridViewCheckBoxCell; if (Convert.ToBoolean(celda.Value)) { encontreUnRegistros = true; Venta.borrarArticulosVenta_Temporal(UInt64.Parse(grdItemsVenta.Rows[row.Index].Cells["ID"].Value.ToString())); //grdItemsVenta.Rows.RemoveAt(row.Index); //i = 0; } } grdItemsVenta.DataSource = null; cargarArticulosEnGrilla(); actualizarGrilla(); if (!(encontreUnRegistros)) { MessageBox.Show("Debe seleccionar el artículo que desea cancelar.", "Cancelar Artículo Venta.", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (grdItemsVenta.Rows.Count == 0) { Venta.borrarArticulosVenta_Temporal(); } btnEliminarArticulo.Enabled = false; } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); } }
public frmModificarVenta(Entidades.Venta ventaModif) { InitializeComponent(); Venta = ventaModif; }
private void mostrarFormularioModificarVenta() { try { celdaSeleccionada = grdVentas.CurrentCellAddress.X; filaSeleccionada = grdVentas.CurrentCellAddress.Y; Entidades.Venta ventaModif = new Entidades.Venta(); ventaModif.m_Id_Venta = UInt64.Parse(grdVentas.Rows[filaSeleccionada].Cells["CÓDIGO"].Value.ToString()); ventaModif.cargarDatosVenta(); frmModificarVenta modificarVenta = new frmModificarVenta(ventaModif); modificarVenta.ShowDialog(); this.btnActualizar.PerformClick(); } catch (Exception ex) { fg.mostrarErrorTryCatch(ex); } }
public void InsertarVentas(Entidades.Venta entidad) { obj = new Datos.Venta(); obj.InsertarVentas(entidad); obj.RebajarConceptos(entidad); }