private static void AdaugareVanzatori() { using (var ctx = new LicitatiiContext()) { try { ctx.Utilizatori.Add( new Vanzator() { Adresa = "Brasov, Brasov, Paraului nr. 5", Nume = "Draghia", Prenume = "Alin", Username = "******", Password = "******" } ); ctx.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.ToString()); } } }
private static void AdaugareCumparatori() { using (var ctx = new LicitatiiContext()) { ctx.Utilizatori.Add( new Cumparator() { Nume = "Popa", Prenume = "Vasile", Username = "******", Password = "******", CNP = "1xxxxxxxxxxxx", Telefon = "07********" } ); ctx.Utilizatori.Add( new Cumparator() { Nume = "Popescu", Prenume = "Ana-Maria", Username = "******", Password = "******", CNP = "2xxxxxxxxxxxx", Telefon = "07********" } ); ctx.SaveChanges(); } }
private void btnLiciteaza_Click(object sender, EventArgs e) { dynamic produsCurent = produsBindingSource.Current; using (var ctx = new LicitatiiContext()) { int produsId = produsCurent.Id; var produsDb = ctx.Produse .Where(p => p.Id == produsId) .FirstOrDefault(); Decimal pretCurent; Decimal.TryParse(tbPretLicitat.Text, out pretCurent); if (produsDb.PretLicitat >= pretCurent || produsDb.PretDeInceput >= pretCurent) { errorProvider1.SetError(tbPretLicitat.TextBox, "Pretul licitat trebuie sa fie mai mare decat pretul curent."); } else { errorProvider1.SetError(tbPretLicitat.TextBox, null); produsDb.CumparatorId = Program.Cumparator.Id; produsDb.PretLicitat = pretCurent; ctx.SaveChanges(); } } RefreshData(); }