private void ValidCommandHandler(object sender, ExecutedRoutedEventArgs e) { var request = conturiViewSource.View.CurrentItem as Conturi_Requests; //creez client nou Clienti client = new Clienti { Nume = request.Nume, Prenume = request.Prenume, CNP = request.CNP, Adresa = request.Adresa }; context.Clientis.Add(client); context.SaveChanges(); var codClient = (from c in context.Clientis where c.CNP == client.CNP select c.CodClient).FirstOrDefault(); //creez card nou Carduri card = new Carduri { Numar = RandomCreate.Instance.CreateDigitString(16), CVV = RandomCreate.Instance.CreateDigitString(3) }; context.Carduris.Add(card); context.SaveChanges(); var codCardNou = (from c in context.Carduris where c.Numar == card.Numar select c.CodCard).FirstOrDefault(); Conturi cont = new Conturi { IBAN = "RO24RNCB" + RandomCreate.Instance.CreateDigitString(16), Client = codClient, Sold = 0, CodCard = codCardNou }; context.Conturis.Add(cont); context.SaveChanges(); MessageBox.Show("Cont,client si card adaugate cu succes"); //sterg intrarea din Conturi_Requests var query_stergere = (from c in context.Conturi_Requests where c.CodConturiRequest == request.CodConturiRequest select c).FirstOrDefault(); context.Conturi_Requests.Remove(query_stergere); context.SaveChanges(); initializeCollectionView(); initializeBoxes(); }
private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) { try { Angajati newAngajat = new Angajati { Nume = txtNume.Text, CodFunctie = Int32.Parse(txtFunctie.Text), CodSucursala = Int32.Parse(txtSucursala.Text), CodSalariu = Int32.Parse(txtSalariu.Text), Telefon = txtTelefon.Text, DataAngajarii = dataAngajarePicker.SelectedDate.GetValueOrDefault() }; VerifyInput(newAngajat, txtPassword.Password); string pass = txtPassword.Password; byte[] array = Encoding.ASCII.GetBytes(pass); HashAlgorithm sha = SHA256.Create(); byte[] HashedPassword = sha.ComputeHash(array); var context = new BancaEntities(); context.Angajatis.Add(newAngajat); context.SaveChanges(); //vad ce IdAngajat are cel nou creat var idNewAngajat = (context.Angajatis.Where(s => s.Nume.ToString() == txtNume.Text).SingleOrDefault()).CodAngajat; //ii pun in UtilizatoriAngajati, Id-ul si parola asociata var NewUser = new UtilizatoriAngajati() { // password = HashedPassword, angajatID = idNewAngajat, createdOn = dataAngajarePicker.SelectedDate.GetValueOrDefault() }; context.UtilizatoriAngajatis.Add(NewUser); context.SaveChanges(); MessageBox.Show("Ati fost adaugat cu succes\nAveti codul unic: ", idNewAngajat.ToString()); MyWindow = new HomeWindow(newAngajat); Hide(); MyWindow.Show(); } catch (System.Data.Entity.Infrastructure.DbUpdateException sqlEx) { MessageBox.Show(GetCorrectError(sqlEx), "Error!"); OnReload?.Invoke(); } }
private void ValidCommandHandler(object sender, ExecutedRoutedEventArgs e) { var request = tranzactiiViewSource.View.CurrentItem as Tranzactii_Requests; //vad daca exista fonduri suficiente in CodSursa var ContSursa = (from c in context.Conturis where c.CodCont == request.CodContSursa select c).FirstOrDefault(); if (ContSursa.Sold >= request.Suma) { var ContDestinatar = (from c in context.Conturis where c.CodCont == request.CodContDestinatie select c).FirstOrDefault(); ContSursa.Sold -= request.Suma; ContDestinatar.Sold += request.Suma; context.SaveChanges(); Tranzactii tranz = new Tranzactii { Suma = request.Suma, Data = request.Data, CodContSursa = request.CodContSursa, CodContDestinatie = request.CodContDestinatie }; ContSursa.Sold -= request.Suma; ContDestinatar.Sold += request.Suma; context.Tranzactiis.Add(tranz); context.SaveChanges(); MessageBox.Show("Tranzactie aprobata cu succes"); //sterg intrarea din Tranzactii_Request var query_stergere = (from c in context.Tranzactii_Requests where c.CodTranzactieRequest == request.CodTranzactieRequest select c).FirstOrDefault(); context.Tranzactii_Requests.Remove(query_stergere); context.SaveChanges(); initializeCollectionView(); initializeBoxes(); } else { MessageBox.Show("Fonduri Insuficiente!"); } }
private void changeButton_Click(object sender, RoutedEventArgs e) { //modif angajatul cu numele angajatModif.Nume var angajat = context.Angajatis.Where(s => s.Nume == angajatModif.Nume).SingleOrDefault(); angajat.CodFunctie = angajatModif.CodFunctie; angajat.CodSalariu = angajatModif.CodSalariu; context.SaveChanges(); }
private void ValidCommandHandler(object sender, ExecutedRoutedEventArgs e) { var request = crediteViewSource.View.CurrentItem as Credite_Requests; int moneda = (int)(from c in context.Credite_Oferta where c.CodOferta == request.CodOferta select c.CodMoneda).FirstOrDefault(); Credite credit = new Credite { CodClient = (int)request.CodClient, Suma = Int32.Parse(txtSuma.Text), Dobanda = Int32.Parse(txtDobanda.Text), RataLunara = Int32.Parse(txtRata.Text), DataInceperii = request.DataInceperii, DataFinalizarii = request.DataFinalizarii, CodMoneda = moneda }; context.Credites.Add(credit); context.SaveChanges(); MessageBox.Show("Credit adaugat cu succes"); //adaug suma in Cont.sold var query_addSuma = (from c in context.Conturis where c.Client == request.CodClient select c).FirstOrDefault(); query_addSuma.Sold += Int32.Parse(txtSuma.Text); context.SaveChanges(); //sterg intrarea din Crerdit_Requests var query_stergere = (from c in context.Credite_Requests where c.CodCreditRequest == request.CodCreditRequest select c).FirstOrDefault(); context.Credite_Requests.Remove(query_stergere); context.SaveChanges(); initializeCollectionView(); initializeBoxes(); }
private void ValidCommandHandler(object sender, ExecutedRoutedEventArgs e) { //pe baza lui currentItem fac un depozit var request = depoziteViewSource.View.CurrentItem as Depozit_Requests; Depozit depozit = new Depozit { CodClient = request.CodClient, DataDepunerii = request.DataDepunerii, Suma = (int)request.Suma }; context.Depozits.Add(depozit); context.SaveChanges(); MessageBox.Show("Depozit adaugat cu succes"); //adaug suma in Cont.sold var query_addSuma = (from c in context.Conturis where c.Client == request.CodClient select c).FirstOrDefault(); query_addSuma.Sold += request.Suma; context.SaveChanges(); //sterg intrarea din Depozit_Requests var query_stergere = (from d in context.Depozit_Requests where d.CodDepozitRequest == request.CodDepozitRequest select d).FirstOrDefault(); context.Depozit_Requests.Remove(query_stergere); context.SaveChanges(); initializeCollectionView(); initializeBoxes(); }