public double descuento() { Bibliotecas.Negocio.Peaje pe = new Bibliotecas.Negocio.Peaje(); pe.Ruta = DLruta.ToString(); pe.Read(); float des = Convert.ToSingle(pe.Descuento); return(des); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex]; TextBox tprecio = (TextBox)row.FindControl("txtprecio2"); TextBox tdesc = (TextBox)row.FindControl("txtDesc2"); TextBox tcantpor = (TextBox)row.FindControl("txtCantPor2"); string pre = tprecio.Text; string des = tdesc.Text; string can = tcantpor.Text; #region CodigoVaLidacion Bibliotecas.Negocio.Peaje pej = new Bibliotecas.Negocio.Peaje(); string ruta = GridView1.Rows[e.RowIndex].Cells[0].Text; if (vacio(pre, can, des)) { if (EsNumero(pre, can, des)) { pej.Ruta = ruta; pej.Precio = Convert.ToDecimal(pre); pej.Descuento = Convert.ToSingle(des); pej.Cantidad_portico = Convert.ToInt32(can); pej.UpdateCompleto(); } else { e.Cancel = true; string script = @"<script type='text/javascript'> alerta('Debe ingresar numeros enteros'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } } else { e.Cancel = true; string script = @"<script type='text/javascript'> alerta('Ningun campo puede estar vacio'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } #endregion }
public void llenartexbox() { Bibliotecas.Negocio.Peaje pe = new Bibliotecas.Negocio.Peaje(); string a = string.Empty; pe.Ruta = DLruta.SelectedValue; a = DLruta.SelectedValue; pe.Read(); int cant = pe.Cantidad_portico; float des = pe.Descuento / 100; Decimal pre = pe.Precio; int desc = Convert.ToInt32(Convert.ToSingle(pre) * des); int total = Convert.ToInt32(pre) - desc; txtPrecio.Text = pre.ToString(); txtCantidad.Text = cant.ToString(); txtDescuento.Text = desc.ToString(); txtTotal.Text = total.ToString(); }
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); } }