Ejemplo n.º 1
0
        protected virtual void GetCustomePermissions(string parentItemName)
        {
            var client = new _Proxy.CRUD_ManagerServiceClient();

            client.GetItemsPermissionsByParentCompleted += (s, e) =>
            {
                var temp = (from z in e.Result
                            where (from x in LoggedUserInfo.WFM_UserJobPermissions
                                   select x.TblPermission).Contains(z.Iserial)
                            select z).ToList();

                foreach (var item in temp)
                {
                    if (!CustomePermissions.Contains(item))
                    {
                        CustomePermissions.Add(item);
                    }
                }
                foreach (var item in PermissionsMapper)
                {
                    var c = CustomePermissions.SingleOrDefault(x => x.Code == item.PermissionKey);

                    item.PermissionValue = c != null;
                }
                var handler = PremCompleted;
                if (handler != null)
                {
                    handler(this, EventArgs.Empty);
                }
            };

            client.GetItemsPermissionsByParentAsync(parentItemName);
        }
Ejemplo n.º 2
0
        private void FillGenericCollection(string tablEname, ObservableCollection <GenericViewModel> objectToFill)
        {
            var client = new _Proxy.CRUD_ManagerServiceClient();

            client.GetGenericAsync(tablEname, "%%", "%%", "%%", "Iserial", "ASC");

            client.GetGenericCompleted += (s, ev) =>
            {
                var i = 0;
                foreach (var item in ev.Result)
                {
                    objectToFill.Add(new GenericViewModel
                    {
                        Iserial = item.Iserial,
                        Code    = item.Code,
                        Aname   = item.Aname,
                        Ename   = item.Ename
                    });
                    objectToFill[i].Status.IsChanged     = false;
                    objectToFill[i].Status.IsNew         = false;
                    objectToFill[i].Status.IsSavedDBItem = true;
                    i++;
                }
            };
        }
Ejemplo n.º 3
0
 private void FillSubGroupSizes()
 {
     try
     {
         var client = new _Proxy.CRUD_ManagerServiceClient();
         client.GetSuptGroupSizesCompleted += (s, e) =>
         {
             if (e.Result != null)
             {
                 AccSizesList.Clear();
                 foreach (var item in e.Result)
                 {
                     AccSizesList.Add(item);
                     RaisePropertyChanged("AccSizesList");
                 }
                 IsSizeIncludedInHeader = true;
             }
             else
             {
                 IsSizeIncludedInHeader = false;
             }
         };
         if (AccSubGroup != null)
         {
             client.GetSuptGroupSizesAsync((int)AccSubGroup);
         }
     }
     catch (Exception ex)
     {
         var err = new ErrorWindow(ex);
         err.Show();
     }
 }
Ejemplo n.º 4
0
        private void FillFabricAttributes()
        {
            var client = new _Proxy.CRUD_ManagerServiceClient();

            client.GetAllFabAttributesCompleted += (s, e) =>
            {
                if (e.Error == null)
                {
                    foreach (var item in e.Result)
                    {
                        FabricAttrCollection.Add(item);
                    }
                }
            };
            client.GetAllFabAttributesAsync();
            client.CloseAsync();
        }
Ejemplo n.º 5
0
        private void FillSubGroupCollection()
        {
            try
            {
                AccSubGrouplist.Clear();
                var client = new _Proxy.CRUD_ManagerServiceClient();

                client.GetAccSubGroupByGroupCompleted += (s, e) =>
                {
                    foreach (var item in e.Result)
                    {
                        AccSubGrouplist.Add(item);
                        RaisePropertyChanged("AccSubGrouplist");
                    }
                };
                client.GetAccSubGroupByGroupAsync(AccessoryGroupProperty.Iserial);
            }
            catch (Exception ex)
            {
                var err = new ErrorWindow(ex);
                err.Show();
            }
        }
Ejemplo n.º 6
0
        public void LoadImages(string fabCode)
        {
            ImageCollection = new ObservableCollection <GImageViewModel>();
            g_IsBusy        = true;
            var client = new _Proxy.CRUD_ManagerServiceClient();

            client.GetFabricImagesByFabricCompleted += (s, e) =>
            {
                if (e.Error == null)
                {
                    foreach (var item in e.Result)
                    {
                        ImageCollection
                        .Add(FabricSetupsViewModelMapper
                             .MapToViewModelObject(item, fabCode));
                    }
                    g_IsBusy = false;
                }
                RaisePropertyChanged("ImageCollection");
                g_IsBusy = false;
            };
            client.GetFabricImagesByFabricAsync(fabCode);
        }
Ejemplo n.º 7
0
        public void LoadViewModel()
        {
            Vendors = new ObservableCollection <_Proxy.Vendor>();
            Vendors.CollectionChanged        += Vendors_CollectionChanged;
            WarehousesList                    = new ObservableCollection <_Proxy.V_Warehouse>();
            WarehousesList.CollectionChanged += WarehousesList_CollectionChanged;
            CreationDate = DateTime.Now;
            var client = new _Proxy.CRUD_ManagerServiceClient();

            client.GetVendorsCompleted += (a, b) =>
            {
                try
                {
                    foreach (var item in b.Result)
                    {
                        Vendors.Add(item);
                    }
                }
                catch (Exception ex)
                {
                    var err = new ErrorWindow(ex);
                    err.Show();
                }
            };

            client.GetAllWarehousesByCompanyNameCompleted += (s, e) =>
            {
                foreach (var item in e.Result)
                {
                    WarehousesList.Add(item);
                }
            };
            client.GetAllWarehousesByCompanyNameAsync("CCR");
            PurchaseOrderDetails = new ObservableCollection <PurchasOrderDetailsViewModel>();
            client.CloseAsync();
        }
Ejemplo n.º 8
0
        private void SaveAccessories()
        {
            var client    = new _Proxy.CRUD_ManagerServiceClient();
            var headerRow = new _Proxy.tbl_AccessoryAttributesHeader();

            headerRow.InjectFrom(SelectedMainRow);

            var detailsList = new ObservableCollection <_Proxy.tbl_AccessoryAttributesDetails>();

            GenericMapper.InjectFromObCollection(detailsList, AccDetailsList);


            var valiationCollection = new List <ValidationResult>();

            var isvalid = Validator.TryValidateObject(SelectedMainRow,
                                                      new ValidationContext(SelectedMainRow, null, null), valiationCollection, true);

            if (!isvalid)
            {
                MessageBox.Show("Data IS not Valid");
                return;
            }


            if (SelectedMainRow.ObjStatus.IsNew)
            {
                client.AddAllNewAccessoriesAttributesCompleted += (s, sv)
                                                                  =>
                {
                    MessageBox.Show(sv.Error == null ? strings.SavedMessage : strings.FailSavingMessage);
                    SelectedMainRow.InjectFrom(sv.Result);
                    SelectedMainRow.ObjStatus.IsNew         = false;
                    SelectedMainRow.ObjStatus.IsSavedDBItem = true;

                    AccDetailsList = new SortableCollectionView <AccessoryAttributesDetailsViewModel>();


                    foreach (var row in sv.Result.tbl_AccessoryAttributesDetails)
                    {
                        var newrow = new AccessoryAttributesDetailsViewModel
                        {
                            ObjStatus = { IsNew = false, IsSavedDBItem = true }
                        };
                        newrow.InjectFrom(row);
                        AccDetailsList.Add(newrow);
                    }
                };
                //  if (AllowAdd)
                //        {
                client
                .AddAllNewAccessoriesAttributesAsync
                    (headerRow
                    , detailsList, SelectedMainRow.IsSizeIncludedInHeader, LoggedUserInfo.Iserial);
                //       }
                //      else
                //   {
                //         MessageBox.Show("You do not have the permission to add a new item!");
                //    }
            }
            else if (SelectedMainRow.ObjStatus.IsSavedDBItem)
            {
                client.UpdateAccessoriesAttributesCompleted += (s, e) =>
                {
                    MessageBox.Show(e.Error == null ? strings.SavedMessage : strings.FailSavingMessage);
                    SelectedMainRow.InjectFrom(e.Result);
                    SelectedMainRow.ObjStatus.IsNew         = false;
                    SelectedMainRow.ObjStatus.IsSavedDBItem = true;

                    AccDetailsList = new SortableCollectionView <AccessoryAttributesDetailsViewModel>();

                    foreach (var row in e.Result.tbl_AccessoryAttributesDetails)
                    {
                        var newrow = new AccessoryAttributesDetailsViewModel
                        {
                            ObjStatus = { IsNew = false, IsSavedDBItem = true }
                        };
                        newrow.InjectFrom(row);
                        AccDetailsList.Add(newrow);
                    }
                }
                ;
                //     if (AllowUpdate)
                //     {
                var detailsNewList = new ObservableCollection <_Proxy.tbl_AccessoryAttributesDetails>();
                GenericMapper.InjectFromObCollection(detailsNewList, AccDetailsList.Where(x => x.ObjStatus.IsNew));

                var detailsUpdatedList = new ObservableCollection <_Proxy.tbl_AccessoryAttributesDetails>();
                GenericMapper.InjectFromObCollection(detailsUpdatedList, AccDetailsList.Where(x => x.ObjStatus.IsSavedDBItem));

                client
                .UpdateAccessoriesAttributesAsync
                    (headerRow,
                    detailsNewList,
                    detailsUpdatedList, LoggedUserInfo.Iserial);
                //   }
                //    else
                //    {
                //        MessageBox.Show("You do not have the update permission");
                //   }
            }
        }
Ejemplo n.º 9
0
        public void SearchFabricAttrs(FabricSetupsViewModel _SearchCriteria)
        {
            var client = new _Proxy.CRUD_ManagerServiceClient();

            client.GetFabAttributesByCategoryCompleted += (s, e) =>
            {
                switch (_SearchCriteria.FabricCategoryID)
                {
                case 2:
                case 3:
                    FabAttrResultDataGrid.ItemsSource =
                        (from x in e.Result.ToList()
                         select
                         new
                    {
                        x.FabricID
                        ,
                        x.FabricDescription
                        ,
                        x.FabricCategoryName
                        ,
                        x.UoM
                        ,
                        x.WidthAsRaw
                        ,
                        x.WeightPerSquarMeterAsRaw
                        ,
                        x.ExpectedDyingLossMargin
                        ,
                        x.Notes
                    });
                    break;

                case 4:
                case 5:
                    FabAttrResultDataGrid.ItemsSource = (from x in e.Result.ToList()
                                                         select
                                                         new
                    {
                        x.FabricID
                        ,
                        x.FabricDescription
                        ,
                        x.FabricCategoryName
                        ,
                        x.UoM
                        ,
                        x.HorizontalShrinkage
                        ,
                        x.VerticalShrinkage
                        ,
                        x.WeightPerSquarMeterAfterWash
                        ,
                        x.WeightPerSquarMeterBeforWash
                        ,
                        x.Twist
                        ,
                        x.Notes
                    }).ToList();
                    break;

                case 1:
                    FabAttrResultDataGrid.ItemsSource = (from x in e.Result.ToList()
                                                         select
                                                         new
                    {
                        x.FabricID
                        ,
                        x.FabricDescription
                        ,
                        x.FabricCategoryName
                        ,
                        x.UoM
                        ,
                        x.Notes
                    }).ToList();
                    break;
                }
            };
            client.GetFabAttributesByCategoryAsync(_SearchCriteria.FabricCategoryID);
        }
Ejemplo n.º 10
0
        public void LoadViewModel()
        {
            ObjStatus = new ObjectStatus {
                IsNew = true
            };
            Client         = new _Proxy.CRUD_ManagerServiceClient();
            WarehousesList = new ObservableCollection <_Proxy.V_Warehouse>();
            WarehousesList.CollectionChanged += WarehousesList_CollectionChanged;
            CreationDate = DateTime.Now;
            Client.GetAllWarehousesByCompanyNameCompleted += (s, e) =>
            {
                foreach (var item in e.Result)
                {
                    WarehousesList.Add(item);
                }
            };
            Client.GetAllWarehousesByCompanyNameAsync("CCR");
            PurchaseOrderDetails = new ObservableCollection <PurchasOrderDetailsViewModel>();

            PurchaseOrderDetails.CollectionChanged += (s, e) =>
            {
                if (e.NewItems != null)
                {
                    foreach (PurchasOrderDetailsViewModel item in e.NewItems)
                    {
                        item.PropertyChanged
                            += (s1, e1) =>
                            {
                            RaisePropertyChanged(e1.PropertyName);
                            if (e1.PropertyName == "RowTotal")
                            {
                                GrandTotal = PurchaseOrderDetails.Sum(x => x.RowTotal);
                            }
                            };

                        var item1 = item;
                        item.DeletePurchLine += (ss, ee) =>
                        {
                            var res = MessageBox.Show("Delete?", "", MessageBoxButton.OKCancel);
                            if (res == MessageBoxResult.Cancel)
                            {
                                return;
                            }
                            PurchaseOrderDetails.Remove(item1);
                        };
                    }
                }

                if (e.OldItems != null)
                {
                    foreach (PurchasOrderDetailsViewModel item in e.OldItems)
                    {
                        item.PropertyChanged
                            -= ((s1, e1) => RaisePropertyChanged(e1.PropertyName));
                        var item1 = item;
                        item.DeletePurchLine -= ((ss, ee) =>
                        {
                            if (item1.ObjStatus.IsSavedDBItem)
                            {
                                PurchaseOrderDeletedDetails.Add(item1);
                            }
                            PurchaseOrderDetails.Remove(item1);
                        });
                    }
                }
            };

            Client.PostPoToAxCompleted += (s, e)
                                          =>
            {
                MessageBox
                .Show(e.Error == null ? "PO Successfully Posted" : "PO Was not posted");
                IsPosted = e.Error == null;
            }

            ;
        }
Ejemplo n.º 11
0
        public void SaveImages()
        {
            if (ImageCollection.Count > 0)
            {
                g_IsBusy = true;
                var newImages     = new ObservableCollection <_Proxy.tbl_FabricImage>();
                var updatedImages = new ObservableCollection <_Proxy.tbl_FabricImage>();

                foreach (var item in ImageCollection)
                {
                    if (item._ImageState == ImageCondition.NewAdded)
                    {
                        newImages.Add(FabricSetupsViewModelMapper.MapToModelObject(item));
                    }
                    else if (item._ImageState == ImageCondition.LoadedAndChanged)
                    {
                        updatedImages.Add(FabricSetupsViewModelMapper.MapToModelObject(item));
                    }
                }
                var client = new _Proxy.CRUD_ManagerServiceClient();
                if (newImages.Count > 0)
                {
                    client.AddFabricGalaryCompleted += (s, e) =>
                    {
                        if (e.Error != null)
                        {
                            g_IsBusy = false;
                            throw new Exception("Error!, Data was not added\n" + e.Error.Message);
                        }
                        else
                        {
                            MessageBox.Show("Data was added successfully");
                            g_IsBusy = false;
                        }
                        g_IsBusy = false;
                    };
                    client.AddFabricGalaryAsync(newImages);
                }
                if (updatedImages.Count > 0)
                {
                    client.UpdateFabricGalaryCompleted += (s, e) =>
                    {
                        if (e.Error != null)
                        {
                            g_IsBusy = false;
                            throw new Exception("Error!, Data was not Updated\n" + e.Error.Message);
                        }
                        else
                        {
                            MessageBox.Show("Data was updated successfully");
                            g_IsBusy = false;
                        }
                        g_IsBusy = false;
                    };
                    client.UpdateFabricGalaryAsync(updatedImages);
                }
            }
            else
            {
                MessageBox.Show("data are not valid for saving!");
            }
        }
Ejemplo n.º 12
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();
        }