Example #1
0
        /// <summary>
        /// Вызов формы для добавления записи с контролем ошибок.
        /// </summary>
        void AddItem()
        {
            var editForm = new DeliveriesEditForm(null);

            if (editForm.ShowDialog() == DialogResult.OK)
            {
                LoadData();
                deliveriesDataGridView.Refresh();
            }
        }
Example #2
0
        /// <summary>
        /// Вызов формы для обновление выбранной записи с контролем ошибок.
        /// </summary>
        void UpdateItem()
        {
            if (deliveriesDataGridView.CurrentCell == null)
            {
                return;
            }

            if (deliveriesDataGridView.SelectedRows.Count > 0)
            {
                using (var marketDBEntities = new MarketDBEntities())
                {
                    int      index        = deliveriesDataGridView.SelectedRows[0].Index;
                    Delivery selectedItem = marketDBEntities.Deliveries.Find(deliveriesDataGridView[0, index].Value);

                    var editForm = new DeliveriesEditForm(selectedItem);
                    if (editForm.ShowDialog() == DialogResult.OK)
                    {
                        LoadData();
                    }
                }
            }
        }