Exemple #1
0
        /// <summary>
        /// Обработчик нажатия на кнопку меню "Справочники - С/х культуры - Группы с/х культур (сервер)"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ToolStripMenuItem_Sprav_CropGroups_Remote_Click(object sender, EventArgs e)
        {
            WebApiConnector webApiConnector = new WebApiConnector();

            _cropGroupRepository = new CropGroupRepositoryWebApi(webApiConnector);

            dataGridViewMain.SelectionMode =
                DataGridViewSelectionMode.FullRowSelect;
            dataGridViewMain.MultiSelect = false;
            try
            {
                var list = await _cropGroupRepository.GetCropGroupsAsync();

                BindingList <CropGroup> bindingListCropGroups = new BindingList <CropGroup>(list);
                dataGridViewMain.DataSource = bindingListCropGroups;
            }
            catch (Exception exc)
            {
                richTextBoxLog.Text += $"{exc.Message}\n";
            }


            dataGridViewMain.Columns[0].HeaderText = "УИД";
            dataGridViewMain.Columns[1].HeaderText = "Наименование группы с/х культур";
            dataGridViewMain.Columns[1].Width      = 400;
        }
Exemple #2
0
        /// <summary>
        /// Обработчик нажатия на кнопку меню "Справочники - С/х культуры - Группы с/х культур"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ToolStripMenuItem_Sprav_CropGroups_Click(object sender, EventArgs e)
        {
            _cropGroupRepository = new CropGroupRepositorySqlite();

            dataGridViewMain.SelectionMode =
                DataGridViewSelectionMode.FullRowSelect;
            dataGridViewMain.MultiSelect = false;

            BindingList <CropGroup> bindingListCropGroups = new BindingList <CropGroup>(await _cropGroupRepository.GetCropGroupsAsync() /*CropGroups.ToList()*/);

            dataGridViewMain.DataSource = bindingListCropGroups;

            dataGridViewMain.Columns[0].HeaderText = "УИД";
            dataGridViewMain.Columns[1].HeaderText = "Наименование группы с/х культур";
            dataGridViewMain.Columns[1].Width      = 400;
        }