protected void btnRegistrar_Click(object sender, EventArgs e) { Bibliotecas.Negocio.Vehiculo ve = new Bibliotecas.Negocio.Vehiculo(); if (Vacio() == false) { if (ValidarColorYMarca()) { if (LargoPatente(txtpatente.Text)) { ve.Color = txtcolor.Text; ve.Marca = txtmarca.Text; ve.Modelo = txtmodelo.Text; ve.Patente1 = txtpatente.Text; ve.Rut1 = Session["CLAVE"].ToString(); ve.Create(); Server.Transfer("Vehiculo.aspx"); } else { string script = @"<script type='text/javascript'> alerta('La patente debe tener 6 caracteres'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } } else { string script = @"<script type='text/javascript'> alerta('La marca y el color no deben tener numeros'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } } else { string script = @"<script type='text/javascript'> alerta('No puedes tener campos vacios'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } }
protected void GBauto_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = (GridViewRow)GBauto.Rows[e.RowIndex]; TextBox txtMarca2 = (TextBox)row.FindControl("txtMarca2"); TextBox txtModelo2 = (TextBox)row.FindControl("txtModelo2"); TextBox txtColor2 = (TextBox)row.FindControl("txtColor2"); string marca = txtMarca2.Text; string color = txtColor2.Text; string modelo = txtModelo2.Text; Bibliotecas.Negocio.Vehiculo ve = new Bibliotecas.Negocio.Vehiculo(); if (Vacio2(marca, color, modelo)) { if (ValidarString(color)) { ve.Patente1 = GBauto.Rows[e.RowIndex].Cells[0].Text.ToString(); ve.Marca = marca; ve.Color = color; ve.Modelo = marca; ve.Update(); } else { e.Cancel = true; string script = @"<script type='text/javascript'> alerta('No puedes tener numeros en el color'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } } else { e.Cancel = true; string script = @"<script type='text/javascript'> alerta('No puedes tener campos vacios'); </script>"; ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } }