private void cargarComboEmpresa()
 {
     try
     {
         ServiceProcess_Empresa.Process_EmpresaSoapClient auxServiceEmpresa = new ServiceProcess_Empresa.Process_EmpresaSoapClient();
         auxServiceEmpresa.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
         auxServiceEmpresa.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
         DataSet   ds = new DataSet();
         DataTable dt = new DataTable();
         ds = auxServiceEmpresa.TraerTodasEmpresas_Escritorio();
         dt = ds.Tables[0];
         DataRow fila = dt.NewRow();
         fila["RUT_EMPRESA"] = 0;
         fila["NOMBRE"]      = "SELECCIONE EMPRESA";
         fila["GIRO"]        = " ";
         fila["DIRECCION"]   = " ";
         fila["ESTADO"]      = 0;
         fila["ID_COMUNA"]   = 0;
         dt.Rows.InsertAt(fila, 0);
         cbEmpresa.DropDownStyle = ComboBoxStyle.DropDownList;
         cbEmpresa.DataSource    = dt;
         cbEmpresa.DisplayMember = "NOMBRE";
         cbEmpresa.ValueMember   = "RUT_EMPRESA";
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al cargar Informacion cargarComboEmpresa, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        //Metodo Carga GridView Usuario Empresa
        private void cargarDataGridViewEmpresa()
        {
            try
            {
                ServiceProcess_Usuario.Process_UsuarioSoapClient auxServiceUsuario = new ServiceProcess_Usuario.Process_UsuarioSoapClient();
                auxServiceUsuario.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
                auxServiceUsuario.ClientCredentials.UserName.Password = Cuenta.Clave_iis;

                ServiceProcess_Empresa.Process_EmpresaSoapClient auxServiceEmpresa = new ServiceProcess_Empresa.Process_EmpresaSoapClient();
                auxServiceEmpresa.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
                auxServiceEmpresa.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
                ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa();

                //capturar dataset
                DataSet ds = auxServiceEmpresa.TraerTodasEmpresas_Escritorio();
                //Capturar Tabla
                DataTable dt = ds.Tables[0];
                //contar cantidad de empresas
                int _cantidad_empresas = dt.Rows.Count;
                //crear array bidimencional
                string[,] ListaEmpresas = new string[_cantidad_empresas, 2];
                //Recorrer data table
                int _fila = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //Capturar datos de la fila recorridad en objeto empresa
                    auxEmpresa.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"];
                    auxEmpresa.Nombre      = (String)dt.Rows[i]["Nombre"];
                    auxEmpresa.Giro        = (String)dt.Rows[i]["Giro"];
                    auxEmpresa.Direccion   = (String)dt.Rows[i]["Direccion"];
                    auxEmpresa.Estado      = Convert.ToInt32(dt.Rows[i]["Estado"]);
                    auxEmpresa.Id_comuna   = Convert.ToInt32(dt.Rows[i]["Id_comuna"]);

                    //CAPTURAR DATASET
                    DataSet dsU = auxServiceUsuario.TraerUsuarioPorRutPorEmpresaSinEntidad_Escritorio(_rut_usuario, auxEmpresa.Rut_empresa);
                    if ((dsU.Tables.Count != 0) && (dsU.Tables[0].Rows.Count > 0))
                    {
                        //no carga nada al gridview por que ya es usuario  de la empresa
                    }
                    else
                    {
                        //cargar array con datos de fila
                        ListaEmpresas[_fila, 0] = auxEmpresa.Rut_empresa;
                        ListaEmpresas[_fila, 1] = auxEmpresa.Nombre;
                        //agregar lista a gridview
                        dgvEmpresas.Rows.Add(ListaEmpresas[_fila, 0], ListaEmpresas[_fila, 1]);
                        _fila++;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error en metodo cargarDataGridViewUsuario, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
 //Metodo Carga GridView
 public void cargarDataGridViewPpal()
 {
     try
     {
         //instansear web service con seguridad
         ServiceProcess_Empresa.Process_EmpresaSoapClient auxServiceEmpresa = new ServiceProcess_Empresa.Process_EmpresaSoapClient();
         auxServiceEmpresa.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
         auxServiceEmpresa.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
         ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa();
         //capturar dataset
         DataSet ds = auxServiceEmpresa.TraerTodasEmpresas_Escritorio();
         //Capturar Tabla
         DataTable dt = ds.Tables[0];
         //contar cantidad de empresas
         int _cantidad_empresas = dt.Rows.Count;
         //crear array bidimencional
         string[,] ListaEmpresa = new string[_cantidad_empresas, 2];
         //Recorrer data table
         int _fila = 0;
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             //Capturar datos de la fila recorridad en objeto empresa
             auxEmpresa.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"];
             auxEmpresa.Nombre      = (String)dt.Rows[i]["Nombre"];
             auxEmpresa.Giro        = (String)dt.Rows[i]["Giro"];
             auxEmpresa.Direccion   = (String)dt.Rows[i]["Direccion"];
             auxEmpresa.Estado      = Convert.ToInt32(dt.Rows[i]["Estado"]);
             auxEmpresa.Id_comuna   = Convert.ToInt32(dt.Rows[i]["Id_comuna"]);
             if (auxEmpresa.Estado == 1) // si la empresa esta activa se carga en la lista
             {
                 // cargar array con datos de fila
                 ListaEmpresa[_fila, 0] = auxEmpresa.Rut_empresa;
                 ListaEmpresa[_fila, 1] = auxEmpresa.Nombre;
                 //agregar lista a gridview
                 dgvEmpresas.Rows.Add(ListaEmpresa[_fila, 0], ListaEmpresa[_fila, 1]);
                 _fila++;
             }
         }
         pbSeleccion.Visible = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error en metodo cargarDataGridViewPpal, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }