Beispiel #1
0
 private void unitOfMeasureAddButtonClick(object sender, EventArgs e)
 {
     using (var db = new Model.BudgetModel())
     {
         var unitOfMeasure = new UnitOfMeasure();
         AddItemForm addItemForm = new AddItemForm("Введите полное название");
         if (addItemForm.ShowDialog(this) == DialogResult.OK)
             if (string.IsNullOrWhiteSpace(addItemForm.Value)
                 || addItemForm.Value == "Введите полное название")
             {
                 MessageBox.Show("Введите название");
                 return;
             }
             else
             {
                 unitOfMeasure.Name = addItemForm.Value;
                 addItemForm = new AddItemForm("Введите сокращенное название");
                 if (addItemForm.ShowDialog(this) == DialogResult.OK)
                     if (string.IsNullOrWhiteSpace(addItemForm.Value)
                         || addItemForm.Value == "Введите сокращенное название")
                     {
                         MessageBox.Show("Введите название");
                         return;
                     }
                     else
                     {
                         unitOfMeasure.ShortName = addItemForm.Value;
                         db.UnitOfMeasures.Add(unitOfMeasure);
                         db.SaveChanges();
                     }
             }
         UpdateListBox();
     }
 }
Beispiel #2
0
        public AddGoodsItemForm(ListBoxItem category, UnitOfMeasure unitOfMeasure, string value)
        {
            InitializeComponent();
            FillForm();
            addGoodsCategoryComboBox.SelectedIndex = addGoodsCategoryComboBox.FindString(category.Name);
            addGoodsUnitOfMeasureComboBox.SelectedIndex = addGoodsUnitOfMeasureComboBox.FindString(unitOfMeasure.Name);
            addGoodsItemTextBox.Text = value;

        }