Ejemplo n.º 1
0
        public Form2()
        {
            InitializeComponent();
            db = new PhoneContext();

            db.Realizations.Load();

            dataGridView1.DataSource = db.Realizations.Local.ToBindingList();
        }
Ejemplo n.º 2
0
        public Form1()
        {
            InitializeComponent();


            db = new PhoneContext();
            db.Phones.Load();
            db.Realizations.Load();
            dataGridView1.DataSource = db.Phones.Local.ToBindingList();

            comboBox1.DataSource    = db.Phones.Local.ToBindingList();
            comboBox1.DisplayMember = "Model";
            comboBox1.ValueMember   = "Id";
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (PhoneContext db = new PhoneContext())
            {
                var ph = db.Phones.Find(comboBox1.SelectedValue);
                if (ph.Count <= 0 || ph.Count < (int)numericUpDown1.Value)
                {
                    MessageBox.Show("Товар отсутствует на складе", "Информация", MessageBoxButtons.OK);
                    return;
                }

                db.Realizations.Add(Realization.CreateRealization(textBox1.Text, (int)numericUpDown1.Value, DateTime.Now, (int)comboBox1.SelectedValue));

                ph.Count -= (int)numericUpDown1.Value;
                db.SaveChanges();
            }
            dataGridView1.Refresh();
            MessageBox.Show("Покупка оформлена успешно", "Информация", MessageBoxButtons.OK);
        }