public static int SelectPerson() { int ID = -1; formSelect select = new formSelect("PERSON:"); var dataArray = from person in Program.GData.dataPerson.getPersons select new { person.ID, person.LastName, person.FirstName, person.Telephone, person.Email, person.Active }; if (dataArray.IsEmpty()) { return(-1); } SortableBindingList <Object> dataSortable = new SortableBindingList <Object>(dataArray.ToArray()); select.grid.DataSource = dataSortable; select.grid.Columns["ID"].Visible = false; select.grid.Columns["Active"].Visible = false; select.grid.Columns["LastName"].Width = 250; select.grid.Columns["FirstName"].Width = 180; select.grid.Columns["Telephone"].Width = 180; select.grid.Columns["Email"].Width = 180; select.ShowDialog(); int rowIndex = select.SelectedRow; if (rowIndex != -1) { ID = int.Parse(select.grid.Rows[rowIndex].Cells["ID"].Value.ToString()); } return(ID); }
public static int SelectCountry() { int ID = -1; formSelect select = new formSelect("COUNTRY:"); var dataArray = from countries in Program.GData.dataLOV.getCountries select new { countries.ID, countries.Country, countries.Code, countries.Active }; if (dataArray.IsEmpty()) { return(-1); } SortableBindingList <Object> dataSortable = new SortableBindingList <Object>(dataArray.ToArray()); select.grid.DataSource = dataSortable; select.grid.Columns["ID"].Visible = false; select.grid.Columns["Active"].Visible = false; select.grid.Columns["Country"].Width = 750; select.grid.Columns["Code"].Width = 100; select.ShowDialog(); int rowIndex = select.SelectedRow; if (rowIndex != -1) { ID = int.Parse(select.grid.Rows[rowIndex].Cells["ID"].Value.ToString()); } return(ID); }
private void SetupGrid() { var dataArray = from organization in Program.GData.dataOrganization.getOrganizations join countries in Program.GData.dataLOV.getCountries on organization.Country equals countries.ID orderby countries.Code select new OrganizationSelect { Selected = false, Code = countries.Code, ID = organization.ID, LegalName = organization.LegalName, Acronym = organization.Acronym, Address = organization.Address, City = organization.City, Country = countries.Country, }; if (dataArray.IsEmpty()) { return; } //List<OrganizationSelect> data = new List<OrganizationSelect>(); //foreach (var item in dataArray) // data.Add(item); SortableBindingList <Object> dataSortable = new SortableBindingList <Object>(dataArray.ToArray()); grid.DataBindings.Clear(); grid.DataSource = dataArray.ToList(); grid.Columns["ID"].Visible = false; grid.Columns["Code"].Width = 80; grid.Columns["LegalName"].Width = 200; grid.Columns["Acronym"].Width = 80; grid.Columns["Address"].Width = 15; grid.Columns["City"].Width = 150; grid.Columns["Country"].Width = 150; }