protected void btngrabar_Click(object sender, EventArgs e)
        {
            //  DSDIndestructible.SOAP.Service1 service = new DSDIndestructible.SOAP.Service1();
            ServiceReference1.Service1Client service = new ServiceReference1.Service1Client();
            SolicitudAfiliacion be = new SolicitudAfiliacion();

            be.SRUC = txtruc.Text;
            be.SRAZO_SOCI = txtrazonsocial.Text;
            be.SNOMB_COME = txtnombrecomercial.Text;
            be.SDIRE_COME = txtdirecomercial.Text;
            be.SDIRE_ADMI = txtdirecomercial.Text;
            be.SREPR_LEGA_1 = txtrepresenante1.Text;
            be.SREPR_LEGA_2 = txtrepresentante2.Text;
            be.SPERS_CONT = txtpersonalcontacto.Text;
            be.SNUME_CUEN = txtcuentabancaria.Text;
            be.STIPO_CUEN = txtipocuenta.Text;
            be.SMONE = txtmoneda.Text;
            be.SENTI_FINA = txtentidadfinanciera.Text;
            be.STIPO_AFIL = txttipoafiliacion.Text;
            be.STIPO_PROD = txttipoproducto.Text;
            be.STIPO_COMU = txttipocomunicacion.Text;
            be.SFECH_INST = txtfechainstalacion.Text;

            service.GetData(be);

            lblmensaje.Text = "Se registro la solicitud : ID ";
            lblmensaje.Visible = true;
            LimpiarCampos();
            //txtNombre.Text = service.Obtener_Reniec(Convert.ToInt32(txtBuscar_DNI.Text)).Nombre;
            //txtPaterno.Text = service.Obtener_Reniec(Convert.ToInt32(txtBuscar_DNI.Text.ToString())).Ape_paterno;
            //txtMaterno.Text = service.Obtener_Reniec(Convert.ToInt32(txtBuscar_DNI.Text.ToString())).Ape_materno;
            //txtSexo.Text = service.Obtener_Reniec(Convert.ToInt32(txtBuscar_DNI.Text.ToString())).Sexo;
            //txtEstadoCivil.Text = service.Obtener_Reniec(Convert.ToInt32(txtBuscar_DNI.Text.ToString())).Est_civil1;
            //txtNacionalidad.Text = service.Obtener_Reniec(Convert.ToInt32(txtBuscar_DNI.Text.ToString())).Nacionalidad;
            //txtDepartamento.Text = service.Obtener_Reniec(Convert.ToInt32(txtBuscar_DNI.Text.ToString())).Departamento1;
            //txtProvincia.Text = service.Obtener_Reniec(Convert.ToInt32(txtBuscar_DNI.Text.ToString())).Provincia;
            //txtDistrito.Text = service.Obtener_Reniec(Convert.ToInt32(txtBuscar_DNI.Text.ToString())).Distrito;
            //txtDomicilio.Text = service.Obtener_Reniec(Convert.ToInt32(txtBuscar_DNI.Text.ToString())).Domicilio1;
            //imgFoto.ImageUrl = "~/FOTOS/" + service.Obtener_Reniec(Convert.ToInt32(txtBuscar_DNI.Text.ToString())).Foto;
        }
        public SolicitudAfiliacion GetDataUsingDataContract(string ruc)
        {
            SqlConnection objConnection = new SqlConnection();
            DataSet ObjDataset = new DataSet();
            SqlDataAdapter objAdapater = new SqlDataAdapter();
            SqlCommand objCommand = new SqlCommand
            ("Select SolicitudAfiliacionID,RUC,RazonSocial,NombreComercial,DireccionComercial,DireccionAdministrativa,RepresentanteLegal1,RepresentanteLegal2,PersonaContactoPuntoVenta,NumerocuentaBancaria,TipoCuenta,TipoMoneda,EntidadFinanciera,TipoAfiliacion,TipoProduccto,TipoComunicacion,FechaInstalacion from SolicitudAfiliacion where RUC='" + ruc.ToString() + "'");
            objConnection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["CnnSQL"].ToString();
            objConnection.Open();
            objCommand.Connection = objConnection;
            objAdapater.SelectCommand = objCommand;
            objAdapater.Fill(ObjDataset);
            SolicitudAfiliacion _Be= new SolicitudAfiliacion();
            if (ObjDataset.Tables.Count > 0)
            {

                _Be.SRUC        = ObjDataset.Tables[0].Rows[0][1].ToString();
                _Be.SRAZO_SOCI  = ObjDataset.Tables[0].Rows[0][2].ToString();
                _Be.SNOMB_COME  = ObjDataset.Tables[0].Rows[0][3].ToString();
                _Be.SDIRE_COME  = ObjDataset.Tables[0].Rows[0][4].ToString();
                _Be.SDIRE_ADMI  = ObjDataset.Tables[0].Rows[0][5].ToString();
                _Be.SREPR_LEGA_1= ObjDataset.Tables[0].Rows[0][6].ToString();
                _Be.SREPR_LEGA_2= ObjDataset.Tables[0].Rows[0][7].ToString();
                _Be.SPERS_CONT  = ObjDataset.Tables[0].Rows[0][8].ToString();
                _Be.SNUME_CUEN  = ObjDataset.Tables[0].Rows[0][9].ToString();
                _Be.STIPO_CUEN  = ObjDataset.Tables[0].Rows[0][10].ToString();
                _Be.SMONE       = ObjDataset.Tables[0].Rows[0][11].ToString();
                _Be.SENTI_FINA  = ObjDataset.Tables[0].Rows[0][12].ToString();
                _Be.STIPO_AFIL  = ObjDataset.Tables[0].Rows[0][13].ToString();
                _Be.STIPO_PROD  = ObjDataset.Tables[0].Rows[0][14].ToString();
                _Be.STIPO_COMU  = ObjDataset.Tables[0].Rows[0][15].ToString();
                _Be.SFECH_INST  = ObjDataset.Tables[0].Rows[0][16].ToString();

            }
            objConnection.Close();

            return _Be;
        }
        public string GetData(SolicitudAfiliacion solicitud)
        {
            SqlConnection objConnection = new SqlConnection();
            DataSet ObjDataset = new DataSet();
            SqlDataAdapter objAdapater = new SqlDataAdapter();
            SqlCommand objCommand = new SqlCommand("sp_SolicitudAfiliacion_I01", objConnection);

            objConnection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["CnnSQL"].ToString();
            objConnection.Open();
            SqlTransaction trans = objConnection.BeginTransaction(IsolationLevel.ReadCommitted);
            objCommand.Connection = objConnection;

            SolicitudAfiliacion _Be = (SolicitudAfiliacion)solicitud;//pasarle la entidad
            objCommand.Transaction = trans;
            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.Parameters.Add("@ruc", SqlDbType.VarChar).Value = _Be.SRUC;
            objCommand.Parameters.Add("@razonsocial", SqlDbType.VarChar).Value = _Be.SRAZO_SOCI;
            objCommand.Parameters.Add("@nombrcomercial", SqlDbType.VarChar).Value = _Be.SNOMB_COME;
            objCommand.Parameters.Add("@direccioncomercial", SqlDbType.VarChar).Value = _Be.SDIRE_COME;
            objCommand.Parameters.Add("@direccionadmin", SqlDbType.VarChar).Value = _Be.SDIRE_ADMI;
            objCommand.Parameters.Add("@reprelegal1", SqlDbType.VarChar).Value = _Be.SREPR_LEGA_1;
            objCommand.Parameters.Add("@reprelegal2", SqlDbType.VarChar).Value = _Be.SREPR_LEGA_2;
            objCommand.Parameters.Add("@personcontactoventa", SqlDbType.VarChar).Value = _Be.SPERS_CONT;
            objCommand.Parameters.Add("@numerocuentabancaria", SqlDbType.VarChar).Value = _Be.SNUME_CUEN;
            objCommand.Parameters.Add("@tipocuenta", SqlDbType.VarChar).Value = _Be.STIPO_CUEN;
            objCommand.Parameters.Add("@tipomoneda", SqlDbType.VarChar).Value = _Be.SMONE;
            objCommand.Parameters.Add("@entidadfinan", SqlDbType.VarChar).Value = _Be.SENTI_FINA;
            objCommand.Parameters.Add("@tipoafiliacion", SqlDbType.VarChar).Value = _Be.STIPO_AFIL;
            objCommand.Parameters.Add("@tipoproducto", SqlDbType.VarChar).Value = _Be.STIPO_PROD;
            objCommand.Parameters.Add("@tipocomunicacion", SqlDbType.VarChar).Value = _Be.STIPO_COMU;
            objCommand.Parameters.Add("@fechainstal", SqlDbType.VarChar).Value = _Be.SFECH_INST;
            objCommand.ExecuteNonQuery();
            trans.Commit();
            objConnection.Close();
            return "salio";
        }