Example #1
0
        private void LoadRepairLogs(long repairID)
        {
            technicianService.ParseDatabase();
            var repairLogs = technicianService.RepairLogs.FindAll(l => l.Repair.Id == repairID);
            var topbar     = new RepairLogEditorTopbar();

            topbar.newBtn.Click += (object sender, RoutedEventArgs args) =>
            {
                var logEntry = new RepairLogEntry();
                logEntry.techIDLbl.Content = technicianService.CurrentTechnician.Id;
                logEntry.dobLbl.Content    = DateTime.Now.ToShortDateString();
                entryPanel.Children.Insert(0, logEntry);
            };

            topbar.backBtn.Click += (object sender, RoutedEventArgs args) =>
            {
                topbarpanel.Children.Clear();
                entryPanel.Children.Clear();
                LoadRepairs();
            };

            topbar.saveBtn.Click += (object sender, RoutedEventArgs args) =>
            {
                foreach (UIElement uiElement in entryPanel.Children)
                {
                    if (uiElement is RepairLogEntry)
                    {
                        var rle = (RepairLogEntry)uiElement;
                        if (!rle.Modified)
                        {
                            continue;
                        }
                        var rlog = new RepairLogView();
                        rlog.Date         = DateTime.Parse(rle.dobLbl.Content.ToString());
                        rlog.TechnicianId = Convert.ToInt64(rle.techIDLbl.Content.ToString());
                        rlog.Description  = rle.logTblock.Text;
                        rlog.Id           = rle.LogId;
                        rlog.Repair       = technicianService.Repairs.FirstOrDefault(r => r.Id == repairID);
                        technicianService.UploadRepairLog(rlog);
                    }
                }
            };
            topbarpanel.Children.Add(topbar);

            foreach (RepairLogView log in repairLogs)
            {
                var logEntry = new RepairLogEntry();
                logEntry.techIDLbl.Content = log.TechnicianId.ToString();
                logEntry.logTblock.Text    = log.Description.ToString();
                logEntry.dobLbl.Content    = log.Date.ToShortDateString();
                logEntry.LogId             = log.Id;
                entryPanel.Children.Insert(0, logEntry);
            }
            topbar.repairIdLbl.Content = repairID.ToString();
        }
Example #2
0
        private void LoadRepairLogs(long repairID)
        {
            var repairLogs = ManagerService.GetInstance().RepairLogs.FindAll(l => l.Repair.Id == repairID);

            foreach (RepairLogView log in repairLogs)
            {
                var logEntry = new RepairLogEntry();
                logEntry.techIDLbl.Content = log.TechnicianId.ToString();
                logEntry.logTblock.Text    = log.Description.ToString();
                logEntry.dobLbl.Content    = log.Date.ToShortDateString();
                logEntryPanel.Children.Insert(0, logEntry);
            }
            repairJobIDlbl.Content = repairID.ToString();
        }