Ejemplo n.º 1
0
        private void ConditionControlDeleted(object sender, EventArgs e)
        {
            CategoryRecordControl control = (CategoryRecordControl)sender;
            CategoryRecord        cond    = control.CategoryRecord;

            if (cond.ItemId > 0 && MessageBox.Show("Do you really want to delete Category record?", "Deleting confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                //если информация о состоянии сохранена в БД
                //и получен положительный ответ на ее удаление
                try
                {
                    GlobalObjects.NewKeeper.Delete(cond);
                }
                catch (Exception ex)
                {
                    Program.Provider.Logger.Log("Error while removing data", ex);
                }

                flowLayoutPanelMain.Controls.Remove(control);
                control.Deleted -= ConditionControlDeleted;
                control.Dispose();
            }
            else if (cond.ItemId <= 0)
            {
                flowLayoutPanelMain.Controls.Remove(control);
                control.Deleted -= ConditionControlDeleted;
                control.Dispose();
            }
        }
Ejemplo n.º 2
0
        private void LinkLabelAddNewLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            CategoryRecordControl performance =
                new CategoryRecordControl(new CategoryRecord {
                Parent = Employee
            });

            performance.Deleted += ConditionControlDeleted;
            if (flowLayoutPanelMain.Controls.Count > 1)
            {
                performance.ShowHeaders = false;
            }
            flowLayoutPanelMain.Controls.Remove(panelAdd);
            flowLayoutPanelMain.Controls.Add(performance);
            flowLayoutPanelMain.Controls.Add(panelAdd);
            performance.Focus();
        }
Ejemplo n.º 3
0
        /*
         * Реализация
         */

        #region private void BuildControls()
        /// <summary>
        /// Строит нужные контролы
        /// </summary>
        private void BuildControls()
        {
            // Освобождаем старые контролы
            flowLayoutPanelMain.Controls.Clear();

            if (Employee != null && Employee.CategoriesRecords != null)
            {
                for (int i = 0; i < Employee.CategoriesRecords.Count; i++)
                {
                    // Добавляем контрол для ввода данных по маслу
                    CategoryRecordControl c = new CategoryRecordControl(Employee.CategoriesRecords[i]);
                    c.Deleted += ConditionControlDeleted;
                    if (i > 0)
                    {
                        c.ShowHeaders = false;
                    }
                    flowLayoutPanelMain.Controls.Add(c);
                }
            }

            flowLayoutPanelMain.Controls.Add(panelAdd);
        }