public async Task<bool> LoadTimeSheetAndProgress(DateTime workdate, int departstructId, int dailytimesheetId, int projectId, int moduleId)
        {
            bool retValue = false;

            try
            {
                _timesheetprogress.Clear();
                var result = await (new Lib.ServiceModel.ProjectModel()).
                    GetTimesheetAndProgressByWorkdateDepartStructure(workdate, departstructId, dailytimesheetId, projectId, moduleId, 0);

                foreach (var item in result)
                {
                    TimesheetAndProgress child = new TimesheetAndProgress();
                    child.DataID = item.DataID;
                    child.Updated = item.Updated;
                    child.progresseslist = item.progresseslist.ToObservableCollection();
                    child.TimesheetList = item.TimesheetList.ToObservableCollection();

                    _timesheetprogress.Add(child);
                }

                retValue = true;
            }
            catch (Exception e)
            {
                (new WinAppLibrary.Utilities.Helper()).ExceptionHandler(e, "InputProgressDataSource LoadTimeSheetAndProgress");
            }

            return retValue;
        }
        async Task<bool> LoadTotalTimeSheet_Reject(RevealProjectSvc.SigmacueDTO param)
        {
            bool retValue = false;

            this.TimeSheetTotal.Visibility = Visibility.Collapsed;
            this.gvInputTimeProgress.Visibility = Visibility.Visible;
            this.BottomAppBar.IsEnabled = true;

            _status = WinAppLibrary.Utilities.TrackTimeSheetStatus.Reject;
            _timeprogrsses.Clear();

            var result = await (new Lib.ServiceModel.ProjectModel()).GetTimesheetAndProgressByWorkdateDepartStructure(param.SentDate, 0, param.DataID,
                                  Login.UserAccount.CurProjectID, Login.UserAccount.CurModuleID, 0);
            foreach (var ts in result)
            {
                TimesheetAndProgress child = new TimesheetAndProgress();
                child.DataID = ts.DataID;
                child.Updated = ts.Updated;
                child.progresseslist = ts.progresseslist.ToObservableCollection();
                child.TimesheetList = ts.TimesheetList.ToObservableCollection();
                _timeprogrsses.Add(child);
            }

            return retValue;
        }
        public async Task<bool> ReloadTimeSheetProgress(DateTime workdate, int departstructId, int dailytimesheetId, int projectId, int moduleId)
        {
            bool retValue = false;

            _timesheetprogress.Clear();
            var result = await (new Lib.ServiceModel.ProjectModel()).
                GetTimesheetAndProgressByWorkdateDepartStructure(workdate, departstructId, dailytimesheetId, projectId, moduleId, 0);

            foreach (var item in result)
            {
                TimesheetAndProgress child = new TimesheetAndProgress();
                child.DataID = item.DataID;
                child.Updated = item.Updated;
                child.progresseslist = item.progresseslist.ToObservableCollection();
                child.TimesheetList = item.TimesheetList.ToObservableCollection();

                _timesheetprogress.Add(child);
            }

            _timeallocationId = -1;
            return retValue;
        }
 public void Insert(int index, TimesheetAndProgress item)
 {
     if (index != -1 && _timesheetprogress.Count > index - 1)
         _timesheetprogress.Insert(index, item);
     
 }
        private async Task<bool> LoadTimeSheetAndProgress(int departstructureId, DateTime selectedDate, List<RevealProjectSvc.MTODTO> components, List<RevealCommonSvc.ComboBoxDTO> crews)
        {
            bool retValue = false;
            int groupindex = -1;

            if(OperationType == Lib.UI.InputTemplate.OperationType.Normal)
                retValue = await _datasource.LoadTimeSheetAndProgress(selectedDate, departstructureId, 0, Login.UserAccount.CurProjectID, Login.UserAccount.CurModuleID);

            switch (OperationType)
            {
                case Lib.UI.InputTemplate.OperationType.Add:
                    groupindex = (_selectedgroup.DataContext as TimesheetAndProgress).DataID;
                    break;
                case Lib.UI.InputTemplate.OperationType.Normal:
                    if (retValue)
                        groupindex = 0;
                    break;
            }

            if (groupindex > -1 && crews != null && components != null && crews.Count > 0 && components.Count > 0)
            {
                TimesheetAndProgress group = new TimesheetAndProgress();
                group.TimesheetList = new ObservableCollection<RevealProjectSvc.TimesheetDTO>();
                group.progresseslist = new ObservableCollection<RevealProjectSvc.MTODTO>();

                foreach (var item in crews.Select(x => new RevealProjectSvc.TimesheetDTO()
                {
                    DepartStructureID = x.DataID,
                    PersonnelID = Convert.ToInt32(x.ExtraValue2),
                    EmployeeFullName = x.DataName,
                    DTOStatus = (int)WinAppLibrary.Utilities.RowStatus.New
                }).ToList())
                {
                    group.TimesheetList.Add(item);
                }

                foreach (var item in components)
                {
                    item.DTOStatus = (int)WinAppLibrary.Utilities.RowStatus.New;
                    group.progresseslist.Add(item);
                }

                group.Updated = true;
                _datasource.Insert(groupindex, group);
            }

            SelectedGroupIndex = groupindex;
            return retValue;
        }