Exemplo n.º 1
0
        protected void btn_Guardar_Click(object sender, EventArgs e)
        {
            try {
                Int32 tipoSeguro = 0, departamento = 0, municipio = 0;
                tipoSeguro   = Convert.ToInt32(ddl_tipoSeguro.SelectedValue);
                departamento = Convert.ToInt32(ddl_Departamento.SelectedValue);
                municipio    = Convert.ToInt32(ddl_municipio.SelectedValue);

                conexion = new OracleConnection(cadena);
                conexion.Open();

                cmd             = new OracleCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = "insert into tb_tramites " +
                                  "(id_tramite, nombre, nit, mail, celular, telefono_casa, tipo_seguro, departamento, municipio) " +
                                  "values(tb_tramites_conteo.nextval, '" + txt_NombreCompleto.Text + "', '" + txt_nit.Text + "', '" + txt_Correo.Text + "', '" + txt_Celular.Text + "', '" + txt_TelefonoCasa.Text + "', " + tipoSeguro + ", " + departamento + ", " + municipio + ")";
                cmd.Connection = conexion;
                res            = cmd.ExecuteNonQuery();
                conexion.Close();
                limpiardatos();
                llenarGridDatos();

                // LlenarGridView();

                if (res != 0)
                {
                    mensaje.AlertInfo("Registro Ingresado");
                }
            }
            catch (Exception ex)
            {
                mensaje.AlertError("Erro al guardar los datos" + ex.Message);
            }
        }
 protected void Editar(Int32 Id_usuario)
 {
     try
     {
         DataSet dt = new DataSet();
         conexion = new OracleConnection(cadena);
         conexion.Open();
         adapt = new OracleDataAdapter("select  * from EMPLEADOS where codigo_empleado= " + Id_usuario + "", conexion);
         adapt.Fill(dt, "usuarios");
         if (dt.Tables[1].Rows.Count > 0)
         {
             txt_idUsuario.Text       = dt.Tables[1].Rows[0][0].ToString();
             txt_Nombre.Text          = dt.Tables[1].Rows[0][1].ToString();
             txt_Apaterno.Text        = dt.Tables[1].Rows[0][2].ToString();
             txt_Materno.Text         = dt.Tables[1].Rows[0][3].ToString();
             txt_codigo_empleado.Text = txt_idUsuario.Text;
             //txt_Direccion.Text= dt.Tables[1].Rows[0][4].ToString();
             //txt_telefono.Text= dt.Tables[1].Rows[0][5].ToString();
             //txt_correo.Text=dt.Tables[1].Rows[0][6].ToString();
             //ddl_ocupacion.SelectedValue = dt.Tables[1].Rows[0][7].ToString();
             btn_Guardar.Visible    = false;
             btn_Actualizar.Visible = true;
         }
         else
         {
             mensaje.AlertInfo("No hay registros para mostrar en la tabla ");
         }
     }
     catch (Exception ex)
     {
         mensaje.AlertError("error al seleccionar usuario" + ex.Message);
     }
 }