Exemplo n.º 1
0
        public int CreateVenta(VentaVO vo)
        {
            string resp = string.Empty;

            try
            {
                string       query   = "sp_Venta_crear";
                MySqlCommand comando = this.Conexion.CreateCommand();
                comando.CommandType = CommandType.StoredProcedure;
                comando.CommandText = query;
                comando.Parameters.AddWithValue("p_cliente", vo.Cliente);
                comando.Parameters.AddWithValue("p_Folio", vo.Folio);
                comando.Parameters.AddWithValue("p_enganche", vo.Enganche);
                comando.Parameters.AddWithValue("p_bonificacion", vo.Bonificacion);
                comando.Parameters.AddWithValue("p_totalt", vo.TotalT);
                comando.Parameters.AddWithValue("p_plazo", vo.Plazo);
                // Se toma el valor devuelto
                resp = comando.ExecuteScalar().ToString();
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return(int.Parse(resp));
        }
Exemplo n.º 2
0
        public List <VentaVO> GetVentaList(BaseGridVO filtro)
        {
            List <VentaVO>  lista = new List <VentaVO>();
            MySqlDataReader dr    = null;

            try
            {
                string       query   = "sp_Ventas_select_lista";
                MySqlCommand comando = this.Conexion.CreateCommand();
                comando.CommandType = CommandType.StoredProcedure;
                comando.CommandText = query;
                comando.Parameters.Add("p_campobusqueda", MySqlDbType.VarChar).Value = filtro.campobusqueda ?? string.Empty;
                comando.Parameters.Add("p_valorbusqueda", MySqlDbType.VarChar).Value = filtro.valorbusqueda ?? string.Empty;
                comando.Parameters.Add("p_numeropagina", MySqlDbType.Int32).Value    = filtro.pagina;
                comando.Parameters.Add("p_porpagina", MySqlDbType.Int32).Value       = filtro.porpagina;
                comando.Parameters.Add("p_orderby", MySqlDbType.VarChar).Value       = filtro.orderby;
                comando.Parameters.Add("p_ordertype", MySqlDbType.VarChar).Value     = filtro.ordertype;
                // Se toma el valor devuelto
                dr = comando.ExecuteReader();

                if (dr.HasRows)
                {
                    VentaVO vo;
                    while (dr.Read())
                    {
                        vo = new VentaVO();

                        vo.Clave = dr.GetInt32(dr.GetOrdinal("Clave"));

                        vo.Cliente       = dr.GetInt32(dr.GetOrdinal("Cliente"));
                        vo.ClienteNombre = dr["ClienteNombre"].ToString();
                        vo.Folio         = dr["Folio"].ToString();
                        vo.TotalT        = dr.GetDecimal(dr.GetOrdinal("TotalT"));
                        var Fecha = Convert.ToDateTime(dr["Fecha"]);
                        vo.Fecha = Fecha.ToString("yyyy-MM-dd");
                        //vo.RFC = dr["RFC"].ToString();
                        vo.total = Convert.ToInt32(dr["total"]);
                        lista.Add(vo);
                    }
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            finally
            {
                if (dr != null && !dr.IsClosed)
                {
                    dr.Close();
                }

                dr = null;
            }

            return(lista);
        }
Exemplo n.º 3
0
    protected void btnContinuar_Click(object sender, EventArgs e)
    {
        lblMensaje.Text = string.Empty;
        DAL_Venta oVenta = new DAL_Venta();
        VentaVO   venta  = new VentaVO();

        venta.Barrio        = txtBarrio.Text;
        venta.Ciudad        = dllCiudad.SelectedItem.Value;
        venta.Comentarios   = txtComentarios.Text;
        venta.Direccion     = txtDireccion.Text;
        venta.Email         = txtEmail.Text;
        venta.NombreCliente = txtNombre.Text;
        venta.Telefono      = txtTelefono.Text;
        if (optConsignacion.Checked == true)
        {
            venta.Pago = Convert.ToInt16(UtilidadesPeterPan.eTipoPago.eConsignacion);
        }

        /*if (optPagos.Checked == true)
         * {
         *  venta.Pago = Convert.ToInt16(UtilidadesPeterPan.eTipoPago.ePagos);
         * }
         * if (optPay.Checked == true)
         * {
         *  venta.Pago = Convert.ToInt16(UtilidadesPeterPan.eTipoPago.ePaypal);
         * }*/
        if (optContra.Checked == true)
        {
            venta.Pago = Convert.ToInt16(UtilidadesPeterPan.eTipoPago.eContraentrega);
        }
        if (optSer.Checked == true)
        {
            venta.Envio = Convert.ToInt16(UtilidadesPeterPan.eEnvio.eServientrega);
        }
        if (optDom.Checked == true)
        {
            venta.Envio = Convert.ToInt16(UtilidadesPeterPan.eEnvio.eDomicilio);
        }
        if (optSin.Checked == true)
        {
            venta.Envio = Convert.ToInt16(UtilidadesPeterPan.eEnvio.eSinEnvio);
        }
        venta.Productos = (List <ProductoVO>)Session[UtilidadesPeterPan.VENTAS];
        try
        {
            venta.Numero_venta = oVenta.InsertarVenta(venta);
            Session[UtilidadesPeterPan.SESION_VENTA] = venta;
            Session.Remove(UtilidadesPeterPan.VENTAS);
            EnviarCorreo(venta);
            Response.Redirect("Frm_Confirmacion.aspx", true);
        }
        catch (Exception ex)
        {
            lblMensaje.Text = ex.Message;
        }
    }
Exemplo n.º 4
0
 public ActionResult CreateVenta(VentaVO vo)
 {
     try
     {
         VentasBS BS = new VentasBS();
         return(Json(BS.CreateVenta(vo)));
     }
     catch (Exception ex)
     {
         return(Json(ParseException(new CCExcepcion(ex))));
     }
 }
Exemplo n.º 5
0
    void LLenarCamposVenta(VentaVO venta)
    {
        lblMensajeFinal.Text = "Tu compra ha sido aprobada ...";
        Random r      = new Random(DateTime.Now.Millisecond);
        int    numero = r.Next();

        lblNumeroAprobacion.Text = numero.ToString() + "-" + venta.Numero_venta.ToString();
        txtBarrio.Text           = venta.Barrio;
        txtDireccion.Text        = venta.Direccion;
        txtEmail.Text            = venta.Email;
        txtNombre.Text           = venta.NombreCliente;
        txtTelefono.Text         = venta.Telefono;
        dllCiudad.Text           = ObtenerValorDominio(venta.Ciudad, UtilidadesPeterPan.DOMINIO_CIUDAD).Descripcion;
        decimal valor       = Convert.ToDecimal(Session[UtilidadesPeterPan.VALOR_VENTA]);
        decimal valor_envio = 0;

        if (venta.Envio == Convert.ToInt16(UtilidadesPeterPan.eEnvio.eDomicilio))
        {
            valor_envio   = ObtenerValorParametro(UtilidadesPeterPan.PARAMETRO_DOM).Moneda;
            lblEnvio.Text = "Domicilio: " + String.Format("${0:#,#}", valor_envio);
        }
        if (venta.Envio == Convert.ToInt16(UtilidadesPeterPan.eEnvio.eServientrega))
        {
            valor_envio   = ObtenerValorParametro(UtilidadesPeterPan.PARAMETRO_SERV).Moneda;
            lblEnvio.Text = "Servientrega: " + String.Format("${0:#,#}", valor_envio);
        }
        if (venta.Envio == Convert.ToInt16(UtilidadesPeterPan.eEnvio.eSinEnvio))
        {
            lblEnvio.Text = "Sin Envio";
        }
        //PAGO
        if (venta.Pago == Convert.ToInt16(UtilidadesPeterPan.eTipoPago.eConsignacion))
        {
            lblPago.Text = "Consignación: Consignar a la cuenta corriente: 4821 6000 3687 a nombre de Hector Morales";
        }
        if (venta.Pago == Convert.ToInt16(UtilidadesPeterPan.eTipoPago.eContraentrega))
        {
            lblPago.Text = "Contraentrega";
        }
        if (venta.Pago == Convert.ToInt16(UtilidadesPeterPan.eTipoPago.ePagos))
        {
            lblPago.Text = "Pagos Online";
        }
        if (venta.Pago == Convert.ToInt16(UtilidadesPeterPan.eTipoPago.ePaypal))
        {
            lblPago.Text = "Paypal";
        }
        valor         = valor + valor_envio;
        lblTotal.Text = "Total: " + String.Format("${0:#,#}", valor);
        Session.Remove(UtilidadesPeterPan.VALOR_VENTA);
    }
Exemplo n.º 6
0
 public int CreateVenta(VentaVO vo)
 {
     try
     {
         return(this.Con.CreateVenta(vo));
     }
     catch (CCExcepcion)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new CCExcepcion(ex);
     }
 }
Exemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session[UtilidadesPeterPan.SESION_VENTA] == null)
         {
             Response.Redirect("Frm_Catalogo.aspx", true);
         }
         else
         {
             VentaVO venta = new VentaVO();
             venta = (VentaVO)Session[UtilidadesPeterPan.SESION_VENTA];
             DataBindVentas(venta.Productos);
             LLenarCamposVenta(venta);
         }
     }
 }
Exemplo n.º 8
0
    public bool VentaNueva(UsuarioVO _token, VentaVO _venta)
    {
        bool _valido = false;

        DAL.DAL_PuntoVenta.DAL_PuntoVenta oPuntoVenta = new DAL.DAL_PuntoVenta.DAL_PuntoVenta();
        DAL.DAL_Ventas.DAL_Venta          oVentas     = new DAL.DAL_Ventas.DAL_Venta();
        if (ValidarToken(_token) == true)
        {
            if (oVentas.InsertarVenta(_venta) > 0)
            {
                _valido = true;
            }
        }
        else
        {
            _valido = false;
        }
        return(_valido);
    }
Exemplo n.º 9
0
        public int InsertarVenta(VentaVO venta)
        {
            DbCommand dbInsertar;

            try
            {
                dbInsertar = conexionDB.GetStoredProcCommand("PRC_VENTA");
                conexionDB.AddInParameter(dbInsertar, "@cliente", DbType.String, venta.NombreCliente);
                conexionDB.AddInParameter(dbInsertar, "@barrio", DbType.String, venta.Barrio);
                conexionDB.AddInParameter(dbInsertar, "@ciudad", DbType.String, venta.Ciudad);
                conexionDB.AddInParameter(dbInsertar, "@comentarios", DbType.String, venta.Comentarios);
                conexionDB.AddInParameter(dbInsertar, "@direccion", DbType.String, venta.Direccion);
                conexionDB.AddInParameter(dbInsertar, "@email", DbType.String, venta.Email);
                conexionDB.AddInParameter(dbInsertar, "@telefono", DbType.String, venta.Telefono);
                conexionDB.AddInParameter(dbInsertar, "@envio", DbType.Int32, venta.Envio);
                conexionDB.AddInParameter(dbInsertar, "@pago", DbType.Int32, venta.Pago);
                conexionDB.AddInParameter(dbInsertar, "@tarjeta", DbType.Int16, venta.Tarjeta);
                conexionDB.AddInParameter(dbInsertar, "@punto_venta", DbType.Int16, venta.PuntoVenta);
                conexionDB.AddInParameter(dbInsertar, "@archivo", DbType.String, venta.Archivo);
                conexionDB.AddOutParameter(dbInsertar, "@numero", DbType.Int32, 10);
                conexionDB.ExecuteNonQuery(dbInsertar);
                Int32 numero_factura = 0;
                numero_factura = Convert.ToInt32(conexionDB.GetParameterValue(dbInsertar, "@numero"));
                int contador = 0;
                foreach (ProductoVO _producto in venta.Productos)
                {
                    contador = contador + 1;
                    InsertarDetalle(_producto, contador, numero_factura);
                }
                return(numero_factura);
            }
            catch (Exception ex)
            {
                CLS_Error error = new CLS_Error(ex.Message + "-" + ex.StackTrace);
                return(0);
            }
        }
Exemplo n.º 10
0
    void EnviarCorreo(VentaVO _venta)
    {
        // Gmail Address from where you send the mail
        var    fromAddress = ConfigurationManager.AppSettings["Correo"].ToString();
        string toAddress;

        if (ConfigurationManager.AppSettings["Copia"].ToString() != String.Empty)
        {
            // any address where the email will be sending
            toAddress = ConfigurationManager.AppSettings["Copia"].ToString() + "," + _venta.Email;
        }
        else
        {
            // any address where the email will be sending
            toAddress = _venta.Email;
        }
        //Password of your gmail address
        string fromPassword = ConfigurationManager.AppSettings["Password"].ToString();
        // Passing the values and make a email formate to display
        string subject = ConfigurationManager.AppSettings["Asunto"].ToString();
        string body    = "De: " + ConfigurationManager.AppSettings["Tienda"].ToString() + "\n";

        body += "Subject: " + ConfigurationManager.AppSettings["Asunto"].ToString() + "\n";
        body += "Telefono contacto: " + _venta.Telefono + "\n";
        body += "Dirección contacto: " + _venta.Direccion + "\n";
        body += "Barrio contacto: " + _venta.Barrio + "\n";
        body += "Hola Sr(a): " + _venta.NombreCliente + " Se confirmo la siguiente compra: \n";
        decimal valor       = 0;
        decimal valor_envio = 0;

        if (_venta.Envio == Convert.ToInt16(UtilidadesPeterPan.eEnvio.eDomicilio))
        {
            valor_envio = ObtenerValorParametro(UtilidadesPeterPan.PARAMETRO_DOM).Moneda;
        }
        if (_venta.Envio == Convert.ToInt16(UtilidadesPeterPan.eEnvio.eServientrega))
        {
            valor_envio = ObtenerValorParametro(UtilidadesPeterPan.PARAMETRO_SERV).Moneda;
        }
        foreach (ProductoVO prod in _venta.Productos)
        {
            body += "\n" + prod.Descripcion.ToString() + "\n";
            valor = valor + prod.Precio_Venta;
        }
        valor = valor + valor_envio;
        body += "\nTOTAL COMPRA" + String.Format("${0:#,#}", valor) + "\n";
        var smtp = new System.Net.Mail.SmtpClient();

        smtp.Send(fromAddress, toAddress, subject, body);

        /*
         * var smtp = new System.Net.Mail.SmtpClient();
         * {
         *  smtp.Host = ConfigurationManager.AppSettings["Host"].ToString();
         *  smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["Puerto"]);
         *  smtp.EnableSsl = true;
         *  smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
         *  smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
         *  smtp.Timeout = 200000;
         * }
         * // Passing values to smtp object
         * smtp.Send(fromAddress, toAddress, subject, body);
         */
    }