Exemple #1
0
        private void cargarDataGridViewUnidad()
        {
            try
            {
                dgvUnidad.Rows.Clear();
                dgvUnidad.Refresh();
                //instansear web service con seguridad

                ServiceProcess_Unidad.Process_UnidadSoapClient auxServiceUnidad = new ServiceProcess_Unidad.Process_UnidadSoapClient();
                auxServiceUnidad.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
                auxServiceUnidad.ClientCredentials.UserName.Password = Cuenta.Clave_iis;

                ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa();
                ServiceProcess_Unidad.Unidad   auxUnidad  = new ServiceProcess_Unidad.Unidad();

                //capturar dataset
                DataSet ds = auxServiceUnidad.TraerUnidadPorEmpresaSinEntidad_Escritorio(_rut_empresa);
                if ((ds.Tables.Count != 0) && (ds.Tables[0].Rows.Count > 0))
                {
                    //Capturar Tabla
                    DataTable dt = ds.Tables[0];
                    //contar cantidad de empresas
                    int _cantidad_unidades = dt.Rows.Count;
                    //crear array bidimencional
                    string[,] ListaUnidades = new string[_cantidad_unidades, 2];
                    //Recorrer data table
                    int _fila = 0;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        //Capturar datos de la fila recorridad en objeto Unidad
                        int    id_unidad     = Convert.ToInt32(dt.Rows[i]["Id_unidad"]);
                        string nombre_unidad = (String)dt.Rows[i]["Nombre"];
                        //cargar array con datos de fila
                        ListaUnidades[_fila, 0] = id_unidad.ToString();
                        ListaUnidades[_fila, 1] = nombre_unidad;

                        //agregar lista a gridview
                        dgvUnidad.Rows.Add(ListaUnidades[_fila, 0], ListaUnidades[_fila, 1]);
                        _fila++;
                    }
                }
                else
                {
                    MessageBox.Show("La Empresa Seleccionada No tienes Unidades creadas .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    pbSeleccionUnidad.Visible = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error en metodo cargarDataGridViewEquipo, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void cargarComboUnidad()
 {
     try
     {
         ServiceProcess_Unidad.Process_UnidadSoapClient auxServiceUnidad = new ServiceProcess_Unidad.Process_UnidadSoapClient();
         auxServiceUnidad.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
         auxServiceUnidad.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
         pbSeleccionEmpresa.Visible = true;
         DataSet   ds = new DataSet();
         DataTable dt = new DataTable();
         ds = auxServiceUnidad.TraerUnidadPorEmpresaSinEntidad_Escritorio(_rut_empresa);
         if ((ds.Tables.Count != 0) && (ds.Tables[0].Rows.Count > 0))
         {
             dt = ds.Tables[0];
             DataRow fila = dt.NewRow();
             fila["ID_UNIDAD"]   = 0;
             fila["NOMBRE"]      = "SELECCIONE UNIDAD";
             fila["DESCRIPCION"] = " ";
             fila["ESTADO"]      = 0;
             fila["RUT_EMPRESA"] = 0;
             dt.Rows.InsertAt(fila, 0);
             cbUnidad.DropDownStyle = ComboBoxStyle.DropDownList;
             cbUnidad.DataSource    = dt;
             cbUnidad.DisplayMember = "NOMBRE";
             cbUnidad.ValueMember   = "ID_UNIDAD";
         }
         else
         {
             MessageBox.Show("Empresa Seleccionada No Tiene Unidades Registradas.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al cargar Informacion cargarComboUnidad, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }