Example #1
0
 private void SaveCompleted(ObservableCollection <TblStoreCommission> Result, Exception Error)
 {
     if (Error != null)
     {
         MessageBox.Show(Helper.GetInnerExceptionMessage(Error));
         Loading = false;
         return;
     }
     else
     {
         MessageBox.Show(strings.SavedMessage);
     }
     foreach (var item in Result)
     {
         TblStoreCommission savedRow = new TblStoreCommission();
         //if (outindex >= 0 && MainRowList.Count > outindex)
         //    savedRow = MainRowList.ElementAt(outindex);
         savedRow = MainRowList.FirstOrDefault(s => s.Tblstore == item.Tblstore);
         if (savedRow != null)
         {
             savedRow.InjectFrom(Result);
             savedRow.TblStore1 = StoreList.FirstOrDefault(b => b.iserial == savedRow.Tblstore);
         }
     }
     DeleteCommand.RaiseCanExecuteChanged();
     IsNewChanged();
     Loading = false;
 }
        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);
                    }
                };
            }
        }
        public DyeingOrderInvoiceViewModel() : base(PermissionItemName.DyeingOrderInvoice)
        {
            GetItemPermissions(PermissionItemName.DyeingOrderInvoice.ToString());
            //PermissionItemName.dyeing
            DyeingServiceClient.PostDyeingOrderInvoiceCompleted += (s, sv) =>
            {
                if (sv.Result != null)
                {
                    SelectedMainRow.InjectFrom(sv.Result);
                }
                SelectedMainRow.VisPosted = false;
                MessageBox.Show("Posted Completed");
            };
            DyeingServiceClient.DeleteDyeingOrderInvoiceHeaderCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    MessageBox.Show(ev.Error.Message);
                }
                var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                if (oldrow != null)
                {
                    MainRowList.Remove(oldrow);
                }
            };

            MiscValueTypeList = new ObservableCollection <GenericTable>
            {
                new GenericTable {
                    Iserial = 0, Code = "%", Ename = "%", Aname = "%"
                },
                new GenericTable {
                    Iserial = 1, Code = "Value", Ename = "Value", Aname = "Value"
                }
            };

            var currencyClient = new GlService.GlServiceClient();

            currencyClient.GetGenericCompleted += (s, sv) =>
            {
                CurrencyList = new ObservableCollection <CRUDManagerService.GenericTable>();
                foreach (var item in sv.Result)
                {
                    CurrencyList.Add(new CRUDManagerService.GenericTable().InjectFrom(item) as CRUDManagerService.GenericTable);
                }
            };
            currencyClient.GetGenericAsync("TblCurrency", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);

            var journalAccountTypeClient = new GlService.GlServiceClient();

            journalAccountTypeClient.GetGenericCompleted += (s, sv) =>
            {
                JournalAccountTypeList = sv.Result;
            };
            journalAccountTypeClient.GetGenericAsync("TblJournalAccountType", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);


            PurchasePlanClient.GetTblMarkupProdAsync(0, int.MaxValue, "it.Iserial", null, null, LoggedUserInfo.DatabasEname);

            PurchasePlanClient.GetTblMarkupProdCompleted += (s, sv) =>
            {
                MarkupList = new ObservableCollection <TblMarkupProd>();
                foreach (var item in sv.Result)
                {
                    MarkupList.Add(new TblMarkupProd().InjectFrom(item) as TblMarkupProd);
                }

                // MarkupList = sv.Result;
            };



            SelectedMainRow = new TblDyeingOrderInvoiceHeaderViewModel {
                DocDate = DateTime.Now
            };

            DyeingServiceClient.UpdateOrInsertDyeingOrderInvoiceHeaderCompleted += (s, sv) =>
            {
                if (sv.Error != null)
                {
                    MessageBox.Show(sv.Error.Message);
                }
                try
                {
                    SelectedMainRow.InjectFrom(sv.Result);

                    if (SelectedMainRow.Status == 0)
                    {
                        SelectedMainRow.VisPosted = true;
                    }
                    else
                    {
                        SelectedMainRow.VisPosted = false;
                    }
                }

                catch (Exception)
                {
                }
                Loading = false;
                if (OpenMisc)
                {
                    new MarkupTransProdChildWindow(this).Show();
                    OpenMisc = false;
                }
            };

            PurchasePlanClient.UpdateOrInsertDyeingOrderInvoiceMarkupTransProdsCompleted += (s, x) =>
            {
                var markup = new TblMarkupProd();
                try
                {
                    var row = SelectedMainRow.MarkUpTransList.ElementAt(x.outindex);
                    if (row != null)
                    {
                        markup = row.TblMarkupProd1;
                    }
                    if (x.Result.Iserial == -1)
                    {
                        MessageBox.Show("This Markup Is Not Linked To Account");
                        row.TblMarkupProd1 = null;
                    }
                    else
                    {
                        SelectedMainRow.MarkUpTransList.ElementAt(x.outindex).InjectFrom(x.Result);
                        if (row != null)
                        {
                            row.TblMarkupProd1 = markup;
                        }
                    }
                }
                catch (Exception)
                {
                }

                Loading = false;
            };
            DyeingServiceClient.GetDyeingOrderInvoiceHeaderCompleted += (s, sv) =>
            {
                Loading = false;
                MainRowList.Clear();
                foreach (var variable in sv.Result.ToList())
                {
                    var newvendor = new Vendor();
                    newvendor.InjectFrom(sv.Vendors.FirstOrDefault(w => w.vendor_code == variable.Vendor));

                    var newrow = new TblDyeingOrderInvoiceHeaderViewModel();
                    newrow.InjectFrom(variable);
                    newrow.VendorPerRow = newvendor;
                    if (newrow.Status == 0)
                    {
                        newrow.VisPosted = true;
                    }
                    newrow.CurrencyPerRow = new GenericTable();
                    newrow.CurrencyPerRow.InjectFrom(CurrencyList.FirstOrDefault(w => w.Iserial == variable.TblCurrency));
                    newrow.TblCurrency = variable.TblCurrency;
                    MainRowList.Add(newrow);
                }
            };

            DyeingServiceClient.GetDyeingOrderInvoiceDetailCompleted += (s, sv) =>
            {
                foreach (var variable in sv.Result.ToList())
                {
                    var newrow = new TblDyeingOrderInvoiceDetailViewModel();
                    newrow.InjectFrom(variable);
                    newrow.ServicePerRow       = new TblService();
                    newrow.ColorPerRow         = new TblColor();
                    newrow.ColorPerRow.Code    = variable.TblColor1.Code;
                    newrow.ServicePerRow.Code  = variable.TblService1.Code;
                    newrow.ServicePerRow.Ename = variable.TblService1.Ename;
                    TransactionDetails.Add(newrow);
                }
            };
            DyeingServiceClient.SearchDyeingOrderInvoiceCompleted += (s, sv) =>
            {
                TransactionDetails.Clear();
                foreach (var variable in sv.Result.ToList())
                {
                    var newrow = new TblDyeingOrderInvoiceDetailViewModel();
                    newrow.InjectFrom(variable);
                    newrow.ServicePerRow       = new TblService();
                    newrow.ColorPerRow         = new TblColor();
                    newrow.ColorPerRow.Code    = variable.ColorCode;
                    newrow.ServicePerRow.Code  = variable.ServiceCode;
                    newrow.ServicePerRow.Ename = variable.ServiceName;
                    newrow.SupplierInv         = variable.SupplierInv;
                    TransactionDetails.Add(newrow);
                }
            };

            PurchasePlanClient.DyeingOrderInvoiceMarkupTransProdCompleted += (s, sv) =>
            {
                foreach (var row in sv.Result)
                {
                    var newrow = new TblMarkupTranProdViewModel();
                    newrow.InjectFrom(row);
                    newrow.CurrencyPerRow = new GenericTable();
                    newrow.CurrencyPerRow.InjectFrom(CurrencyList.FirstOrDefault(w => w.Iserial == row.TblCurrency));
                    newrow.TblCurrency    = row.TblCurrency;
                    newrow.TblMarkupProd1 = new TblMarkupProd();
                    newrow.TblMarkupProd1.InjectFrom(MarkupList.FirstOrDefault(w => w.Iserial == row.TblMarkupProd));
                    newrow.TblMarkupProd            = row.TblMarkupProd;
                    newrow.JournalAccountTypePerRow = JournalAccountTypeList.FirstOrDefault(w => w.Iserial == newrow.TblJournalAccountType);
                    newrow.EntityPerRow             = new GlService.Entity().InjectFrom(sv.entityList.FirstOrDefault(w => w.Iserial == row.EntityAccount && w.TblJournalAccountType == row.TblJournalAccountType)) as GlService.Entity;
                    newrow.TblJournalAccountType    = row.TblJournalAccountType;
                    newrow.EntityAccount            = row.EntityAccount;
                    SelectedMainRow.MarkUpTransList.Add(newrow);
                }

                Loading = false;

                if (SelectedMainRow.MarkUpTransList.Count == 0)
                {
                    AddNewMarkUpRow(false, true);
                }
            };
        }
        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");
                    }
                };
            }
        }
Example #5
0
        public GenericViewModelCollection(string tablEname, PermissionItemName userJobsForm)
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }
            TablEname = tablEname;
            Client    = new _Proxy.CRUD_ManagerServiceClient();
            GetItemPermissions(userJobsForm.ToString());

            Client.GetGenericCompleted += (s, ev) =>
            {
                Loading = false;
                GenericMapper.InjectFromObCollection(MainRowList, ev.Result);
                //FullCount = ev.fullCount;
                if (MainRowList.Any() && (SelectedMainRow == null || SelectedMainRow.Iserial == 0))
                {
                    SelectedMainRow = MainRowList.FirstOrDefault();
                }
                if (FullCount == 0 && MainRowList.Count == 0)
                {
                    AddNewMainRow(false);
                }

                if (Export)
                {
                    Export = false;
                    ExportGrid.ExportExcel(userJobsForm.ToString());
                }
            };

            MainRowList = new SortableCollectionView <GenericViewModel>();

            Client.GenericUpdateOrInsertCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    MessageBox.Show(ev.Error.Message);
                }
                Loading = false;
                MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
            };

            Client.DeleteGenericCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    MessageBox.Show(ev.Error.Message);
                }
                Loading = false;
                var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                if (oldrow != null)
                {
                    MainRowList.Remove(oldrow);
                }
                if (!MainRowList.Any())
                {
                    AddNewMainRow(false);
                }
            };
            GetMaindata();
        }