private void CambiarEstadoDevolucion(Devolucion SelectedDevolucion)
 {
     DevolucionSQL dsql = new DevolucionSQL();
     dsql.cambiarEstado(SelectedDevolucion.IdDevolucion, 2);
 }
Ejemplo n.º 2
0
        public string formatoBP(Devolucion d, int num, List<DevolucionProducto> lstProductos)
        {
            double valorVenta = 0;
            double precioReal;
            num++;
            string content =
                @"<html>
                    <body>
                        <table>
                            <tr>
                                <td>
                                    <span style='text-align: center; text-decoration: underline; font-size: 1em; font-weight: bold'>MadeInHouse S.A.</span><br>
                                    <span style='text-align: center; font-size: 0.5em'>
                                        Av. Priority N° xxx - San Miguel - Lima<br>
                                        Telf: 999-9999<br>
                                        www.MadeInHouse.com Email: [email protected]
                                    </span>
                                </td>
                                <td></td>
                                <td border=1>
                                    <span style='text-align: center; font-size: 1em'>
                                        R.U.C. N° XXXXXXXXXXX<br>
                                        NOTA DE CREDITO<br>
                                        001 - N° " + (d.NumDocCredito = num.ToString().PadLeft(6, '0'));
            content +=              "</span>" +
                                "</td>" +
                            "</tr>" +
                        "</table>" +
                        "<br>" +
                        "<table width=100%>" +
                            "<tr>" +
                                "<td width=200 border=1>";
            if (d.venta.IdCliente > 0)
            {
                ClienteSQL cSQL = new ClienteSQL();
                Cliente cli = cSQL.BuscarClienteByIdCliente(d.venta.IdCliente);
                content += "<span style='font-size: 0.5em'>" +
                                        "Señor (es): " + cli.ApePaterno + " " + cli.ApeMaterno + ", " + cli.Nombre + "<br>" +
                                        "Dirección : " + cli.Direccion + "<br>" +
                                        "R.U.C. N° : " + cli.Ruc +
                                    "</span>";
            }
            else
            {
                content +=          "<span style='font-size: 0.5em'>" +
                                        "DNI: " + d.venta.dni + "<br>" +
                                    "</span>";
            }
            content += "</td>" +
                                "<td width=100>" +
                                    "<table border=1 width=150 align=center>" +
                                        "<tr><td><span style='text-align: center; font-size: 0.5em'>FECHA DE EMISIÓN</span></td></tr>" +
                                        "<tr><td><span style='text-align: center; font-size: 0.5em'>" + DateTime.Now.ToString("dd/MM/yyyy") + "</span></td></tr>" +
                                    "</table>" +
                                "</td>" +
                            "</tr>" +
                        "</table>" +
                        "<br>" +
                        "<table border=1 height=700>" +
                            "<tr>" +
                                "<th><span style='font-size: 0.5em'>CODIGO</span></th>" +
                                "<th><span style='font-size: 0.5em'>CANTIDAD</span></th>" +
                                "<th><span style='font-size: 0.5em'>DESCRIPCION</span></th>" +
                                "<th><span style='font-size: 0.5em'>PRECIO</span></th>" +
                                "<th><span style='font-size: 0.5em'>SUB TOTAL</span></th>" +
                            "</tr>";
            if (lstProductos != null)
            {
                foreach (DevolucionProducto prod in lstProductos)
                {
                    if (prod.Devuelve > 0)
                    {
                        content += "<tr>" +
                                    "<td><span style='font-size: 0.5em'>" + prod.CodProducto + "</span></th>" +
                                    "<td><span style='font-size: 0.5em'>" + prod.Devuelve + "</span></th>" +
                                    "<td><span style='font-size: 0.5em'>" + prod.Producto + "</span></th>" +
                                    "<td><span style='font-size: 0.5em'>" + Math.Round(precioReal = (prod.Precio / 1.18), 2) + "</span></th>" +
                                    "<td><span style='font-size: 0.5em'>" + Math.Round(valorVenta += prod.Devuelve * precioReal, 2) + "</span></th>" +
                                    "</tr>";

                    }
                }
            }
            content += "</table>" +
                        "<br>" +
                        "<table border=1>" +
                            "<tr>" +
                                "<td><span style='font-size: 0.5em'>VALOR VENTA</span></td>" +
                                "<td><span style='font-size: 0.5em'>" + Math.Round(valorVenta, 2) + "</span></td>" +
                                "<td><span style='font-size: 0.5em'>IGV</span></td>" +
                                "<td><span style='font-size: 0.5em'>" + Math.Round(0.18 * valorVenta, 2) + "</span></td>" +
                                "<td><span style='font-size: 0.5em'>TOTAL A PAGAR</span></td>" +
                                "<td><span style='font-size: 0.5em'>" + (d.Monto = Math.Round(1.18 * valorVenta, 2)) + "</span></td>" +
                            "</tr>" +
                        "</table>" +
                    "</body>" +
                "</html>";

            return content;
        }
Ejemplo n.º 3
0
        public string registrarDevolucion(Devolucion dev, List<DevolucionProducto> prod)
        {
            DBConexion db = new DBConexion();
            db.conn.Open();
            SqlTransaction trans = db.conn.BeginTransaction();
            db.cmd.Transaction = trans;
            DevolucionSQL devSQL = new DevolucionSQL(db);
            int idDevolucion;
            string message;

            if ((idDevolucion = devSQL.insertarDevolucion(dev)) > 0)
            {
                if (devSQL.insertarProductosDevolucion(idDevolucion, prod))
                {
                    trans.Commit();
                    return "La operacion fue exitosa";
                }
                else
                    message = "Hubo un error al agregar los productos";
            }
            else
                message = "No se pudo crear la solicitud";

            trans.Rollback();
            return message;
        }
Ejemplo n.º 4
0
 public string GenerarNotaCredito(Devolucion d, int num, List<DevolucionProducto> lstProductos)
 {
     string pathString = Environment.CurrentDirectory + @"\Archivos\NotasCredito";
     System.IO.Directory.CreateDirectory(pathString);
     GenerarPDF pdf = new GenerarPDF();
     string body = formatoBP(d, num, lstProductos).ToString();
     string date = DateTime.Now.ToString("yyyyMMddHHmmss");
     pdf.createPDF(body, "\\Archivos\\NotasCredito\\Nota"+date+".pdf", true);
     return "\\Archivos\\NotasCredito\\Nota" + date + ".pdf";
 }
Ejemplo n.º 5
0
        public List<Devolucion> buscarDevoluciones(string notaCredito, string docPago, int estado, string registroDesde, string registroHasta, string dni)
        {
            List<Devolucion> lstAux = null;
            Devolucion devTemp;
            int posIdDevolucion, posDNI, posDocPago, posNotaCredito, posMonto, posRegistro, posEstado;
            string where = "";

            if (!String.IsNullOrEmpty(notaCredito))
            {
                where += " AND d.numDocCredito = @notaCredito ";
                db.cmd.Parameters.Add(new SqlParameter("notaCredito", notaCredito));
            }

            if (!String.IsNullOrEmpty(docPago))
            {
                where += " AND v.numDocPagoProducto = @docPago ";
                db.cmd.Parameters.Add(new SqlParameter("docPago", docPago));
            }

            if (estado > 0)
            {
                where += " AND d.estado = @estado ";
                db.cmd.Parameters.Add(new SqlParameter("estado", estado));
            }

            if (!String.IsNullOrEmpty(registroDesde))
            {
                where += " AND convert (char, d.fechaReg, 103) >= @registroDesde ";
                db.cmd.Parameters.Add(new SqlParameter("registroDesde", registroDesde));
            }

            if (!String.IsNullOrEmpty(registroHasta))
            {
                where += " AND convert (char, d.fechaReg, 103) <= @registroHasta ";
                db.cmd.Parameters.Add(new SqlParameter("registroHasta", registroHasta));
            }

            if (!String.IsNullOrEmpty(dni))
            {
                where += " AND v.dni = @dni ";
                db.cmd.Parameters.Add(new SqlParameter("dni", dni));
            }

            db.cmd.CommandText = "SELECT * FROM Devolucion d, Venta v WHERE d.idVenta = v.idVenta " + where + " ORDER by idDevolucion ASC";

            if (db.cmd.Transaction == null) db.conn.Open();
            SqlDataReader reader = db.cmd.ExecuteReader();

            while (reader.Read())
            {
                if (lstAux == null) lstAux = new List<Devolucion>();
                devTemp = new Devolucion();
                devTemp.venta = new Venta();
                posIdDevolucion = reader.GetOrdinal("idDevolucion");
                posDNI = reader.GetOrdinal("dni");
                posDocPago = reader.GetOrdinal("numDocPagoProducto");
                posNotaCredito = reader.GetOrdinal("numDocCredito");
                posMonto = reader.GetOrdinal("monto");
                posRegistro = reader.GetOrdinal("fechaReg");
                posEstado = reader.GetOrdinal("estado");
                devTemp.IdDevolucion = reader.IsDBNull(posIdDevolucion) ? -1 : reader.GetInt32(posIdDevolucion);
                devTemp.venta.dni = reader.IsDBNull(posDNI) ? null : reader.GetString(posDNI);
                devTemp.venta.NumDocPago = reader.IsDBNull(posDocPago) ? null : reader.GetString(posDocPago);
                devTemp.NumDocCredito = reader.IsDBNull(posNotaCredito) ? null : reader.GetString(posNotaCredito);
                devTemp.Monto = reader.IsDBNull(posMonto) ? -1 : (double)reader.GetDecimal(posMonto);
                devTemp.fechaReg = reader.IsDBNull(posRegistro) ? null : reader.GetDateTime(posRegistro).ToString();
                devTemp.estado = reader.IsDBNull(posEstado) ? -1 : reader.GetInt32(posEstado);
                devTemp.nomEstado = (devTemp.estado == 1) ? "Registrada" : ((devTemp.estado == 2) ? "Ingresada" : "Anulada");
                lstAux.Add(devTemp);
            }

            db.cmd.Parameters.Clear();
            if (db.cmd.Transaction == null) db.conn.Close();

            return lstAux;
        }
Ejemplo n.º 6
0
        public int insertarDevolucion(Devolucion dev)
        {
            int result = -1;

            db.cmd.CommandText = " INSERT INTO Devolucion (numDocCredito,monto,fechaReg,estado,idVenta,idUsuario,archivo) " +
                " output INSERTED.idDevolucion " +
                " VALUES (@numDocCredito, @monto, GETDATE(), @estado, @idVenta, @idUsuario, @archivo) ";

            db.cmd.Parameters.AddWithValue("@numDocCredito", dev.NumDocCredito);
            db.cmd.Parameters.AddWithValue("@monto", dev.Monto);
            db.cmd.Parameters.AddWithValue("@idVenta", dev.venta.IdVenta);
            db.cmd.Parameters.AddWithValue("@idUsuario", dev.idUsuario);
            db.cmd.Parameters.AddWithValue("@archivo", dev.archivo);
            db.cmd.Parameters.AddWithValue("@estado", 1);

            if (db.cmd.Transaction == null) db.conn.Open();
            result = (int)db.cmd.ExecuteScalar();
            if (db.cmd.Transaction == null) db.conn.Close();
            db.cmd.Parameters.Clear();

            return result;
        }