示例#1
0
        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);
        }
示例#2
0
        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);
        }