Пример #1
0
        private void LoadTitle()
        {
            try
            {
                var data = _titleRepo.GetAllTitles();
                if (data != null && data.Count > 0)
                {
                    dataGridTitle.DataSource                   = data;
                    dataGridTitle.Columns["Id"].Visible        = false;
                    dataGridTitle.Columns["IsDeleted"].Visible = false;
                }
                else
                {
                    _noItems = true;
                    var dt = new DataTable();
                    dataGridTitle.Columns.Clear();
                    dt.Columns.Add("Message", typeof(string));
                    dt.Rows.Add("No record found");
                    dataGridTitle.DataSource = dt;
                }

                Base.AddLinksToGrid(ref dataGridTitle, new List <string>
                {
                    "Edit",
                    "Delete"
                }, _noItems); //add edit,delete icon
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.Message, "Error occured", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public static void LoadTitles(ref ComboBox dropDown, bool includeAll = false)
        {
            var repo     = new TitleRepo();
            var allItems = repo.GetAllTitles();

            if (includeAll)
            {
                allItems.Insert(0, new PersonTitle
                {
                    Title = "All Titles",
                    Id    = Base.IdForSelectAll
                });
            }
            else
            {
                allItems.Insert(0, new PersonTitle()
                {
                    Title = "Select Title",
                    Id    = Base.IdForSelect
                });
            }

            dropDown.DataSource    = allItems;
            dropDown.DisplayMember = "Title";
            dropDown.ValueMember   = "Id";
            dropDown.SelectedIndex = 0;
        }