コード例 #1
0
ファイル: NaujaPreke.cs プロジェクト: nemiux/TOP-3
 private void button2_Click(object sender, EventArgs e)
 {
     cancel   = false;
     prekesNr = context.Preke.Where(x => x.Pavadinimas == pavadinimas).Select(y => y.prekesNr).FirstOrDefault();
     //MessageBox.Show("Prekes Nr: " + prekesNr.ToString());
     pavadinimas = textBox1.Text;
     kategorija  = context.Kategorija.Where(x => comboBox1.Text == x.Vardas).Select(y => y.KategorijosID).FirstOrDefault();
     if (kategorija == 0)
     {
         MessageBox.Show("Kategorijos \"" + comboBox1.Text + "\" nera. Kuriama...");
         kategorija = sukurtiKategorija();
     }
     kiekis = Int32.Parse(textBox3.Text);
     kaina  = Decimal.Parse(textBox4.Text);
     // INSERT
     if (update)
     {
         Preke keiciama = context.Preke.FirstOrDefault(x => x.prekesNr == prekesNr);
         keiciama.Pavadinimas = pavadinimas;
         keiciama.Kaina       = kaina;
         keiciama.Kiekis      = kiekis;
         Kategorija k = context.Kategorija.FirstOrDefault(x => x.KategorijosID == kategorija);
         k.Preke.Add(keiciama);
         context.SaveChanges();
         //MessageBox.Show("Keiciam " + keiciama.prekesNr + " " + keiciama.Pavadinimas +
         //    "\nJos kategorija: " + keiciama.Kategorija.Select(x=>x.KategorijosID).FirstOrDefault().ToString());
     }
     //---
     Close();
 }
コード例 #2
0
ファイル: PrekiuValdymas.cs プロジェクト: nemiux/TOP-3
        private void button4_Click(object sender, EventArgs e)
        {
            string trint   = listView1.SelectedItems[0].SubItems[0].Text;
            Preke  trinama = (from x in context.Preke where x.Pavadinimas == trint select x).First();

            context.Preke.Remove(trinama);
            context.SaveChanges();
            updateTable();
        }
コード例 #3
0
ファイル: Perkama.cs プロジェクト: nemiux/TOP-3
        private void button2_Click(object sender, EventArgs e)
        {
            PerkamaP pp = new PerkamaP();

            pp.ShowDialog();
            if (!pp.closing)
            {
                Preke        preke = context.Preke.First(x => pp.sel == x.prekesNr);
                Transakcijos tr    = context.Transakcijos.First(x => tid == x.transakcijosID);
                context.PerkamaPreke.Add(new PerkamaPreke()
                {
                    PerkamasKiekis = pp.perkama, prekesNr = pp.sel, transakcijosID = tid, Preke = preke, Transakcijos = tr
                });
                context.SaveChanges();
                updateTable();
            }
        }