示例#1
0
        public static List <clsVenta> BuscarIdVenta(int idCliente, int idEmpleado, int NroVentaId, int SerieId,
                                                    string TipoDocumento, decimal TotalVentaId)
        {
            List <clsVenta> x = new List <clsVenta>();

            SqlConnection conexion = new SqlConnection(mdlVariables.CadenaDeConexion);
            SqlCommand    cmd      = new SqlCommand("usp_Venta_Id", conexion);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@parIdCliente", idCliente);
            cmd.Parameters.AddWithValue("@parIdEmpleado", idEmpleado);
            cmd.Parameters.AddWithValue("@parNroVenta", NroVentaId);
            cmd.Parameters.AddWithValue("@parSerie", SerieId);
            cmd.Parameters.AddWithValue("@parTipoDocumento", TipoDocumento);
            cmd.Parameters.AddWithValue("@parTotalVenta", TotalVentaId);

            conexion.Open();
            SqlDataReader contenedor;

            contenedor = cmd.ExecuteReader();
            while (contenedor.Read() == true)
            {
                clsVenta MiObjeto;
                MiObjeto = new clsVenta(Convert.ToInt32(contenedor["IdVenta"]), Convert.ToInt32(contenedor["IdEmpleado_V"]), Convert.ToInt32(contenedor["IdCliente_V"]),
                                        Convert.ToInt32(contenedor["NroVenta"]), Convert.ToInt32(contenedor["Serie"]),
                                        contenedor["TipoDocumento"].ToString(), Convert.ToDecimal(contenedor["TotalVenta"]));

                x.Add(MiObjeto);
            }
            conexion.Close();
            return(x);
        }
示例#2
0
        public static List <clsVenta> generarSerieNumeroComprobante(string tipoComprobante)
        {
            List <clsVenta> x = new List <clsVenta>();

            SqlConnection conexion = new SqlConnection(mdlVariables.CadenaDeConexion);
            SqlCommand    cmd      = new SqlCommand("sp_venta_generar_serie_numero_comprobante", conexion);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@partipo_comprobante", tipoComprobante);
            conexion.Open();
            SqlDataReader contenedor;

            contenedor = cmd.ExecuteReader();
            while (contenedor.Read() == true)
            {
                clsVenta MiObjeto;
                MiObjeto = new clsVenta(Convert.ToInt32(contenedor["Serie"]),
                                        Convert.ToInt32(contenedor["NroVenta"]));

                x.Add(MiObjeto);
            }
            conexion.Close();
            return(x);
        }
        private void btnInsertarVenta_Click(object sender, EventArgs e)
        {
            try
            {
                if (lstvDatos.Items.Count == 0 || string.IsNullOrEmpty(txtDatos.Text))
                {
                    MessageBox.Show("Agregue un producto a la lista / Seleccione un Cliente ");
                }
                else
                {
                    GenerarSerie();
                    clsVenta nuevaVenta;
                    if (rbnBoleta.Checked == true)
                    {
                        nuevaVenta = new clsVenta(Convert.ToInt32(lblIdCliente.Text), Convert.ToInt32(lblIdEmpleado.Text), Convert.ToInt32(lblNroCorrelativo.Text), Convert.ToInt32(lblSerie.Text), "BOLETA", Convert.ToDecimal(txtTotal.Text));
                        nuevaVenta.InsertarVenta();
                        foreach (clsVenta ELEMENTO in clsVenta.BuscarIdVenta(Convert.ToInt32(lblIdCliente.Text), Convert.ToInt32(lblIdEmpleado.Text), Convert.ToInt32(lblNroCorrelativo.Text), Convert.ToInt32(lblSerie.Text), "BOLETA", Convert.ToDecimal(txtTotal.Text)))
                        {
                            lblIdVenta.Text = ELEMENTO.IdVenta.ToString();
                        }
                    }
                    if (rbnFactura.Checked == true)
                    {
                        nuevaVenta = new clsVenta(Convert.ToInt32(lblIdCliente.Text), Convert.ToInt32(lblIdEmpleado.Text), Convert.ToInt32(lblNroCorrelativo.Text), Convert.ToInt32(lblSerie.Text), "FACTURA", Convert.ToDecimal(txtTotal.Text));
                        nuevaVenta.InsertarVenta();
                        foreach (clsVenta ELEMENTO in clsVenta.BuscarIdVenta(Convert.ToInt32(lblIdCliente.Text), Convert.ToInt32(lblIdEmpleado.Text), Convert.ToInt32(lblNroCorrelativo.Text), Convert.ToInt32(lblSerie.Text), "FACTURA", Convert.ToDecimal(txtTotal.Text)))
                        {
                            lblIdVenta.Text = ELEMENTO.IdVenta.ToString();
                        }
                    }

                    int n;
                    n = 0;

                    while (n < lstvDatos.Items.Count)
                    {
                        clsDetalleVenta nuevoDetalleVenta;
                        nuevoDetalleVenta = new clsDetalleVenta(Convert.ToInt32(lblIdVenta.Text), Convert.ToInt32(lstvDatos.Items[n].SubItems[3].Text), Convert.ToInt32(lstvDatos.Items[n].SubItems[1].Text), Convert.ToDecimal(lstvDatos.Items[n].Text));
                        nuevoDetalleVenta.InsertarDetalleVenta();
                        n = n + 1;
                    }

                    MessageBox.Show("VENTA  REALIZADA SATISFACTORIAMENTE", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult result = MessageBox.Show("¿Desea imprimir?", "Imprimir Documento", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    //if (result == DialogResult.Yes)
                    //{
                    //    try
                    //    {

                    //        //---------------- imprimir--------------------------

                    //        try
                    //        {
                    //            string tipoComprobante = cboTipoComprobante.Text;
                    //            if (tipoComprobante.CompareTo("FACTURA") == 0)
                    //            {
                    //                FrmReporteFactura form = new FrmReporteFactura();
                    //                form.idVenta = Convert.ToInt32(txtIdVenta.Text);
                    //                form.Show();
                    //            }
                    //            else
                    //            {
                    //                FrmReporteBoleta form = new FrmReporteBoleta();
                    //                form.idVenta = Convert.ToInt32(txtIdVenta.Text);
                    //                form.Show();

                    //            }
                    //        }
                    //        catch (Exception ex)
                    //        {

                    //            MessageBox.Show(ex.Message);
                    //        }

                    //        //--------------------------------------------------------


                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        MessageBox.Show(ex.Message);
                    //    }

                    //}
                    //else result = DialogResult.No;
                    //{
                    //    this.Close();
                    //}

                    lstvDatos.Items.Clear();
                    Limpiar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }