private void button4_Click(object sender, EventArgs e) { string message = ""; Cerere cerere_de_selectat = (Cerere)dataGridView3.SelectedRows[0].DataBoundItem; var lista_cereri = serviceCentru.GetAllCereri(); Cerere cerere = null; foreach (var i in lista_cereri) { if (i.Id == cerere_de_selectat.Id) { cerere = i; } } if (cerere != null && cerere.Efectuata != true) { var stoc = serviceCentru.GetAllStocuri(); int grupa; Stoc stocBun = null; foreach (var i in stoc) { if (cerere.Grupa == i.Grupa && cerere.RH == i.RH) { stocBun = i; if (cerere.CantitateGlobuleRosii <= i.GlobuleRosii && cerere.CantitatePlasma <= i.Plasma && cerere.CantitateTrombocite <= i.Trombocite && cerere.CantitateSange <= i.TotalSange) { message = "Cantitatea este suficienta pentru a implini cererea"; } else { message = "Ne pare rau dar nu este suficient sange pentru cererea dumneavoastra. \n Notificati donatori sau trimiteti cantitatea de sange din stoc."; } } } if (stocBun != null) { CentruService cService = new CentruService(); CentruTransfuzie ctr = cService.GetCentruTransfuzieByName(username); CerereForm formCerere = new CerereForm(message, cerere, stocBun, ctr, this); formCerere.Show(); loadStocSange(); } } else { MessageBox.Show("Cererea a fost deja completata."); } }
private void buttonAddCentruT_Click(object sender, EventArgs e) { //add centru transfuzie string nume, parola, adresa, judet, localitate; nume = textBoxNume.Text; adresa = textBoxAdresa.Text; parola = textBoxParola.Text; if (comboBoxJudet.SelectedIndex >= 0 && comboBoxLocalitate.SelectedIndex >= 0) { judet = comboBoxJudet.Items[comboBoxJudet.SelectedIndex].ToString(); localitate = comboBoxLocalitate.Items[comboBoxLocalitate.SelectedIndex].ToString(); if (nume.Equals("") || parola.Equals("") || adresa.Equals("")) { MessageBox.Show(this, "Campuri necompletate!", "Error!"); } else { //adaugare CentruTransfuzie centru = new CentruTransfuzie(nume, adresa, localitate, judet, parola); adminService.AddCentru(centru); loadDataGridViewCentreT(); loadComboBoxCentreTranfuzii(); } } else { MessageBox.Show(this, "Campuri necompletate!", "Error!"); } }
public void Delete(CentruTransfuzie centru) { using (UnitOfWork unitOfWork = new UnitOfWork()) { unitOfWork.CentruTransfuzieRepo.Delete(centru); unitOfWork.Save(); } }
public CentruTransfuzie GetCentruTransfuzieByName(String name) { using (UnitOfWork unitOfWork = new UnitOfWork()) { CentruTransfuzie centru = unitOfWork.CentruTransfuzieRepo.GetBy(c => c.Nume.Equals(name)); return(centru); } }
public CerereForm(string message, Cerere cerere, Stoc stoc, CentruTransfuzie centru) { this.message = message; this.cerere = cerere; this.stoc = stoc; this.centru = centru; InitializeComponent(); }
public void AddCentru(CentruTransfuzie centru) { using (UnitOfWork unitOfWork = new UnitOfWork()) { centru.Parola = Util.EncryptPassword(centru.Parola); unitOfWork.CentruTransfuzieRepo.Save(centru); unitOfWork.Save(); } }
public void AddSpital(Spital spital, CentruTransfuzie centru) { using (UnitOfWork unitOfWork = new UnitOfWork()) { CentruTransfuzie centruFromBD = unitOfWork.CentruTransfuzieRepo.GetBy(c => c.Id == centru.Id); spital.CentruTransfuzie = centruFromBD; unitOfWork.SpitalRepo.Save(spital); unitOfWork.Save(); } }
private static void InitializeSpitale(CTContext context) { if (context.Spital.Any()) { return; } CentruTransfuzie c1 = context.CentruTransfuzie.Find(3); CentruTransfuzie c2 = context.CentruTransfuzie.Find(4); Spital sp1 = new Spital(c1, "Str. Salcamilor nr. 98", "Iasi", "Iasi"); Spital sp2 = new Spital(c2, "Str. Alunei nr. 637", "Arad", "Arad"); context.Spital.Add(sp1); context.Spital.Add(sp2); context.SaveChanges(); }
private void buttonDeleteCentru_Click(object sender, EventArgs e) { if (bindingSourceCentre.Position >= 0) { CentruTransfuzie centruTransfuzie = listaCentreT[bindingSourceCentre.Position]; adminService.Delete(centruTransfuzie); MessageBox.Show(this, "Centru de transfuzie a fost sters cu succes!", "Informatie"); loadDataGridViewCentreT(); loadComboBoxCentreTranfuzii(); } else { MessageBox.Show(this, "Va rugam selectati un centru pentru a il sterge!", "Eroare"); } }
public int Login(String username, String password) { CentruTransfuzie ct = GetCentruTransfuzieByName(username); if (ct == null) { return(-1); } if (ct.Parola.Equals(Util.EncryptPassword(password))) { return(ct.Id); } else { return(-1); } }
public void TestAddCentru() { int count = adminService.GetAllCentre().Count; CentruTransfuzie centru = new CentruTransfuzie("CentruTest", "Test", "Test", "Test", "Test"); adminService.AddCentru(centru); Assert.AreEqual(count + 1, adminService.GetAllCentre().Count); try { adminService.AddCentru(centru); } catch (Exception e) { Assert.AreEqual(count + 1, adminService.GetAllCentre().Count); } adminService.Delete(centru); Assert.AreEqual(count, adminService.GetAllCentre().Count); }
public void TestAddSpital() { CentruTransfuzie centru = new CentruTransfuzie("CentruTest", "Test", "Test", "Test", "Test"); adminService.AddCentru(centru); int count = adminService.GetAllSpitale().Count; Spital spital = new Spital("Test", "Test", "Test"); adminService.AddSpital(spital, centru); Assert.AreEqual(count + 1, adminService.GetAllSpitale().Count); try { adminService.AddSpital(spital, centru); } catch (Exception e) { Assert.AreEqual(count + 1, adminService.GetAllSpitale().Count); } adminService.DeleteSpital(spital); adminService.Delete(centru); }
public void testAddPungaSange() { DonatorService srvDon = new DonatorService(); srvDon.RegisterDonator("test", "test", "testNume", "testPrenume", "M", Convert.ToDateTime("04-02-1997"), "testDomiciliu", "testLocalitate", "testJudet", "", "", "", "1935647856", "*****@*****.**"); Donator donator = srvDon.GetDonator("test"); CentruService service = new CentruService(); CentruTransfuzie centru = new CentruTransfuzie("test", "test", "test", "test"); PungaSange punga = new PungaSange(); punga.CantitateSange = 0.5F; punga.CantitatePlasma = 0.275F; punga.CantitateGlobuleRosii = -1; punga.CantitateTrombocite = 150; service.AddPungaSange(punga, donator, centru.Nume); Assert.AreNotEqual(service.GetAllPungiSange().Where(x => x.CantitateGlobuleRosii == -1), null); }
static void InitializeCentre(CTContext context) { if (context.CentruTransfuzie.Any()) { return; } CentruTransfuzie c1 = new CentruTransfuzie("Centru Donare Sânge Cluj", "Piața Mihai Viteazu", "Cluj-Napoca", "Cluj"); CentruTransfuzie c2 = new CentruTransfuzie("Centru Donare Sânge București", "Militari", "Bucuresti", "Ilfov"); CentruTransfuzie c3 = new CentruTransfuzie("CentruTransfuzieIasi", "Moldova", "Iasi", "Iasi", "8287458823facb8ff918dbfabcd22ccb"); //parola=parola CentruTransfuzie c4 = new CentruTransfuzie("CentruTransfuzieArad", "Banat", "Arad", "Arad", "8287458823facb8ff918dbfabcd22ccb"); //parola=parola context.CentruTransfuzie.Add(c1); context.CentruTransfuzie.Add(c2); c1.Parola = "e2a7b5972479f8c59ade36a15e5b6146"; //parola=ParolaCluj c2.Parola = "311e8c89c2e7f24e3ac63265496297a7"; //parola=ParolaBucuresti var centre = new CentruTransfuzie[] { c1, c2, c3, c4 }; foreach (CentruTransfuzie c in centre) { context.CentruTransfuzie.Add(c); } context.SaveChanges(); }
public CerereForm(string message, Cerere cerere, Stoc stoc, CentruTransfuzie centru, FormCentru parentForm) : this(message, cerere, stoc, centru) { this.parentForm = parentForm; }