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 Window_Loaded(object sender, RoutedEventArgs e) { BancaEntities context = new BancaEntities(); Microsoft.Reporting.WinForms.ReportDataSource reportDataSource = new Microsoft.Reporting.WinForms.ReportDataSource(); this._reportviewer.LocalReport.DataSources.Add(reportDataSource); reportDataSource.Name = "DataSet1"; reportDataSource.Value = from c in context.Credites select c; this._reportviewer.LocalReport.ReportPath = "../../AngajatPages/Raport.rdlc"; _reportviewer.RefreshReport(); }