Exemple #1
0
        public void llenarLabelTitulo()
        {
            Bibliotecas.Negocio.Viaje ve = new Bibliotecas.Negocio.Viaje();
            ve.Rut = Session["CLAVE"].ToString();

            if (ve.TieneViajes() == false)
            {
                lbTitulo.Text       = "NO HAY VIAJES DISPONIBLES";
                btnExportar.Visible = false;
            }
        }
Exemple #2
0
        public void llenarLabelTitulo()
        {
            Bibliotecas.Negocio.Viaje ve = new Bibliotecas.Negocio.Viaje();
            ve.Rut = Session["CLAVE"].ToString();

            if (ve.HayViajes() == false)
            {
                lbTitulo.Text       = "NO HAY VIAJES DISPONIBLES";
                btnExportar.Visible = false;
            }
            else
            {
                lbTitulo.Text       = "ESTOS SON TODOS LOS VIAJES REGISTRADOS";
                btnExportar.Visible = true;
            }
        }
        protected void btnPagar_Click(object sender, EventArgs e)
        {
            string rut = Session["CLAVE"].ToString();

            Bibliotecas.Negocio.Usuario user = new Bibliotecas.Negocio.Usuario();
            user.Rut1 = rut;
            float total = Convert.ToSingle(txtTotal.Text);


            if (ValidarCampos())
            {
                if (user.SaldoSuficiente(rut, total))
                {
                    Bibliotecas.Negocio.Viaje ve = new Bibliotecas.Negocio.Viaje();

                    user.Read();
                    int saldo = Convert.ToInt32(user.Saldo);

                    ve.Rut     = rut;
                    ve.Fecha   = CLFecha.SelectedDate;
                    ve.Patente = DLPatente.SelectedValue;
                    ve.Ruta    = DLruta.SelectedValue;
                    ve.Precio  = Convert.ToDecimal(txtTotal.Text);
                    ve.Create();

                    Bibliotecas.Negocio.Peaje pe = new Bibliotecas.Negocio.Peaje();
                    pe.Ruta = DLruta.SelectedValue;
                    pe.Read();

                    user.Saldo = saldo - Convert.ToSingle(txtTotal.Text);
                    user.UpdateSaldo();

                    Bibliotecas.Negocio.RegistroDescuento re = new Bibliotecas.Negocio.RegistroDescuento();
                    re.Rut        = rut;
                    re.Fecha      = DateTime.Now;
                    re.Peaje      = pe.Cantidad_portico;
                    re.Ruta       = DLruta.SelectedValue;
                    re.Porcentaje = Convert.ToDecimal(pe.Descuento);
                    re.Create();
                    SaldoActual();

                    string script = @"<script type='text/javascript'>
                            alerta('Viaje realizado');
                        </script>";

                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
                }
                else
                {
                    string script = @"<script type='text/javascript'>
                            alerta('No tiene saldo suficiente');
                        </script>";

                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
                }
            }
            else
            {
                string script = @"<script type='text/javascript'>
                            alerta('Campo patente o fecha no validos');
                        </script>";

                ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
            }
        }