public EmpLeavingTransactionViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                GetItemPermissions(PermissionItemName.EmpLeavingTransactionForm.ToString());
                GetCustomePermissions(PermissionItemName.EmpLeavingTransactionForm.ToString());
                PremCompleted += (s, sv) => AddNewMainRow(false);
                Client.UpdateOrInsertEmpLeavingTransactionCompleted += (s, x) =>
                {
                    var savedRow = (TblEmpLeavingTransactionViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                    Loading = false;
                };
                Client.SearchBysStoreNameAsync(new ObservableCollection <int>(LoggedUserInfo.AllowedStores), LoggedUserInfo.Iserial, null, null, LoggedUserInfo.DatabasEname);

                Client.SearchBysStoreNameCompleted += (s, sv) =>
                {
                    foreach (var variable in sv.Result)
                    {
                        Client.GetEmpTablebyStoreAndCompanyAsync(LoggedUserInfo.DatabasEname, variable.code);
                        Store = variable.code;
                    }
                };
                Client.DeleteEmpLeavingTransactionCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };
                EmpList = new ObservableCollection <EmployeesView>();
                Client.GetEmpTablebyStoreAndCompanyCompleted += (s, sv) =>
                {
                    foreach (var variable in sv.Result)
                    {
                        EmpList.Add(variable);
                    }
                };
            }
        }
Ejemplo n.º 2
0
        public EmpWeeklyDayOffViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                WeekList = new List <string>();

                GetItemPermissions(PermissionItemName.EmpWeeklyDayOff.ToString());

                Client.UpdateOrInsertTblEmpWeeklyDayOffCompleted += (s, x) =>
                {
                    var savedRow = (TblEmpWeeklyDayOffViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
                Client.DeleteTblEmpWeeklyDayOffCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };

                foreach (var variable in GetDates(2015, 10))
                {
                    WeekList.Add(variable.DayOfWeek.ToString());
                }
                GetMaindata();

                Client.GetTblEmpWeeklyDayOffCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblEmpWeeklyDayOffViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Any() && (SelectedMainRow == null || SelectedMainRow.Iserial == 0))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }

                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }

                    if (Export)
                    {
                        Export = false;

                        //var handler = ExportCompleted;
                        //if (handler != null) handler(this, EventArgs.Empty);
                        //ExportGrid.ExportExcel("Style");
                    }
                };
            }
        }