private void updateRowChanges() { try { Employee oldRow = VM.row[0]; Employee newRow = (Employee)RowView.Items[0]; newRow.CalculateIsError(); newRow.IsManuallyChanged = 1; windowBack.VM.Logs.ToList().ForEach((e) => { if (e.ID == oldRow.ID && e.Date == oldRow.Date) { e = newRow; } }); VM.inter.UpdateLog(newRow); windowBack.VM.Emp.logs = (Employee[])windowBack.VM.Logs; LogsHolder newEmp = windowBack.VM.Emp; newEmp.CalculateAll(); windowBack.VM.Emp = newEmp; windowBack.LogsView.ItemsSource = windowBack.VM.Emp.logs; this.Close(); } catch (Exception ex) { MessageBox.Show("אירעה תקלה בעדכון השורה. אנא צור קשר. " + ex.Message); } }
public LogsHolder GetLogsByMonthYearAndName(int month, int year, string name) { if (month == 0 || year == 0 || name == null) { throw new NullReferenceException(); } try { LogsHolder result = null; if (name != null) { Employee[] logs = null; List <Employee> newLogs = new List <Employee>(); logs = GetLogsByMonthAndYear(month, year); for (int i = 0; i < logs.Count(); i++) { if (logs[i].Name.ToLower() == name.ToLower()) { newLogs.Add(logs[i]); } } foreach (Employee log in logs) { log.CalculateIsError(); } result = new LogsHolder(newLogs.ToArray()); result.CalculateAll(); } return(result); } catch (Exception ex) { if (ex is NullReferenceException) { MessageBox.Show("תאריך או עובד לא נבחרו"); } else { MessageBox.Show("אירעה תקלה: " + ex.Message); } return(null); } }
public LogsHolder GetLogsByEmpName(string name) { if (name == null) { throw new NullReferenceException(); } try { LogsHolder result = null; using (MyEntity entity = new MyEntity()) { List <Employee> logs = new List <Employee>(); logs = (from Employee in entity.Employees where Employee.Name.ToLower() == name.ToLower() orderby Employee.Date ascending select Employee).ToList(); foreach (Employee log in logs) { log.CalculateIsError(); } result = new LogsHolder(logs.ToArray()); result.CalculateAll(); } return(result); } catch (Exception ex) { if (ex is NullReferenceException) { MessageBox.Show("לא נבחר עובד."); } else { MessageBox.Show("אירעה תקלה:" + ex.Message); } return(null); } }