private void SetWorkers(int divisionId) { if (Workers != null) { Workers.Clear(); } using (DataSet ds = WorkerSQL.GetWorkers(divisionId)) { try { Workers = ds.Tables[0].AsEnumerable().Select(dataRow => new Worker { Id = dataRow.Field <int>("ID"), DivisionId = dataRow.Field <int>("DepartamentID"), PersNum = dataRow.Field <string>("PersNum"), FullName = dataRow.Field <string>("FullName"), Birthday = dataRow.Field <DateTime>("Birthday"), HiringDay = dataRow.Field <DateTime>("HiringDay"), Salary = Decimal.Round(dataRow.Field <decimal>("Salary"), 2), ProfArea = dataRow.Field <string>("ProfArea"), Gender = dataRow.Field <string>("Gender") }).ToList(); } catch (Exception ex) { Console.WriteLine(ex); } } }
internal void Add(int divisionId, string persNum, string fullName, string birthday, string hiringDay, decimal salary, string profArea, string gender) { int id = WorkerSQL.Add(divisionId, persNum, fullName, birthday, hiringDay, salary, profArea, gender); Workers.Add(new Worker { Id = id, DivisionId = divisionId, PersNum = persNum, FullName = fullName, Birthday = Convert.ToDateTime(birthday), HiringDay = Convert.ToDateTime(hiringDay), Salary = Decimal.Round(salary, 2), ProfArea = profArea, Gender = gender }); }
internal void Remove(Division division) { WorkerSQL.DeleteByDivisiontId(division.Id); DivisionSQL.DeleteById(division.Id); Division deleteDivision = Divisions.Find(d => d.Id == division.Id); Divisions.Remove(division); }
internal void Edit(Worker worker) { WorkerSQL.Update(worker.Id, worker.PersNum, worker.FullName, worker.Birthday, worker.HiringDay, worker.Salary, worker.ProfArea, worker.Gender); Worker updateWorker = Workers.First(d => d.Id == worker.Id); updateWorker.PersNum = worker.PersNum; updateWorker.FullName = worker.FullName; updateWorker.Birthday = worker.Birthday; updateWorker.HiringDay = worker.HiringDay; updateWorker.Salary = worker.Salary; updateWorker.ProfArea = worker.ProfArea; updateWorker.Gender = worker.Gender; }
public WorkerInformation() { InitializeComponent(); workerSQL = new WorkerSQL(); }
internal bool Remove(Worker worker) { WorkerSQL.DeleteById(worker.Id); return(Workers.Remove(worker)); }