
20/01/2011, 09:51
|
| | Fecha de Ingreso: enero-2009
Mensajes: 112
Antigüedad: 16 años, 1 mes Puntos: 0 | |
Respuesta: Problema con variable Gracias compa aqui lo pongo:
public partial class _Default : System.Web.UI.Page
{ string ID;
DateTime fechaActual = DateTime.Now; int temp;
protected void Page_Load(object sender, EventArgs e)
{
txtNombres.ReadOnly = true;
txtDireccion.ReadOnly = true;
txtTelefono.ReadOnly = true;
txtCelular.ReadOnly = true;
txtEmail.ReadOnly = true;
cboProfesion.Enabled = false;
cboPais.Enabled = false;
//botones
btnNuevo.Enabled = true;
btnGrabar.Enabled = false;
btnModificar.Enabled = false;
btnCancelar.Enabled = false;
btnEliminar.Enabled = false;
btnListar.Enabled = true;
btnSalir.Enabled = true;
//Grid
dtgDetalle.Enabled = true;
}
protected void btnGrabar_Click(object sender, EventArgs e)
{
if (txtNombres.Text.Trim().Length > 0)
{
contacto Persona = new contacto();
if (temp == 0)
{
Persona.AgregarContacto(txtNombres.Text, txtDireccion.Text, txtTelefono.Text,
txtCelular.Text, txtEmail.Text, fechaActual, Convert.ToInt32(cboProfesion.SelectedValue.ToStrin g()),
Convert.ToInt32(cboPais.SelectedValue.ToString())) ;
}
else
{
Persona.ModificarContacto(Convert.ToInt32(ID), txtNombres.Text,
txtDireccion.Text, txtTelefono.Text, txtCelular.Text, txtEmail.Text,
fechaActual, Convert.ToInt32(cboProfesion.SelectedValue.ToStrin g()),
Convert.ToInt32(cboPais.SelectedValue.ToString())) ;
}
//capa en los controles los blanqueo despues de insertar
txtNombres.Text = "";
txtDireccion.Text = "";
txtTelefono.Text = "";
txtCelular.Text = "";
txtEmail.Text = "";
cboProfesion.Enabled = false;
cboPais.Enabled = false;
//Botones
btnNuevo.Enabled = true;
btnGrabar.Enabled = false;
btnModificar.Enabled = false;
btnCancelar.Enabled = false;
btnEliminar.Enabled = false;
btnListar.Enabled = true;
btnSalir.Enabled = true;
}
}
protected void btnModificar_Click(object sender, EventArgs e)
{
if ((dtgDetalle.Rows.Count > 0) && (dtgDetalle.Rows[dtgDetalle.SelectedIndex].Cells[1].Text != null))
{ temp = 1; ID = dtgDetalle.Rows[dtgDetalle.SelectedIndex].Cells[1].Text;
//capa en los controles
txtCodigo.ReadOnly = false;
txtNombres.ReadOnly = false;
txtDireccion.ReadOnly = false;
txtTelefono.ReadOnly = false;
txtCelular.ReadOnly = false;
txtEmail.ReadOnly = false;
cboProfesion.Enabled = true;
cboPais.Enabled = true;
//Botones
btnNuevo.Enabled = false;
btnGrabar.Enabled = true;
btnModificar.Enabled = false;
btnCancelar.Enabled = true;
btnEliminar.Enabled = false;
btnListar.Enabled = false;
btnSalir.Enabled = false;
//Grid
dtgDetalle.Enabled = false;
} |