Beispiel #1
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            reiniciarCotizacion();
            Ent_Venta ventas = new Ent_Venta();

            if (txtDNI.Text != String.Empty)
            {
                ventas.nro_doc = int.Parse(txtDNI.Text);
            }

            if (cboTipo.SelectedValue == null)
            {
                ventas.tipo_cotizacion = String.Empty;
            }

            if (cboTipo.SelectedValue != null && cboTipo.SelectedValue.ToString() != String.Empty)
            {
                ventas.tipo_cotizacion = cboTipo.SelectedValue.ToString();
            }
            ventas.cod_tienda = cod_tienda;

            List <Ent_Venta> lista_cotizacion = BL_Ventas.getConsultaCotizacion(ventas);

            dgvDocumentos.Rows.Clear();

            foreach (Ent_Venta venta in lista_cotizacion)
            {
                dgvDocumentos.Rows.Add(venta.nro_doc_str, venta.id_cab, venta.tipo_cotizacion, venta.emision, venta.usuario, venta.cliente_doc, venta.cliente, venta.monto_total, venta.dias_alquiler, venta.moneda);
            }
        }
Beispiel #2
0
        private void fillVentas()
        {
            dgvVentas.AutoGenerateColumns = false;

            if (dgvVentas.Rows.Count > 0)
            {
                dgvVentas.Rows.Clear();
            }

            Ent_Venta entity = new Ent_Venta();

            entity.cod_tienda  = tienda;
            entity.nro_doc_str = txtNroDoc.Text;
            entity.tipo_venta  = cboTipoVenta.SelectedValue.ToString();
            entity.forma_pago  = cboFormaPago.SelectedValue.ToString();
            entity.emision     = txtFecha.Text;
            entity.anulado     = cboEstado.SelectedValue.ToString();

            List <Ent_Venta> lstVentas = BL_Ventas.getConsultaVentas(entity);

            var bindingList = new BindingList <Ent_Venta>(lstVentas);
            var source      = new BindingSource(bindingList, null);

            dgvVentas.DataSource = source;

            txtTotal.Text = dgvVentas.Rows.Count.ToString();
        }
Beispiel #3
0
        private void fillDatosVenta()
        {
            Ent_Venta entity = BL_Ventas.getCabeceraVenta(id_venta);

            if (entity.tipo_venta == "FA")
            {
                lblDNI.Text     = "RUC";
                lblNombres.Text = "Razón Social";
            }
            else
            {
                lblDNI.Text     = "DNI";
                lblNombres.Text = "Nombres";
            }

            txtTipoVenta.Text = entity.tipo_venta_des;
            txtNroDoc.Text    = entity.nro_doc_str;
            txtDNI.Text       = entity.cliente_doc;
            txtNombres.Text   = entity.cliente;
            txtDireccion.Text = entity.direccion;
            txtFecha.Text     = entity.emision;
            txtFormaPago.Text = entity.forma_pago_des;
            txtTelefono.Text  = entity.telefono;
            txtUsuario.Text   = entity.usuario;
            txtAnulado.Text   = (entity.anulado == "1") ? "SI" : "NO";

            txtMotivo.Text      = entity.motivo_anul;
            txtFechaAnul.Text   = entity.fecha_anul;
            txtusuarioAnul.Text = entity.usuario_anul;

            lblTotal.Text = entity.monto_total.ToString("#0.00");

            Ent_Configuracion ent_configuracion = BL_Configuracion.getConfiguracion();

            if (entity.tipo_venta.Equals("FA"))
            {
                txtSubTotal.Text = (Convert.ToDouble(lblTotal.Text) / Convert.ToDouble(ent_configuracion.IGV + 1)).ToString("#0.00");
                txtIGV.Text      = (Convert.ToDouble(lblTotal.Text) - Convert.ToDouble(txtSubTotal.Text)).ToString("#0.00");
            }
            else
            {
                txtSubTotal.Text = "0.00";
                txtIGV.Text      = "0.00";
            }

            txtRecibido.Text = entity.monto_recibido.ToString("#0.00");
            if (entity.forma_pago == "CR")
            {
                lblVuelto.Text = "Saldo";
                txtVuelto.Text = (entity.monto_total - entity.monto_recibido).ToString("#0.00");
            }
            else
            {
                txtVuelto.Text = entity.monto_vuelto.ToString("#0.00");
            }

            fillDetalles();
        }
Beispiel #4
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            reiniciarCredito();

            if (txtNroDocumento.Text == String.Empty)
            {
                MessageBox.Show("El número de documento no puede estar vacío.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtNroDocumento.Focus();
                return;
            }

            int       v_nro_doc    = int.Parse(txtNroDocumento.Text.Substring(4, txtNroDocumento.Text.Length - 4));
            string    v_tipo_venta = cboTipoVenta.SelectedValue.ToString();
            string    v_fecha      = txtFecha.Text;
            Ent_Venta res_venta    = BL_Ventas.getVentaCredito(v_nro_doc, cod_tienda, v_tipo_venta, v_fecha);

            if (res_venta.nro_doc == 0)
            {
                MessageBox.Show("Documento no encontrado.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                ent_venta             = res_venta;
                tbDetalles.Enabled    = true;
                lblNroDocumento.Text  = res_venta.nro_doc_str;
                lblNroDocumento2.Text = res_venta.nro_doc_str;
                lblTipoVenta.Text     = res_venta.tipo_venta_des;
                txtDNI.Text           = res_venta.cliente_doc;
                txtCliente.Text       = res_venta.cliente;
                lblFecha.Text         = res_venta.emision;
                txtEmail.Text         = res_venta.email;
                txtTelefono.Text      = res_venta.telefono;
                txtDireccion.Text     = res_venta.direccion;
                if (res_venta.tipo_venta == "FA")
                {
                    txtSubTotal.Text = Convert.ToDouble(res_venta.monto_total / (ent_configuracion.IGV + 1)).ToString("#0.00");
                    txtIGV.Text      = (res_venta.monto_total - Convert.ToDouble(txtSubTotal.Text)).ToString("#0.00");
                }
                txtTotal.Text             = res_venta.monto_total.ToString("#0.00");
                btnFinalizarVenta.Enabled = (res_venta.estado_credito == "P") ? true : false;

                if (v_tipo_venta == "FA")
                {
                    lblDNI.Text     = "RUC";
                    lblCliente.Text = "Razón Social";
                }
                else
                {
                    lblDNI.Text     = "DNI";
                    lblCliente.Text = "Cliente";
                }
            }

            fillDetalles(res_venta.id_cab.ToString());
            fillAbonos(res_venta.id_cab, res_venta.nro_doc);
        }
Beispiel #5
0
        private void dgvVentas_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (e.ColumnIndex == 9)
            {
                string          id  = dgvVentas.Rows[e.RowIndex].Cells["ID"].Value.ToString();
                frmDetalleVenta frm = new frmDetalleVenta(id);
                frm.ShowDialog();
            }

            if (e.ColumnIndex == 11)
            {
                string nro_doc = dgvVentas.Rows[e.RowIndex].Cells["DOC"].Value.ToString();
                string tipo    = dgvVentas.Rows[e.RowIndex].Cells["TIPO_VENTA"].Value.ToString();

                InvoicePDF pdf = new InvoicePDF();

                ent_venta                 = new Ent_Venta();
                ent_venta.nro_doc_str     = dgvVentas.Rows[e.RowIndex].Cells["NRO_DOC"].Value.ToString();
                ent_venta.tipo_venta      = dgvVentas.Rows[e.RowIndex].Cells["TIPO_VENTA"].Value.ToString();
                ent_venta.emision         = dgvVentas.Rows[e.RowIndex].Cells["FECHA"].Value.ToString();
                ent_venta.cliente         = dgvVentas.Rows[e.RowIndex].Cells["NOMBRES"].Value.ToString();
                ent_venta.cliente_doc     = dgvVentas.Rows[e.RowIndex].Cells["DNI"].Value.ToString();
                ent_venta.direccion       = dgvVentas.Rows[e.RowIndex].Cells["DIRECCION"].Value.ToString();
                ent_venta.monto_total     = Convert.ToDouble(dgvVentas.Rows[e.RowIndex].Cells["TOTAL"].Value.ToString());
                ent_venta.monto_subtotal  = Convert.ToDouble(ent_venta.monto_total / (ent_configuracion.IGV + 1));
                ent_venta.monto_igv       = (ent_venta.monto_total - Convert.ToDouble(ent_venta.monto_subtotal));
                ent_venta.monto_descuento = Convert.ToDouble(dgvVentas.Rows[e.RowIndex].Cells["DESCUENTO"].Value.ToString());;
                ent_venta.nro_doc         = Convert.ToInt32(dgvVentas.Rows[e.RowIndex].Cells["DOC"].Value.ToString());
                ent_venta.moneda          = dgvVentas.Rows[e.RowIndex].Cells["MONEDA"].Value.ToString();

                ent_venta.lstProductos = BL_Ventas.getDetalleVenta(nro_doc);

                if (tipo == "BO")
                {
                    pdf.createBoleta(ent_configuracion, ent_venta);
                }
                else
                {
                    pdf.createFactura(ent_configuracion, ent_venta);
                }

                /*String filename = "invoices\\" + (tipo == "BO" ? "boleta" : "factura") + "_" + nro_doc + ".pdf";
                 * if (File.Exists(filename))
                 * {
                 *  Process.Start(filename);
                 * } else
                 * {
                 *  MessageBox.Show((tipo == "BO" ? "Boleta" : "Factura") + " no encontrada.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 * }*/
            }
        }
Beispiel #6
0
        private void dgvVentas_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                ent_venta             = new Ent_Venta();
                ent_venta.nro_doc_str = dgvVentas.Rows[e.RowIndex].Cells["NRO_DOC"].Value.ToString();
                ent_venta.tipo_venta  = dgvVentas.Rows[e.RowIndex].Cells["TIPO_VENTA"].Value.ToString();
                ent_venta.emision     = dgvVentas.Rows[e.RowIndex].Cells["FECHA"].Value.ToString();

                if (auto_close)
                {
                    this.Close();
                }
            }
        }
Beispiel #7
0
        public frmConsultarCotizacion(string tienda)
        {
            InitializeComponent();
            cod_tienda = tienda;

            ent_configuracion = new Ent_Configuracion();
            ent_configuracion = BL_Configuracion.getConfiguracion();
            cotizacion        = new Ent_Venta();

            Dictionary <string, string> lista_tipo = new Dictionary <string, string>();

            lista_tipo.Add("", ":: TODAS ::");
            lista_tipo.Add("CO", "COMPRA");
            lista_tipo.Add("AL", "ALQUILER");
            cboTipo.DataSource    = new BindingSource(lista_tipo, null);
            cboTipo.DisplayMember = "Value";
            cboTipo.ValueMember   = "Key";

            btnBuscar_Click(new object(), new EventArgs());
        }
Beispiel #8
0
        private void procesarIngresarAlmacen()
        {
            Ent_Venta venta = new Ent_Venta();

            venta.cod_tienda           = cod_tienda;
            venta.cantidad             = sumarCantidad();
            venta.usuario              = usuario;
            venta.tipo_ingreso_almacen = cboTipo.SelectedValue.ToString();
            venta.fecha_fin            = dtpFechaSalida.Value.ToString("dd/MM/yyyy");

            foreach (DataGridViewRow row in dgvProductos.Rows)
            {
                Ent_Productos prd = new Ent_Productos();
                prd.id       = int.Parse(row.Cells["ID"].Value.ToString());
                prd.nombre   = row.Cells["DESCRIPCION"].Value.ToString();
                prd.cantidad = int.Parse(row.Cells["CANTIDAD"].Value.ToString());
                prd.precio   = float.Parse(row.Cells["PU"].Value.ToString());

                venta.lstProductos.Add(prd);
            }

            try
            {
                string result = BL_Ventas.procesarIngresoAlmacen(venta);

                if (result == "1")
                {
                    MessageBox.Show("Venta Realizada con Éxito!.", "Venta", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    reiniciarVenta();
                }
                else
                {
                    MessageBox.Show(result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error en el proceso de compra.\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #9
0
        private void fillDocumentos()
        {
            dgvDocumentos.AutoGenerateColumns = false;

            if (dgvDocumentos.Rows.Count > 0)
            {
                dgvDocumentos.Rows.Clear();
            }

            if (dgvDetalle.Rows.Count > 0)
            {
                dgvDetalle.Rows.Clear();
            }

            Ent_Venta param_venta = new Ent_Venta();

            param_venta.cod_tienda = cod_tienda;

            if (txtNroDocumento.Text != String.Empty)
            {
                param_venta.nro_doc = int.Parse(txtNroDocumento.Text);
            }

            if (cboTipoVenta.SelectedValue == null)
            {
                param_venta.tipo_venta = String.Empty;
            }

            if (cboTipoVenta.SelectedValue != null && cboTipoVenta.SelectedValue.ToString() != String.Empty)
            {
                param_venta.tipo_venta = cboTipoVenta.SelectedValue.ToString();
            }

            List <Ent_Venta> lstVenta = BL_Ventas.getVentas(param_venta);

            var bindingList = new BindingList <Ent_Venta>(lstVenta);
            var source      = new BindingSource(bindingList, null);

            dgvDocumentos.DataSource = source;
        }
Beispiel #10
0
        private void fillNroDoc()
        {
            List <Ent_Venta> items = new List <Ent_Venta>();

            Ent_Venta venta = new Ent_Venta();

            venta.cod_tienda = cod_tienda;
            venta.tipo_venta = (cboTipoDocumento.SelectedValue == null) ? "BO" : cboTipoDocumento.SelectedValue.ToString();

            if (venta.tipo_venta == "VentasSys.EL.Ent_TipoVentas")
            {
                return;
            }

            var ventas = BL_Ventas.getVentas(venta);

            items.AddRange(ventas);

            cboNroDocumento.DataSource    = items;
            cboNroDocumento.ValueMember   = "id_cab";
            cboNroDocumento.DisplayMember = "nro_doc_str";
        }
Beispiel #11
0
        private void fillVentas()
        {
            dgvVentas.AutoGenerateColumns = false;

            if (dgvVentas.Rows.Count > 0)
            {
                dgvVentas.Rows.Clear();
            }

            Ent_Venta entity = new Ent_Venta();

            entity.cliente_doc = txtDNI.Text;
            entity.cliente     = txtNombre.Text;
            entity.emision     = txtFecha.Text;

            List <Ent_Venta> lstVentas = BL_Ventas.getVentasPorCliente(entity);

            var bindingList = new BindingList <Ent_Venta>(lstVentas);
            var source      = new BindingSource(bindingList, null);

            dgvVentas.DataSource = source;
        }
Beispiel #12
0
        public string Send_Email(Ent_Venta venta, Ent_Tienda ent_tienda, Ent_Configuracion ent_configuracion, string observacion, string adjunto)
        {
            string send = "1";

            try
            {
                obser = observacion;
                _ent_configuracion = ent_configuracion;
                _ent_tienda        = ent_tienda;
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("gator4068.hostgator.com");

                mail.From = new MailAddress("*****@*****.**", "Osmosis Perú");
                if (!adjunto.Equals(String.Empty))
                {
                    Attachment attachment = new Attachment(adjunto);
                    mail.Attachments.Add(attachment);
                }
                //mail.To.Add("*****@*****.**");
                mail.To.Add(venta.email);
                mail.Subject    = "Cotización";
                mail.IsBodyHtml = true;
                //mail.Body = Armar_Cotizacion_hmtl(venta);
                mail.AlternateViews.Add(Armar_Cotizacion_hmtl(venta));

                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "info190792");
                SmtpServer.EnableSsl   = true;

                SmtpServer.Send(mail);
            }
            catch (Exception ex) {
                send = ex.Message;
            }

            return(send);
        }
Beispiel #13
0
 public static string procesarCotizacion(Ent_Venta venta, out String id_cab)
 {
     return(DAO_Ventas.procesarCotizacion(venta, out id_cab));
 }
Beispiel #14
0
        private void procesarCompra()
        {
            forma_pago = cboFormaPago.SelectedValue.ToString();

            Ent_Venta venta = new Ent_Venta();

            venta.nro_doc         = int.Parse(correlativo);
            venta.nro_doc_str     = lblSerie.Text;
            venta.cod_tienda      = cod_tienda;
            venta.tipo_venta      = tipo_venta;
            venta.forma_pago      = forma_pago;
            venta.cantidad        = sumarCantidad();
            venta.monto_total     = total;
            venta.monto_subtotal  = double.Parse(txtSubTotal.Text);
            venta.monto_igv       = double.Parse(txtIGV.Text);
            venta.monto_recibido  = double.Parse(txtRecibido.Text);
            venta.monto_vuelto    = double.Parse(txtVuelto.Text);
            venta.monto_descuento = double.Parse(txtDescuento.Text);
            venta.cliente_doc     = txtDNI.Text;
            venta.cliente         = txtNombres.Text + " " + txtApellidos.Text;
            venta.direccion       = txtDireccion.Text;
            venta.usuario         = ent_usuario.username;

            venta.fecha_inicio = dtpFechaInicio.Value.ToShortDateString();
            venta.fecha_fin    = dtpFechaEntrega.Value.ToShortDateString();

            venta.moneda = cboMoneda.SelectedValue.ToString();

            bool existe_cliente = BL_Clientes.existeCliente(venta.cliente_doc);

            //save customer if doesnt exists
            if (!existe_cliente)
            {
                log.Info("Cliente " + txtDNI.Text + " no existe en la base de datos.", System.Reflection.MethodBase.GetCurrentMethod().Name);

                var confirm = MessageBox.Show("¿Desea guardar el cliente en el sistema?", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (confirm == DialogResult.Yes)
                {
                    Ent_Clientes nuevo_cliente = new Ent_Clientes();
                    nuevo_cliente.dni       = txtDNI.Text;
                    nuevo_cliente.nombres   = txtNombres.Text;
                    nuevo_cliente.apellidos = txtApellidos.Text;
                    nuevo_cliente.direccion = txtDireccion.Text;
                    nuevo_cliente.telefono  = txtTelefono.Text;
                    nuevo_cliente.email     = txtEmail.Text;
                    nuevo_cliente.tipo      = (tipo_venta == "FA") ? "E" : "N";
                    nuevo_cliente.posible   = "1";

                    try
                    {
                        string _result = BL_Clientes.insertarCliente(nuevo_cliente);

                        if (_result == "1")
                        {
                            log.Info("Cliente " + nuevo_cliente.dni + " grabado con éxito.", System.Reflection.MethodBase.GetCurrentMethod().Name);
                        }
                        else
                        {
                            log.Error("Error al grabar cliente: " + _result, System.Reflection.MethodBase.GetCurrentMethod().Name);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Ocurrió un error al grabar al cliente, sin embargo, el proceso de compra continuará.\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        log.Error("Error al grabar cliente: " + ex.Message, System.Reflection.MethodBase.GetCurrentMethod().Name);
                    }
                }
                else
                {
                    log.Info("Cliente " + txtDNI.Text + " no se guardará en la base de datos.", System.Reflection.MethodBase.GetCurrentMethod().Name);
                }
            }

            foreach (DataGridViewRow row in dgvProductos.Rows)
            {
                Ent_Productos prd = new Ent_Productos();
                prd.id       = int.Parse(row.Cells["ID"].Value.ToString());
                prd.nombre   = row.Cells["DESCRIPCION"].Value.ToString();
                prd.cantidad = int.Parse(row.Cells["CANTIDAD"].Value.ToString());
                prd.precio   = float.Parse(row.Cells["PU"].Value.ToString());

                venta.lstProductos.Add(prd);
            }

            try
            {
                string result = BL_Ventas.procesarVenta(venta);

                if (result == "1")
                {
                    MessageBox.Show("Venta Realizada con Éxito!.", "Venta", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    InvoicePDF pdf = new InvoicePDF();
                    if (venta.tipo_venta == "BO")
                    {
                        pdf.createBoleta(ent_configuracion, venta);
                    }
                    else
                    {
                        pdf.createFactura(ent_configuracion, venta);
                    }

                    log.Info("Venta " + lblSerie.Text + " realizada con éxito.", System.Reflection.MethodBase.GetCurrentMethod().Name);
                    string resumen =
                        "\n-----------------------------------\n" +
                        "Resumen Venta:\n" +
                        "Serie: " + lblSerie.Text + "\n" +
                        "Tipo Venta: " + tipo_venta + "\n" +
                        "Forma de Pago: " + cboFormaPago.Text + "\n" +
                        "Cliente: " + txtDNI.Text + "\n" +
                        "Productos:\n";
                    foreach (DataGridViewRow item in dgvProductos.Rows)
                    {
                        resumen += "  - " + item.Cells["CODIGO"].Value.ToString() + " | " +
                                   item.Cells["DESCRIPCION"].Value.ToString() + " | " +
                                   item.Cells["CANTIDAD"].Value.ToString() + " | " +
                                   item.Cells["PU"].Value.ToString() + " | " +
                                   item.Cells["IMPORTE"].Value.ToString() + "\n";
                    }
                    resumen +=
                        "Subtotal: " + txtSubTotal.Text + "\n" +
                        "IGV: " + txtIGV.Text + "\n" +
                        "TOTAL: " + txtTotal.Text + "\n" +
                        "Recibido: " + txtRecibido.Text + "\n" +
                        "Vuelto: " + txtVuelto.Text + "\n" +
                        "-----------------------------------\n\n";
                    log.Info(resumen, System.Reflection.MethodBase.GetCurrentMethod().Name);
                    reiniciarVenta();
                }
                else
                {
                    MessageBox.Show(result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error en el proceso de compra.\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                log.Error("Error en el proceso de compra: " + ex.Message, System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
        }
Beispiel #15
0
        private AlternateView Armar_Cotizacion_hmtl(Ent_Venta venta)
        {
            string         pagina = "<html>";
            string         style  = "<head></style>";
            string         html   = "<body>";
            LinkedResource res    = new LinkedResource("logo.png");

            res.ContentId = Guid.NewGuid().ToString();
            try
            {
                //style
                //Image.FromFile("logo.png")
                style += "</style></head>";
                //html
                html += "<table style='width:100%'>";
                html += "<tr><td colspan='4' align=center><img src='cid:" + res.ContentId + @"'/></td></tr>";
                html += "<tr><td colspan='4' style='font-weight: bold;font-size: 20px; height:60px; line-height:60px; text-align:center'>OFERTA</td></tr>";
                html += "<tr><td></td><td>N° Oferta : </td><td><span>" + venta.id_cab.ToString().PadLeft(6, '0') + "</span></td></tr>";
                html += "<tr><td>Observaciones: </td><td colspan='3'><span>" + venta.denominacion + "</span></td></tr>";
                html += "<tr><td>Cliente :</td><td><span>" + venta.cliente + "</span></td><td>DNI/RUC :</td><td><span>" + venta.cliente_doc + "</span></td></tr>";
                html += "<tr><td>Ubicación :</td><td><span>LIMA</span></td><td>Fecha Emision</td><td><span>" + venta.emision + "</span></td></tr>";
                html += venta.tipo_cotizacion == "AL" ? "<tr><td>Dia(s) de Alquiler:</td><td><span>" + venta.dias_alquiler + " dia(s)</span></td></tr>" : "";
                html += "</table>";
                html += "<p style='font-weight: bold;font-size: 14px; padding-left:20px;'> Detalle de Producto(s):</p>";
                html += "<table style='margin: 20px; width: 90%; margin-left:5%; border-collapse: collapse;'>";
                html += "<tr style='height:35px; line-height:35px;font-weight: bold;font-size: 12px; background-color:blue; color:white'><th style='border: 1px solid #ddd;'>ID</th><th style='border: 1px solid #ddd;'>Producto</th><th style='border: 1px solid #ddd;'>Cantidad</th><th style='border: 1px solid #ddd;'>Precio Unit.</th><th style='border: 1px solid #ddd;'>Total Importe</th></tr>";
                foreach (Ent_Productos prod in venta.lstProductos)
                {
                    html += "<tr style='height:30px; font-weight: normal;font-size: 10px;'><th style='border: 1px solid #ddd;'>" + prod.cod_producto + "</th><th style='border: 1px solid #ddd;'>" + prod.nombre + "</th><th style='border: 1px solid #ddd;'>" + prod.cantidad + "</th><th style='border: 1px solid #ddd;'>" + prod.precio.ToString("#0.00") + "</th><th style='border: 1px solid #ddd;'>" + prod.monto_total.ToString("#0.00") + "</th></tr>";
                }
                html += "<tr style='font-weight: normal;font-size: 10px;'><th></th><th></th><th style='border: 1px solid #ddd;' colspan='2'>Total Oferta (Sin IGV)</th><th style='border: 1px solid #ddd;'>" + (venta.monto_total - (venta.monto_total * 0.18)).ToString("#0.00") + "</th></tr>";
                html += "<tr style='font-weight: normal;font-size: 10px;'><th></th><th></th><th style='border: 1px solid #ddd;' colspan='2'>IGV - 18%</th><th style='border: 1px solid #ddd;'>" + (venta.monto_total * 0.18).ToString("#0.00") + "</th></tr>";
                html += "<tr style='font-weight: normal;font-size: 10px;'><th></th><th></th><th style='border: 1px solid #ddd;' colspan='2'>Monto Total</th><th style='border: 1px solid #ddd;'>" + venta.monto_total.ToString("#0.00") + "</th></tr>";
                html += "</table>";

                String intPart = venta.monto_total.ToString().Split('.')[0];

                String totalString = Convert.ToInt32(intPart).ToWords().ToUpper();
                var    decimalPart = (int)(((decimal)venta.monto_total % 1) * 100);
                String textoTotal  = "Son " + totalString + " Y " + decimalPart.ToString().PadLeft(2, '0') + "/100 " + ((venta.moneda == "PEN") ? "Soles" : "Dólares Americanos");

                html += "<p style='font-weight: bold;font-size: 11px; padding-left:20px;'>" + textoTotal + "</p>";

                html += "<span style='font-weight: bold;font-size: 11px; padding-left:20px;'>" + obser + "</span><br/>";
                html += "<span style='color:red; font-weight: bold;font-size: 11px; padding-left:20px;'>SOLO POR PAGO POR TRANSFERENCIA BANCARIA</span><br/>";
                html += "<span style='color:red; font-weight: bold;font-size: 11px; padding-left:20px;'>RECOGER CON VOUCHER DE DEPOSITO</span><br/>";
                html += "<span style='font-weight: bold;font-size: 11px; padding-left:20px;'>" + _ent_configuracion.RAZON_SOCIAL + "</span><br/>";
                html += "<span style='font-weight: bold;font-size: 11px; padding-left:20px;'>RUC: " + _ent_configuracion.RUC + " - " + _ent_configuracion.DIRECCION + "</span><br/>";
                html += "<span style='font-weight: bold;font-size: 11px; padding-left:20px;'>CUENTA BBVA</span><br/>";
                html += "<span style='font-weight: bold;font-size: 11px; padding-left:20px;'>SOLES: 0011-0117-0100097865 INTERBANCARIO SOLES 011-117-000100097865</span><br/>";
                html += "<span style='font-weight: bold;font-size: 11px; padding-left:20px;'>DOLARES: 0011-0117-01-00095641 INTERBANCARIO DOLARES 011-117-000100095641-95</span><br/>";

                html += "<p style='color: red'>NOTA IMPORTANTE DE INSTALACIÓN: OSMOSISPERU NO SE HACE RESPONSABLE POR DESPERFECTOS PRODUCIDO POR ACCIONES AJENAS A NUESTRA INSTALACIÓN COMO POR EJEMPLO, TUBERIAS ANTIGUAS, TUBOS DE ABASTO VIEJOS, O DESPERFECTOS EN SUS DESAGÜES, ASI TAMBIÉN  NO NOS HACEMOS RESPONSABLES POR ALGUNA MODIFICACIÓN QUE SE HAYA REALIZADO AL MOMENTO DE INSTALARLO.</p>";
                html += "<p style='color: red'>SI NO ESTUVIERA CONFORME CON EL EQUIPO TIENE DENTRO DE LOS 07 DÍAS NATURALES PARA REALIZAR LA DEVOLUCIÓN DEL EQUIPO DEBIDAMENTE EMBALADO Y CON SU RESPECTIVA CAJA PREVIA REVISIÓN DEL MISMO. SI TODO ESTA CONFORME PASAREMOS A REALIZAR LA DEVOLUCIÓN DEL COSTO DEL EQUIPO, MAS NO DE LA INSTALACIÓN NI DE LOS FILTROS, PUES YA ESTAN USADOS Y SE TIENEN QUE DESHECHAR, SE CONSIDERA COMO PÉRDIDA. EL COSTO DE LOS FILTROS.</p>";


                html += "</body>";
            }
            catch (Exception ex) {
                pagina = "<b>" + ex.Message + "</b>";
            }

            pagina += style;
            pagina += html;
            pagina += "</html>";

            AlternateView alternateView = AlternateView.CreateAlternateViewFromString(@pagina, null, "text/html");

            alternateView.LinkedResources.Add(res);
            return(alternateView);
        }
Beispiel #16
0
        private void procesarCotizacion()
        {
            Ent_Venta venta = new Ent_Venta();

            venta.cod_tienda      = cod_tienda;
            venta.tipo_venta      = tipo_venta;
            venta.cantidad        = sumarCantidad();
            venta.cliente_doc     = txtDesRuc.Text;
            venta.emision         = DateTime.Now.ToString("dd/MM/yyyy");
            venta.cliente         = txtDesCliente.Text;
            venta.email           = txtEmail.Text;
            venta.usuario         = usuario;
            venta.tipo_cotizacion = cboTipo.SelectedValue.ToString();
            venta.dias_alquiler   = int.Parse(txtDias.Text);
            venta.monto_subtotal  = double.Parse(txtSubTotal.Text);
            venta.monto_igv       = double.Parse(txtIGV.Text);
            venta.monto_total     = total;
            venta.denominacion    = txtDenominación.Text;
            venta.observacion     = txtObservacion.Text;
            venta.moneda          = cboMoneda.SelectedValue.ToString();

            bool existe_cliente = BL_Clientes.existeCliente(venta.cliente_doc);

            //save customer if doesnt exists
            if (!existe_cliente)
            {
                var confirm = MessageBox.Show("¿Desea guardar el cliente en el sistema?", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (confirm == DialogResult.Yes)
                {
                    Ent_Clientes nuevo_cliente = new Ent_Clientes();
                    nuevo_cliente.dni       = txtDesRuc.Text;
                    nuevo_cliente.nombres   = txtDesCliente.Text;
                    nuevo_cliente.apellidos = "";
                    nuevo_cliente.direccion = "";
                    nuevo_cliente.telefono  = "";
                    nuevo_cliente.email     = txtEmail.Text;
                    nuevo_cliente.tipo      = (nuevo_cliente.dni.Length > 8) ? "E" : "N";
                    nuevo_cliente.posible   = "1";

                    try
                    {
                        string _result = BL_Clientes.insertarCliente(nuevo_cliente);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Ocurrió un error al grabar al cliente, sin embargo, el proceso de compra continuará.\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                }
            }

            foreach (DataGridViewRow row in dgvProductos.Rows)
            {
                Ent_Productos prd = new Ent_Productos();
                prd.cod_producto = row.Cells["CODIGO"].Value.ToString();
                prd.id           = int.Parse(row.Cells["ID"].Value.ToString());
                prd.nombre       = row.Cells["DESCRIPCION"].Value.ToString();
                prd.cantidad     = int.Parse(row.Cells["CANTIDAD"].Value.ToString());
                prd.precio       = float.Parse(row.Cells["PU"].Value.ToString());
                prd.monto_total  = float.Parse(row.Cells["IMPORTE"].Value.ToString());

                venta.lstProductos.Add(prd);
            }

            try
            {
                string id_cab = "";
                string result = BL_Ventas.procesarCotizacion(venta, out id_cab);

                venta.id_cab = Convert.ToInt32(id_cab);

                Email email = new Email();
                email.Send_Email(venta, _ent_tienda, ent_configuracion, txtObservacion.Text, adjunto);

                if (result == "1")
                {
                    MessageBox.Show("Cotización Realizada con Éxito!.", "Cotización", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    InvoicePDF pdf = new InvoicePDF();
                    pdf.createCotizacion(ent_configuracion, venta);
                    reiniciarVenta();
                }
                else
                {
                    MessageBox.Show(result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error en el proceso de cotización.\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #17
0
 public static List <Ent_Venta> getVentasPorCliente(Ent_Venta entity)
 {
     return(DAO_Ventas.getVentasPorCliente(entity));
 }
Beispiel #18
0
 public static List <Ent_Venta> getConsultaVentas(Ent_Venta ent_venta)
 {
     return(DAO_Ventas.getConsultaVentas(ent_venta));
 }
Beispiel #19
0
 public static string procesarVenta(Ent_Venta venta)
 {
     return(DAO_Ventas.procesarVenta(venta));
 }
Beispiel #20
0
 public static string procesarIngresoAlmacen(Ent_Venta venta)
 {
     return(DAO_Ventas.procesarIngresoAlmacen(venta));
 }
Beispiel #21
0
 public static List <Ent_Venta> getVentas(Ent_Venta ent_tienda)
 {
     return(DAO_Ventas.getVentas(ent_tienda));
 }
Beispiel #22
0
        public void createCotizacion(Ent_Configuracion ent_configuracion, Ent_Venta venta)
        {
            PdfDocument document = new PdfDocument();
            PdfPage     page     = document.AddPage();
            XGraphics   gfx      = XGraphics.FromPdfPage(page);

            //XImage image = XImage.FromFile(logo);
            //gfx.DrawImage(image, 0, marginTop, 256, 80);

            XFont font     = new XFont(fontName, 10);
            XFont fontBox  = new XFont(fontName, 15);
            XFont fontNota = new XFont(fontName, 7);

            int yPosHeader1 = marginTop + 20;

            gfx.DrawString(ent_configuracion.RAZON_SOCIAL, font, XBrushes.Black, marginLeft, yPosHeader1);
            yPosHeader1 = yPosHeader1 + 15;
            gfx.DrawString(ent_configuracion.DIRECCION, font, XBrushes.Black, marginLeft, yPosHeader1);
            yPosHeader1 = yPosHeader1 + 15;
            gfx.DrawString("Cel. " + ent_configuracion.TELEFONO, font, XBrushes.Black, marginLeft, yPosHeader1);
            yPosHeader1 = yPosHeader1 + 15;
            gfx.DrawString("[email protected] / www.osmosisperu.com", font, XBrushes.Black, marginLeft, yPosHeader1);

            int yPosHeader2 = marginTop;

            drawBox(gfx, Convert.ToInt32(page.Width / 1.5), marginTop, Convert.ToInt32(page.Width / 2.9 - marginRight * 2), 80);
            yPosHeader2 = yPosHeader2 + 20;
            gfx.DrawString("R.U.C. " + ent_configuracion.RUC, fontBox, XBrushes.Black, Convert.ToInt32(page.Width / 1.5) + 15, yPosHeader2);
            gfx.DrawRectangle(XBrushes.Black, Convert.ToInt32(page.Width / 1.5), 40, Convert.ToInt32(page.Width / 2.9 - marginRight * 2), 20);
            yPosHeader2 = yPosHeader2 + 25;
            gfx.DrawString("COTIZACIÓN", fontBox, XBrushes.White, Convert.ToInt32(page.Width / 1.5) + 45, yPosHeader2);
            yPosHeader2 = yPosHeader2 + 25;
            gfx.DrawString("001-" + venta.id_cab.ToString().PadLeft(6, '0'), fontBox, XBrushes.Black, Convert.ToInt32(page.Width / 1.5) + 45, yPosHeader2);

            int yPosCustomerDetails = yPosHeader2 + 40;

            gfx.DrawString("Lima, " + DateTime.Now.ToString("d 'de' MMMM 'del' yyyy"), font, XBrushes.Black, marginLeft, yPosCustomerDetails);
            yPosCustomerDetails = yPosCustomerDetails + 20;
            gfx.DrawString("Cliente: " + venta.cliente, font, XBrushes.Black, marginLeft, yPosCustomerDetails);
            yPosCustomerDetails = yPosCustomerDetails + 20;
            gfx.DrawString("Dirección: " + venta.direccion, font, XBrushes.Black, marginLeft, yPosCustomerDetails);
            gfx.DrawString("DNI/RUC: " + venta.cliente_doc, font, XBrushes.Black, page.Width / 1.35, yPosCustomerDetails);
            if (venta.tipo_cotizacion.Equals("AL"))
            {
                yPosCustomerDetails = yPosCustomerDetails + 20;
                gfx.DrawString("Días Alquiler: " + venta.dias_alquiler, font, XBrushes.Black, marginLeft, yPosCustomerDetails);
            }

            int totalItems = venta.lstProductos.Count;

            int yPosBoxItems = yPosCustomerDetails + 25;
            int yPosBoxTitle = yPosBoxItems + 15;
            int boxHeight    = yPosBoxTitle + 20 * totalItems - yPosBoxItems + 10;

            //ITEMS BOX
            drawBox(gfx, marginLeft, yPosBoxItems, Convert.ToInt32(page.Width - marginRight * 2), boxHeight);

            //TITLE BOX
            drawBox(gfx, marginLeft, yPosBoxItems, Convert.ToInt32(page.Width - marginRight * 2), 20);

            int xPosCant    = marginLeft + 10;
            int xPosDesc    = marginLeft + 60;
            int xPosPUnit   = Convert.ToInt32(page.Width - 150);
            int xPosImporte = Convert.ToInt32(page.Width - 80);

            gfx.DrawString("CANT.", font, XBrushes.Black, xPosCant, yPosBoxTitle);
            gfx.DrawString("DESCRIPCIÓN", font, XBrushes.Black, xPosDesc, yPosBoxTitle);
            gfx.DrawString("P. UNIT", font, XBrushes.Black, xPosPUnit, yPosBoxTitle);
            gfx.DrawString("IMPORTE", font, XBrushes.Black, xPosImporte, yPosBoxTitle);

            int yPosBoxTitleWMargin = yPosBoxTitle + 20;
            int yPosLastItem        = 0;
            int i = 0;

            venta.lstProductos.ForEach(delegate(Ent_Productos m) {
                yPosLastItem = yPosBoxTitleWMargin + 20 * i;
                gfx.DrawString(Convert.ToString(m.cantidad), font, XBrushes.Black, xPosCant, yPosLastItem);
                gfx.DrawString(m.nombre, font, XBrushes.Black, xPosDesc, yPosLastItem);
                gfx.DrawString(m.precio.ToString("#0.00"), font, XBrushes.Black, xPosPUnit, yPosLastItem);
                gfx.DrawString((m.cantidad * m.precio).ToString("#0.00"), font, XBrushes.Black, xPosImporte, yPosLastItem);
                i++;
            });

            int totalTextWidth = xPosImporte - xPosPUnit;
            int totalWidth     = Convert.ToInt32(page.Width - marginRight) - xPosImporte + 1;
            //drawBox(gfx, xPosPUnit, yPosLastItem + 9, totalTextWidth, 20);
            int yPosTotalesBox = yPosLastItem + 9;

            drawBox(gfx, xPosImporte - 1, yPosTotalesBox, totalWidth, 15);
            yPosTotalesBox = yPosTotalesBox + 15;
            drawBox(gfx, xPosImporte - 1, yPosTotalesBox, totalWidth, 15);
            yPosTotalesBox = yPosTotalesBox + 15;
            drawBox(gfx, xPosImporte - 1, yPosTotalesBox, totalWidth, 15);

            String intPart = venta.monto_total.ToString().Split('.')[0];

            String totalString = Convert.ToInt32(intPart).ToWords().ToUpper();
            var    decimalPart = (int)(((decimal)venta.monto_total % 1) * 100);

            int yPosTotales = yPosLastItem + 20;

            gfx.DrawString("SubTotal", font, XBrushes.Black, xPosPUnit, yPosTotales);
            gfx.DrawString(venta.monto_subtotal.ToString("#0.00"), font, XBrushes.Black, xPosImporte + 5, yPosTotales);
            yPosTotales = yPosTotales + 15;
            gfx.DrawString("IGV", font, XBrushes.Black, xPosPUnit, yPosTotales);
            gfx.DrawString(venta.monto_igv.ToString("#0.00"), font, XBrushes.Black, xPosImporte + 5, yPosTotales);
            yPosTotales = yPosTotales + 15;
            gfx.DrawString("TOTAL", font, XBrushes.Black, xPosPUnit, yPosTotales);
            gfx.DrawString(venta.monto_total.ToString("#0.00"), font, XBrushes.Black, xPosImporte + 5, yPosTotales);
            yPosTotales = yPosTotales + 15;
            gfx.DrawString("Son " + totalString + " Y " + decimalPart.ToString().PadLeft(2, '0') + "/100 " + ((venta.moneda == "PEN") ? "Soles" : "Dólares Americanos"), font, XBrushes.Black, marginLeft, yPosTotales);

            int yPosNota = yPosTotales + 100;

            gfx.DrawString(venta.observacion, fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("SOLO PAGO POR TRANSFERENCIA BANCARIA", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("RECOGER CON BAUCHER DE DEPOSITO", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("INVERSIONES GUTIERREZ Y DOMINGUEZ EIRL", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("RUC: 20512225048 - DANIEL PORTOCARRERO 376 URB. LOS LAURELES - CHORRILLOS", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("CUENTA BBVA", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("SOLES:   0011-0117-0100097865   INTERBANCARIO SOLES:   011-117-000100097865-98", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("DOLARES: 0011-0117-01-00095641  INTERBANCARIO DOLARES: 011-117-000100095641-95", fontNota, XBrushes.Black, marginLeft, yPosNota);


            yPosNota = yPosNota + 40;
            gfx.DrawString("NOTA IMPORTANTE DE INSTALACIÓN: OSMOSISPERU NO SE HACE RESPONSABLE POR DESPERFECTOS", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("PRODUCIDO POR ACCIONES AJENAS A NUESTRA INSTALACIÓN COMO POR EJEMPLO, TUBERIAS ANTIGUAS,", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("TUBOS DE ABASTO VIEJOS, O DESPERFECTOS EN SUS DESAGÜES, ASI TAMBIÉN  NO NOS HACEMOS", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("RESPONSABLES POR ALGUNA MODIFICACIÓN QUE SE HAYA REALIZADO AL MOMENTO DE INSTALARLO.", fontNota, XBrushes.Black, marginLeft, yPosNota);

            /*yPosNota = yPosNota + 15;
             * gfx.DrawString("DEBE EXISTIR UN PUNTO DE CORRIENTE EN LOS MUEBLES BAJOS A NO MAS DE 2 MT.", fontNota, XBrushes.Black, marginLeft, yPosNota);
             * yPosNota = yPosNota + 15;
             * gfx.DrawString("SI ESTA A MAS, SE COTIZARÁ 20 SOLES POR METRO O DE LO CONTRARIO DEBERÁ REALIZARLO", fontNota, XBrushes.Black, marginLeft, yPosNota);
             * yPosNota = yPosNota + 15;
             * gfx.DrawString("CON SU ELECTRICISTA. EN ESTE CASO EL TÉCNICO EBE DEJAR INSTALADO Y PROBADO  CON UNA", fontNota, XBrushes.Black, marginLeft, yPosNota);
             * yPosNota = yPosNota + 15;
             * gfx.DrawString("EXTENCIÓN QUE USTED TENGA.", fontNota, XBrushes.Black, marginLeft, yPosNota);*/

            yPosNota = yPosNota + 30;
            gfx.DrawString("SI NO ESTUVIERA CONFORME CON EL EQUIPO TIENE DENTRO DE LOS 07 DÍAS NATURALES PARA", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("REALIZAR LA DEVOLUCIÓN DEL EQUIPO DEBIDAMENTE EMBALADO Y CON SU RESPECTIVA CAJA", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("PREVIA REVISIÓN DEL MISMO. SI TODO ESTA CONFORME PASAREMOS A REALIZAR LA DEVOLUCIÓN", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("DEL COSTO DEL EQUIPO, MAS NO DE LA INSTALACIÓN NI DE LOS FILTROS, PUES YA ESTAN USADOS", fontNota, XBrushes.Black, marginLeft, yPosNota);
            yPosNota = yPosNota + 15;
            gfx.DrawString("Y SE TIENEN QUE DESHECHAR, SE CONSIDERA COMO PÉRDIDA. EL COSTO DE LOS FILTROS", fontNota, XBrushes.Black, marginLeft, yPosNota);

            /*yPosNota = yPosNota + 15;
             * gfx.DrawString("ES $50.00 DÓLARES AMERICANOS QUE SE DESCONTARAN DEL COSTO DEL EQUIPO.", fontNota, XBrushes.Black, marginLeft, yPosNota);
             *
             * yPosNota = yPosNota + 30;
             * gfx.DrawString("COSTO DEL EQUIPO $250 DÓLARES AMERICANOS.", fontNota, XBrushes.Black, marginLeft, yPosNota);
             * yPosNota = yPosNota + 15;
             * gfx.DrawString("COSTO DE INSTALACIÓN $50 DÓLARES AMERICANOS DENTRO DE LIMA METROPOLITANA.", fontNota, XBrushes.Black, marginLeft, yPosNota);*/


            String filename = "invoices\\cotizacion_" + venta.id_cab + ".pdf";

            document.Save(filename);
            Process.Start(filename);
        }
Beispiel #23
0
 public static List <Ent_Venta> getConsultaCotizacion(Ent_Venta venta)
 {
     return(DAO_Ventas.getConsultaCotizacion(venta));
 }