//int id,string user, string pass public IEnumerable <Angajat> findAll() { IDbConnection con = DBUtils.getConnection(); IList <Angajat> angajati = new List <Angajat>(); using (var comm = con.CreateCommand()) { comm.CommandText = "select id, username, pass from Angajati"; using (var dataR = comm.ExecuteReader()) { while (dataR.Read()) { int id = dataR.GetInt32(0); String username = dataR.GetString(1); String pass = dataR.GetString(2); Angajat angajat = new Angajat(id, username, pass); angajati.Add(angajat); } } } return(angajati); }
public Angajat findOne(int id) { log.InfoFormat("Entering findOne with value {0}", id); IDbConnection con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "select id, username, pass from Angajati where id=@id"; IDbDataParameter paramId = comm.CreateParameter(); paramId.ParameterName = "@id"; paramId.Value = id; comm.Parameters.Add(paramId); using (var dataR = comm.ExecuteReader()) { if (dataR.Read()) { int idV = dataR.GetInt32(0); String username = dataR.GetString(1); String pass = dataR.GetString(2); Angajat angajat = new Angajat(id, username, pass); log.InfoFormat("Exiting findOne with value {0}", angajat); return(angajat); } } } log.InfoFormat("Exiting findOne with value {0}", null); return(null); }
public Angajat isAngajat(string user, string password) { IDbConnection con = DBUtils.getConnection(props); using (var comm = con.CreateCommand()) { comm.CommandText = "select * from Angajati where User=@user and Password=@password"; IDbDataParameter paramId = comm.CreateParameter(); paramId.ParameterName = "@user"; paramId.Value = user; comm.Parameters.Add(paramId); IDbDataParameter paramPassword = comm.CreateParameter(); paramPassword.ParameterName = "@password"; paramPassword.Value = password; comm.Parameters.Add(paramPassword); using (var dataR = comm.ExecuteReader()) { if (dataR.Read()) { String User2 = dataR.GetString(0); String Password2 = dataR.GetString(1); Angajat a = new Angajat(User2, Password2); //log.InfoFormat("Exiting findOne with value {0}", c); return(a); } } } //log.InfoFormat("Exiting findOne with value {0}", null); return(null); }
public void save(Angajat entity) { var con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "insert into Angajati values (@id, @username, @pass)"; var paramId = comm.CreateParameter(); paramId.ParameterName = "@id"; paramId.Value = entity.Id; comm.Parameters.Add(paramId); var paramUsername = comm.CreateParameter(); paramUsername.ParameterName = "@username"; paramUsername.Value = entity.Username; comm.Parameters.Add(paramUsername); var paramPass = comm.CreateParameter(); paramPass.ParameterName = "@pass"; paramPass.Value = entity.Pass; comm.Parameters.Add(paramPass); var result = comm.ExecuteNonQuery(); if (result == 0) { throw new RepositoryException("No angajat added !"); } } }
public async Task <IActionResult> PutAngajat(long id, Angajat angajat) { if (id != angajat.Id_Angajat) { return(BadRequest()); } _context.Entry(angajat).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AngajatExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Angajat> > PostAngajat(Angajat angajat) { _context.Angajati.Add(angajat); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAngajat", new { id = angajat.Id_Angajat }, angajat)); }
public void logout(Angajat angajat, ITeledonObserver client) { /*ITeledonObserver localClient = loggedClients[angajat.username]; * if (localClient == null) * throw new TeledonException("User " + angajat.username + " is not logged in."); * loggedClients.Remove(angajat.username);*/ }
private void CreateEmployeeReport(ListView list, Angajat employee) { List <Report> items = new List <Report>(); var getTasks = ctx.Tasks.Where(x => x.IdAngajat == employee.Id).OrderBy(x => x.Status).Select(x => x.Id); foreach (int id in getTasks) { var t = ctx.Tasks.Find(id); var st = ctx.Tasks.Include("StatusTask").ToList(); TimeSpan d = TimeSpan.Zero; if (t.DataFinalizarii != null) { d = (TimeSpan)(t.DataFinalizarii - t.DataCrearii); } items.Add(new Report() { Denumire = t.Denumire, Descriere = t.Descriere, DataCrearii = t.DataCrearii, DataFinalizarii = t.DataFinalizarii, Deadline = t.Deadline, Status = st.Where(x => x.Id == t.Id).Select(x => x.StatusTask.DenumireSt).First().ToString(), Durata = (t.DataFinalizarii != null) ? (Convert.ToInt32(d.TotalDays) < 1) ? Convert.ToInt32(d.TotalHours) + " hours" : Convert.ToInt32(d.TotalDays) + " days" : null }); } list.ItemsSource = items; }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Angajat = await _context.Angajat .Include(b => b.Departament) .Include(b => b.Job) .Include(b => b.LimbiStraineVorbite).ThenInclude(b => b.LimbaStraina) .AsNoTracking() .FirstOrDefaultAsync(m => m.ID == id); if (Angajat == null) { return(NotFound()); } PopuleazaAtribuireLimbaStraina(_context, Angajat); ViewData["DepartamentID"] = new SelectList(_context.Set <Departament>(), "ID", "NumeDepartament"); ViewData["JobID"] = new SelectList(_context.Set <Job>(), "ID", "TipJob"); return(Page()); }
public async Task <IActionResult> Edit(long id, [Bind("Id,Marca,Nume,Salariu,IdFunctie,IdDepartament")] Angajat angajat) { if (id != angajat.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(angajat); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AngajatExists(angajat.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdDepartament"] = new SelectList(_context.Departamente, "Id", "Nume", angajat.IdDepartament); ViewData["IdFunctie"] = new SelectList(_context.Functii, "Id", "Nume", angajat.IdFunctie); //PopulateFunctiiDropDownList(angajat.IdFunctie); //PopulateDepartamenteDropDownList(angajat.IdDepartament); return(View(angajat)); }
public void Login(String username, String parola) { Angajat angajat = new Angajat(1, "a", 20, username, parola); server.Login(angajat, this); angajatCurent = angajat; }
public Angajat Save(Angajat elem) { log.Info("Se incearca adaugarea"); var con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "insert into Angajati (nume,varsta,username,parola) values (@nume, @varsta, @username, @parola)"; var paramNume = comm.CreateParameter(); paramNume.ParameterName = "@nume"; paramNume.Value = elem.Nume; comm.Parameters.Add(paramNume); var paramVarsta = comm.CreateParameter(); paramVarsta.ParameterName = "@varsta"; paramVarsta.Value = elem.Varsta; comm.Parameters.Add(paramVarsta); var paramUsername = comm.CreateParameter(); paramUsername.ParameterName = "@username"; paramUsername.Value = elem.Username; comm.Parameters.Add(paramUsername); var paramParola = comm.CreateParameter(); paramParola.ParameterName = "@parola"; paramParola.Value = elem.Parola; comm.Parameters.Add(paramParola); var result = comm.ExecuteNonQuery(); log.Info("S-a adaugat " + elem.ToString()); return(elem); } }
public Angajat GetAngajatUsernameParola(string username, string parola) { log.InfoFormat("Se cauta angajatul cu username-ul {0} si parola ********", username); var con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "select * from Angajati where username=@username and parola=@parola"; var paramUsername = comm.CreateParameter(); paramUsername.ParameterName = "@username"; paramUsername.Value = username; comm.Parameters.Add(paramUsername); var paramParola = comm.CreateParameter(); paramParola.ParameterName = "@parola"; paramParola.Value = parola; comm.Parameters.Add(paramParola); using (var dataR = comm.ExecuteReader()) { if (dataR.Read()) { int id = dataR.GetInt32(0); String nume = dataR.GetString(1); int varsta = dataR.GetInt32(2); Angajat a = new Angajat(id, nume, varsta, username, parola); log.InfoFormat("S-a gasit {0}", a); return(a); } } } log.InfoFormat("Nu s-a gasit niciun angajat"); return(null); }
public Angajat Delete(Angajat Angajat) { var result = _context.Remove(Angajat); _context.SaveChanges(); return(result.Entity); }
public IActionResult EditAngajat(Angajat angajat) { var angajatRepository = new AngajatRepository(); angajatRepository.EditAngajat(angajat); return(RedirectToAction("ListareAngajati")); }
private void btnUpdateUser_Click(object sender, RoutedEventArgs e) { Angajat angajat = null; Angajat selected = sender as Angajat; selected = (Angajat)angajatDataGrid.SelectedItem; try { angajat = selected; angajat.Nume = txtName.Text.Trim(); angajat.Username = txtUsernameSignUp.Text.Trim(); if (txtPasswordSignUp.Password == "") { string passwInput = SecureStringToString(txtPasswordSignUp.SecurePassword); angajat.Password = sha256_hash(txtUsernameSignUp.Text.Trim(), passwInput); } angajat.Email = txtEmail.Text.Trim(); angajat.NrTelefon = txtPhoneNumber.Text.Trim(); ctx.SaveChanges(); MessageBox.Show("Informations Updated Successfully!"); angajatViewSource.View.Refresh(); } catch (DataException ex) { MessageBox.Show(ex.Message); } }
// Functie ce se ocupa cu operatia de INSERT in baza de date a unui angajat public void InsertAngajat(Angajat angajat) { var query = "INSERT INTO Angajati(Nume, Prenume, Email, Adresa, Telefon, Parola)" + $" VALUES('{angajat.Nume}', '{angajat.Prenume}', '{angajat.Email}', '{angajat.Adresa}', '{angajat.Telefon}', '{angajat.Parola}');"; this.ExecuteQuery(query); }
public void AdaugareAngajat(Angajat angajat) { try { using (SQLiteConnection connection = new SQLiteConnection(Constante.CONNECTION_STRING)) { connection.Open(); using (SQLiteCommand command = new SQLiteCommand(connection)) { command.CommandText = "INSERT INTO Angajat(Nume, DataAngajare, NumarLegitimatie, Retras) VALUES(@nume, @dataAngajare, @numarLegitimatie, @retras)"; command.Prepare(); command.Parameters.AddWithValue("@nume", angajat.Nume); command.Parameters.AddWithValue("@dataAngajare", angajat.DataAngajare); command.Parameters.AddWithValue("@numarLegitimatie", angajat.NumarLegitimatie); command.Parameters.AddWithValue("@retras", angajat.Retras); command.ExecuteNonQuery(); } connection.Close(); } } catch (SQLiteException e) { Console.WriteLine(e.Data); } }
public Angajat Create(Angajat Angajat) { var result = _context.Add <Angajat>(Angajat); _context.SaveChanges(); return(result.Entity); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nume,Prenume,VenitBrut,IsServiciuDeBaza,NrPersoaneInIntretinere")] Angajat angajat) { if (id != angajat.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(angajat); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AngajatExists(angajat.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(angajat)); }
public List <Angajat> getAllAngajatiOfRestaurant(Restaurant restaurant) { List <Angajat> res = new List <Angajat>(); connection.Open(); SqlCommand command = new SqlCommand("SELECT * FROM Angajati WHERE id_restaurant = @idRes", connection); SqlParameter parameterRestaurant = new SqlParameter("@idRes", SqlDbType.Int); parameterRestaurant.Value = restaurant.ID; command.Parameters.Add(parameterRestaurant); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Angajat angajat = new Angajat() { ID = reader.GetInt32(0), Nume = reader.GetString(1), functie = reader.GetString(2), Salariu = reader.GetInt32(3), ID_Restaurant = reader.GetInt32(4) // ID = (int)reader[0], // Nume = (string)reader[1], // functie = (string)reader[2], // Salariu = (int)reader[3], // ID_Restaurant = (int)reader[4] }; res.Add(angajat); } } connection.Close(); return(res); }
public IHttpActionResult PutAngajat(int id, Angajat angajat) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != angajat.marca) { return(BadRequest()); } db.Entry(angajat).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AngajatExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void btnEditTask_Click(object sender, RoutedEventArgs e) { TaskerModel.Task tsk = null; TaskerModel.Task selected = ctx.Tasks.Find(idTask); Angajat responsible = (Angajat)cmbAngajati.SelectedItem; int priority = 1; //if rbtnLow.IsChecked if ((bool)rbtnMedium.IsChecked) { priority = Convert.ToInt32(medie); } else if ((bool)rbtnMedium.IsChecked) { priority = max; } try { if (ValidateTask()) { tsk = selected; tsk.Denumire = txtTitle.Text.Trim(); tsk.Descriere = txtDescription.Text.Trim(); tsk.Deadline = (DateTime)pickerDeadline.SelectedDate; tsk.IdAngajat = responsible.Id; tsk.Prioritate = priority; ctx.SaveChanges(); MessageBox.Show("Task Edited Successfully!"); this.Close(); } } catch (DataException ex) { MessageBox.Show(ex.Message); } }
public void save(Angajat entity) { logger.InfoFormat("Se salveaza angajatul cu id-il {0}", entity.Id); IDbConnection conn = DBUtils.getConnection(); using (var com = conn.CreateCommand()) { com.CommandText = "insert into Angajat values (@idAngajat,@username,@password)"; IDbDataParameter paramIdAngajat = com.CreateParameter(); paramIdAngajat.ParameterName = "@idAngajat"; paramIdAngajat.Value = entity.Id; com.Parameters.Add(paramIdAngajat); IDbDataParameter paramUser = com.CreateParameter(); paramUser.ParameterName = "@username"; paramUser.Value = entity.User; com.Parameters.Add(paramUser); IDbDataParameter paramPass = com.CreateParameter(); paramPass.ParameterName = "@password"; paramPass.Value = entity.Pass; com.Parameters.Add(paramPass); var result = com.ExecuteNonQuery(); if (result == 0) { logger.Info("Error while adding"); throw new Exception("Niciun angajat adaugat!"); } } logger.InfoFormat("A fost adaugat angajatul cu id-ul {0}", entity.Id); }
public Angajat findOne(int id) { logger.InfoFormat("Se cauta angajatul cu id-ul {0}", id); IDbConnection conn = DBUtils.getConnection(); using (var com = conn.CreateCommand()) { com.CommandText = "select idAngajat,username,password from Angajat where idAngajat=@id"; IDbDataParameter paramId = com.CreateParameter(); paramId.ParameterName = "@id"; paramId.Value = id; com.Parameters.Add(paramId); using (var Data = com.ExecuteReader()) { if (Data.Read()) { int idAngajat = Data.GetInt32(0); string user = Data.GetString(1); string pass = Data.GetString(2); Angajat Ang = new Angajat(idAngajat, user, pass); logger.InfoFormat("S-a gasit angajatul cu id-ul {0}", Ang.Id); return(Ang); } } } logger.InfoFormat("Nu s a gasit angajatul cu id ul {0}", id); return(null); }
public List <Angajat> findAngajatiDupaUsername(string nume) { log.InfoFormat("getting employees with username {0}", nume); IDbConnection con = dbUtils.DBUtils.getConnection(); List <Angajat> angajati = new List <Angajat>(); using (var comm = con.CreateCommand()) { comm.CommandText = "select * from angajati where username=@name"; IDbDataParameter paramName = comm.CreateParameter(); paramName.ParameterName = "@name"; paramName.Value = nume; comm.Parameters.Add(paramName); using (var dataR = comm.ExecuteReader()) { while (dataR.Read()) { Angajat a = new Angajat(dataR.GetString(1), dataR.GetString(2), dataR.GetString(3), dataR.GetString(4), dataR.GetString(5)); a.Id = dataR.GetInt32(0); angajati.Add(a); } } } log.InfoFormat("exiting function with value {0}", angajati); return(angajati); }
public IEnumerable <Angajat> findAll() { log.Info("getting all employees"); IDbConnection con = dbUtils.DBUtils.getConnection(); Npgsql.NpgsqlConnection con1 = (Npgsql.NpgsqlConnection)con; Npgsql.NpgsqlConnection.ClearPool(con1); List <Angajat> angajati = new List <Angajat>(); using (var comm = con.CreateCommand()) { comm.CommandText = "select * from angajati"; using (var dataR = comm.ExecuteReader()) { while (dataR.Read()) { Angajat a = new Angajat(dataR.GetString(1), dataR.GetString(2), dataR.GetString(3), dataR.GetString(4), dataR.GetString(5)); a.Id = dataR.GetInt32(0); angajati.Add(a); } } } log.InfoFormat("exiting findall with value {0}", angajati); return(angajati); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(string[] limbiSelectate) { var nouAngajat = new Angajat(); if (limbiSelectate != null) { nouAngajat.LimbiStraineVorbite = new List <LimbaStrainaVorbita>(); foreach (var lb in limbiSelectate) { var lbAdauga = new LimbaStrainaVorbita { LimbaStrainaID = int.Parse(lb) }; nouAngajat.LimbiStraineVorbite.Add(lbAdauga); } } if (await TryUpdateModelAsync <Angajat>( nouAngajat, "Angajat", i => i.NumePrenume, i => i.DataAngajarii, i => i.Email, i => i.NrTelefon, i => i.Salariu, i => i.DepartamentID, i => i.JobID)) { _context.Angajat.Add(nouAngajat); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopuleazaAtribuireLimbaStraina(_context, nouAngajat); return(Page()); }
public void update(Angajat entity) { log.InfoFormat("updating employeee with id {0}", entity.Id); IDbConnection con = dbUtils.DBUtils.getConnection(); using (var comm = con.CreateCommand()) { // verificam daca exista ce vrem sa updatam comm.CommandText = "select * from angajati where id_angajat = @id"; IDbDataParameter paramId = comm.CreateParameter(); paramId.ParameterName = "@id"; paramId.Value = entity.Id; comm.Parameters.Add(paramId); using (var dataR = comm.ExecuteReader()) { if (!dataR.Read()) { log.Info("exiting update without update"); return; } } comm.CommandText = "update angajati set name=@name, phone_number=@tel,address=@addr,username=@user,password=@pass where id_angajat = @id "; var paramName = comm.CreateParameter(); paramName.ParameterName = "@name"; paramName.Value = entity.Name; comm.Parameters.Add(paramName); var paramTel = comm.CreateParameter(); paramTel.ParameterName = "@tel"; paramTel.Value = entity.PhoneNumber; comm.Parameters.Add(paramTel); var paramAddr = comm.CreateParameter(); paramAddr.ParameterName = "@addr"; paramAddr.Value = entity.Address; comm.Parameters.Add(paramAddr); IDbDataParameter paramUser = comm.CreateParameter(); paramUser.ParameterName = "@user"; paramUser.Value = entity.username; comm.Parameters.Add(paramUser); IDbDataParameter paramPass = comm.CreateParameter(); paramPass.ParameterName = "@pass"; paramPass.Value = entity.password; comm.Parameters.Add(paramPass); var result = comm.ExecuteNonQuery(); if (result == 0) { log.Error("no employee updated"); throw new RepositoryException("No employee updated!"); } } log.Info("exiting update function succes"); }
public static AngajatDTO getDTO(Angajat user) { int id = user.Id; string password = user.Parola; string userName = user.User; return(new AngajatDTO(id, userName, password)); }