コード例 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            IncomeAEForm iaeForm = new IncomeAEForm();

            List <IncCategory> incCategories = context.IncCategoryList.ToList();

            iaeForm.cbCategory.DataSource    = incCategories;
            iaeForm.cbCategory.ValueMember   = "IncCategoryId";
            iaeForm.cbCategory.DisplayMember = "Name";

            DialogResult result = iaeForm.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            Income income = new Income();

            income.IncDate     = (DateTime)iaeForm.dtDate.Value;
            income.IncSum      = decimal.Parse(iaeForm.txtIncSum.Text);
            income.IncCategory = (IncCategory)iaeForm.cbCategory.SelectedItem;
            income.Descr       = iaeForm.txtDescr.Text;

            context.IncList.Add(income);
            context.SaveChanges();

            MessageBox.Show("Доход добавлен");
        }
コード例 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ConsumAEForm caeForm = new ConsumAEForm();

            List <ConsCategory> consCategories = context.ConsCategoryList.ToList();

            caeForm.cbCategory.DataSource    = consCategories;
            caeForm.cbCategory.ValueMember   = "ConsCategoryId";
            caeForm.cbCategory.DisplayMember = "Name";

            DialogResult result = caeForm.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            Consum consum = new Consum();

            consum.ConsDate     = (DateTime)caeForm.dtDate.Value;
            consum.ConsSum      = decimal.Parse(caeForm.txtIncSum.Text);
            consum.ConsCategory = (ConsCategory)caeForm.cbCategory.SelectedItem;
            consum.Descr        = caeForm.txtDescr.Text;

            context.ConsList.Add(consum);
            context.SaveChanges();

            MessageBox.Show("Расход добавлен");
        }
コード例 #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            IncCtForm    icaeForm = new IncCtForm();
            DialogResult result   = icaeForm.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            IncCategory incCat = new IncCategory();

            incCat.Name = icaeForm.txtName.Text;
            context.IncCategoryList.Add(incCat);
            context.SaveChanges();
            MessageBox.Show("Новая категория добавлена");
        }