private static void FillGenericCollection(string tablEname, ObservableCollection <GenericViewModel> objectToFill) { if (objectToFill == null) { objectToFill = new ObservableCollection <GenericViewModel>(); } var serviceClient = new CRUD_ManagerServiceClient(); serviceClient.GetGenericAsync(tablEname, "%%", "%%", "%%", "Iserial", "ASC"); serviceClient.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++; } }; serviceClient.CloseAsync(); }
public ServiceCodingViewModel() { if (!DesignerProperties.IsInDesignTool) { MainRowList = new SortableCollectionView <TblServiceViewModel>(); SelectedMainRow = new TblServiceViewModel(); var tblAssetsTypeclient = new CRUD_ManagerServiceClient(); tblAssetsTypeclient.GetGenericAsync("TblServiceGroup", "%%", "%%", "%%", "Iserial", "ASC"); tblAssetsTypeclient.GetGenericCompleted += (s, sv) => { ServiceGroupList = sv.Result; }; Client.GetTblServiceCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblServiceViewModel(); newrow.InjectFrom(row); MainRowList.Add(newrow); } Loading = false; FullCount = sv.fullCount; if (FullCount == 0 && MainRowList.Count == 0) { AddNewMainRow(false); } }; Client.UpdateOrInsertTblServiceCompleted += (s, x) => { var savedRow = (TblServiceViewModel)MainRowList.GetItemAt(x.outindex); if (savedRow != null) { savedRow.InjectFrom(x.Result); } }; Client.DeleteTblServiceCompleted += (s, ev) => { if (ev.Error != null) { throw ev.Error; } var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { MainRowList.Remove(oldrow); } }; GetMaindata(); } }
public DirectionLinkViewModel() { if (!DesignerProperties.IsInDesignTool) { var client = new CRUD_ManagerServiceClient(); Client.GetAllBrandsCompleted += (s, sv) => { BrandsList = sv.Result; }; Client.GetAllBrandsAsync(LoggedUserInfo.Iserial); client.GetGenericCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblLkpDirectionLinkViewModel { Aname = row.Aname, Ename = row.Ename, Iserial = row.Iserial, Code = row.Code }; MainRowList.Add(newrow); } }; lkpClient.GetTblBrandSectionLinkCompleted += (s, sv) => { BrandSectionList.Clear(); foreach (var row in sv.Result) { BrandSectionList.Add(row.TblLkpBrandSection1); } }; lkpClient.GetTblDirectionLinkCompleted += (s, sv) => { MainSelectedRows.Clear(); MainSelectedRows = sv.Result; foreach (var row in MainRowList) { row.UpdatedAllowed = false; row.Checked = false; } foreach (var row in MainSelectedRows) { var familyRow = MainRowList.SingleOrDefault(x => x.Iserial == row.TblLkpDirection); familyRow.Checked = true; } }; client.GetGenericAsync("TblLkpDirection", "%%", "%%", "%%", "Iserial", "ASC"); } }
public SmlHeaderViewModel() { if (!DesignerProperties.IsInDesignTool) { SmlCollection = new SeasonalMasterCollection(); SmlCollection.OnRefresh += MainRowList_OnRefresh; Client = new CRUD_ManagerServiceClient(); Client.GetAllBrandsCompleted += (s, e) => { try { Brands = new List <Brand>(e.Result); } catch (Exception ex) { var err = new ErrorWindow(ex); err.Show(); } }; Client.GetAllBrandsAsync(LoggedUserInfo.Iserial); var seasonClientclient = new CRUD_ManagerServiceClient(); seasonClientclient.GetGenericCompleted += (s, e) => { Seasons = new List <GenericTable>(e.Result); }; seasonClientclient.GetGenericAsync("TblLkpSeason", "%%", "%%", "%%", "Iserial", "ASC"); FillGenericCollection("tbl_lkp_SMLStatus", StatusList); Client.GetSmlCompleted += (s, e) => { Loading = false; foreach (var item in e.Result) { // SmlCollection.Add(MapItem(item)); } }; GetMaindata(); } else { SmlCollection.Add(new SeasonalMasterListViewModel { StyleCode = "Test Style", Description = "Test Desc", ColorCode = "BL1" }); SmlCollection.Add(new SeasonalMasterListViewModel { StyleCode = "2Test Style", Description = "Test Desc2", ColorCode = "BL2" }); } }
private void LoadSections() { Client.GetGenericCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new SectionLinkModel { Aname = row.Aname, Ename = row.Ename, Iserial = row.Iserial, Code = row.Code }; BrandSectionList.Add(newrow); } BrandSectionGrid.ItemsSource = null; BrandSectionGrid.ItemsSource = BrandSectionList; }; Client.GetGenericAsync("TblLkpBrandSection", "%%", "%%", "%%", "Iserial", "ASC"); }
private void FillGenericCollection(string tablEname, ObservableCollection <GenericViewModel> objectToFill) { objectToFill.Clear(); var client = new CRUD_ManagerServiceClient(); client.GetGenericAsync(tablEname, "%%", "%%", "%%", "Iserial", "ASC"); client.GetGenericCompleted += (s, ev) => { foreach (var item in ev.Result) { objectToFill.Add(new GenericViewModel { Iserial = item.Iserial, Code = item.Code, Aname = item.Aname, Ename = item.Ename }); } }; client.CloseAsync(); }
public CheckListLinkViewModel() { if (!DesignerProperties.IsInDesignTool) { MainRowList = new ObservableCollection <GenericViewModel>(); SelectedMainRow = new GenericViewModel(); SelectedDetailRow = new TblCheckListLinkViewModel(); Client.GetGenericCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new GenericViewModel { Aname = row.Aname, Ename = row.Ename, Iserial = row.Iserial, Code = row.Code }; MainRowList.Add(newrow); } }; Client.GetGenericAsync("TblCheckListGroup", "%%", "%%", "%%", "Iserial", "ASC"); var detailservice = new CRUD_ManagerServiceClient(); detailservice.GetGenericCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblCheckListLinkViewModel { Aname = row.Aname, Ename = row.Ename, Iserial = row.Iserial, Code = row.Code, TblCheckListItem = row.Iserial }; DetailList.Add(newrow); } }; detailservice.GetGenericAsync("TblCheckListItem", "%%", "%%", "%%", "Iserial", "ASC"); var header1Service = new CRUD_ManagerServiceClient(); header1Service.GetGenericCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new GenericTable { Aname = row.Aname, Ename = row.Ename, Iserial = row.Iserial, Code = row.Code, }; CheckListDesignGroupHeader1List.Add(newrow); } }; header1Service.GetGenericAsync("TblCheckListDesignGroupHeader1", "%%", "%%", "%%", "Iserial", "ASC"); var header2 = new CRUD_ManagerServiceClient(); header2.GetGenericCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new GenericTable { Aname = row.Aname, Ename = row.Ename, Iserial = row.Iserial, Code = row.Code, }; CheckListDesignGroupHeader2List.Add(newrow); } }; header2.GetGenericAsync("TblCheckListDesignGroupHeader2", "%%", "%%", "%%", "Iserial", "ASC"); Client.GetTblCheckListLinkCompleted += (s, sv) => { foreach (var row in DetailList) { row.UpdatedAllowed = false; row.Checked = false; row.CheckListDesignGroupHeader1PerRow = null; row.CheckListDesignGroupHeader2PerRow = null; row.TblCheckListDesignGroupHeader1 = null; row.TblCheckListDesignGroupHeader2 = null; } foreach (var row in sv.Result) { var subCheckListRow = DetailList.SingleOrDefault(x => x.Iserial == row.TblCheckListItem); if (subCheckListRow != null) { subCheckListRow.Checked = true; if (row.TblCheckListDesignGroupHeader11 != null) { subCheckListRow.CheckListDesignGroupHeader1PerRow.InjectFrom(row.TblCheckListDesignGroupHeader11); } if (row.TblCheckListDesignGroupHeader21 != null) { subCheckListRow.CheckListDesignGroupHeader2PerRow.InjectFrom(row.TblCheckListDesignGroupHeader21); } } } }; } }
public BrandBudgetViewModel() { if (!DesignerProperties.IsInDesignTool) { TransactionHeader = new TblBrandBudgetsHeaderViewModel(); GetItemPermissions(PermissionItemName.BrandBudget.ToString()); MainRowList = new SortableCollectionView <TblBrandBudgetsHeaderViewModel>(); SelectedDetailRows = new ObservableCollection <TblBrandBudgetDetailViewModel>(); SelectedDetailRow = new TblBrandBudgetDetailViewModel(); TransactionHeader.PropertyChanged += (sender, sv) => { if (sv.PropertyName == "Brand") { Brandsection.Clear(); lkpClient.GetTblBrandSectionLinkAsync(TransactionHeader.Brand, LoggedUserInfo.Iserial); } else if (sv.PropertyName == "TblLkpBrandSection") { // GetFamilyLink(); TransactionHeader.DirectionList.Clear(); GetDirectionLink(); } else if (sv.PropertyName == "TblLkpDirection") { TransactionHeader.StyleCategoryList.Clear(); GetStyleCategoryLink(); } DataGridName = "MainGrid"; }; var factorGroupClient = new CRUD_ManagerServiceClient(); factorGroupClient.GetGenericCompleted += (s, sv) => { FactoryGroupList = sv.Result; }; factorGroupClient.GetGenericAsync("TblFactoryGroup", "%%", "%%", "%%", "Iserial", "ASC"); //lkpClient.GetTblFamilyLinkCompleted += (s, sv) => //{ // foreach (var row in sv.Result) // { // if (TransactionHeader.FamilyList != null && (TransactionHeader != null && TransactionHeader.FamilyList.All(x => x.Iserial != row.TblFamily1.Iserial))) // { // TransactionHeader.FamilyList.Add( new TblFamily().InjectFrom( row.TblFamily1) as TblFamily); // } // } //}; lkpClient.FamilyCategory_GetTblFamilyCategoryLinkCompleted += (s, sv) => { foreach (var row in sv.Result) { if (TransactionHeader.FamilyList != null && (TransactionHeader != null && TransactionHeader.FamilyList.All(x => x.Iserial != row.TblFamily1.Iserial))) { TransactionHeader.FamilyList.Add(new TblFamily().InjectFrom(row.TblFamily1) as TblFamily); } } }; lkpClient.GetTblDirectionLinkCompleted += (s, sv) => { foreach (var row in sv.Result) { if (TransactionHeader.DirectionList != null && (TransactionHeader != null && TransactionHeader.DirectionList.All(x => x.Iserial != row.TblLkpDirection1.Iserial))) { TransactionHeader.DirectionList.Add(new TblLkpDirection().InjectFrom(row.TblLkpDirection1) as TblLkpDirection); } } }; lkpClient.FamilyCategory_GetTblCategoryLinkCompleted += (s, sv) => { foreach (var row in sv.Result) { if (TransactionHeader.StyleCategoryList != null && (TransactionHeader != null && TransactionHeader.StyleCategoryList.All(x => x.Iserial != row.TblStyleCategory1.Iserial))) { TransactionHeader.StyleCategoryList.Add(new TblStyleCategory().InjectFrom(row.TblStyleCategory1) as TblStyleCategory); } } }; //Client.GetTblSalesOrderColorThemeCompleted += (s, sv) => //{ // foreach (var row in sv.Result) // { // if (TransactionHeader.ThemeList != null && (TransactionHeader != null && TransactionHeader.ThemeList.All(x => x.Iserial != row.Iserial))) // { // TransactionHeader.ThemeList.Add(row); // } // } //}; Client.GetAllBrandsCompleted += (s, ev) => { Brands = ev.Result; }; Client.GetAllBrandsAsync(LoggedUserInfo.Iserial); Client.GetAllSeasonsCompleted += (s, ev) => { Seasons = ev.Result; }; Client.GetAllSeasonsAsync(); lkpClient.GetTblBrandSectionLinkCompleted += (s, ev) => { foreach (var row in ev.Result) { if (Brandsection.All(x => x.Iserial != row.TblLkpBrandSection)) { Brandsection.Add(row.TblLkpBrandSection1); } } }; Client.DeleteTblBrandBudgetDetailCompleted += (s, ev) => { if (ev.Error != null) { throw ev.Error; } var oldrow = TransactionHeader.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { TransactionHeader.DetailsList.Remove(oldrow); } }; Client.UpdateOrInsertTblBrandBudgetDetailCompleted += (x, y) => { var savedRow = (TblBrandBudgetDetailViewModel)TransactionHeader.DetailsList.GetItemAt(y.outindex); if (savedRow != null) { savedRow.InjectFrom(y.Result); if (TransactionHeader.Iserial == 0) { TransactionHeader.Iserial = y.Result.TblBrandBudgetHeader; } } }; Client.GetTblBrandBudgetDetailCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblBrandBudgetDetailViewModel(); newrow.InjectFrom(row); if (row.TblFamily1 != null) { newrow.FamilyPerRow = row.TblFamily1; if (TransactionHeader != null && TransactionHeader.FamilyList.All(x => x.Iserial != row.TblFamily1.Iserial)) { TransactionHeader.FamilyList.Add(newrow.FamilyPerRow); } } if (row.TblLkpDirection1 != null) { newrow.DirectionPerRow = row.TblLkpDirection1; if (TransactionHeader != null && TransactionHeader.DirectionList.All(x => x.Iserial != row.TblLkpDirection1.Iserial)) { TransactionHeader.DirectionList.Add(newrow.DirectionPerRow); } } if (row.TblStyleCategory1 != null) { newrow.StyleCategoryPerRow = row.TblStyleCategory1; if (TransactionHeader != null && TransactionHeader.StyleCategoryList.All(x => x.Iserial != row.TblStyleCategory1.Iserial)) { TransactionHeader.StyleCategoryList.Add(newrow.StyleCategoryPerRow); } } //if (row.TblSalesOrderColorTheme1 != null) //{ // newrow.ThemePerRow = row.TblSalesOrderColorTheme1; // if (TransactionHeader != null && TransactionHeader.ThemeList.All(x => x.Iserial != row.TblSalesOrderColorTheme)) // { // TransactionHeader.ThemeList.Add(newrow.ThemePerRow); // } //} newrow.FactoryGroupPerRow = new GenericTable(); if (row.TblFactoryGroup1 != null) { newrow.FactoryGroupPerRow.InjectFrom(row.TblFactoryGroup1); } TransactionHeader.DetailsList.Add(newrow); } TransactionHeader.AddTotalRow(); }; Client.GetTblBrandBudgetHeaderCompleted += (y, v) => { foreach (var row in v.Result) { Loading = false; var newrow = new TblBrandBudgetsHeaderViewModel(); newrow.InjectFrom(row); newrow.BrandSectionPerRow = row.TblLkpBrandSection1; newrow.SeasonPerRow = row.TblLkpSeason1; MainRowList.Add(newrow); } }; Client.UpdateOrInsertTblBrandBudgetHeaderCompleted += (s, x) => { if (x.Error == null) { TransactionHeader.InjectFrom(x.Result); try { foreach (var item in TransactionHeader.DetailsList) { item.TblBrandBudgetHeader = x.Result.Iserial; // Client.UpdateOrInsertTblBrandBudgetDetailAsync(item, true, // LoggedUserInfo.Iserial); TblBrandBudgetDetail myitem = new TblBrandBudgetDetail(); myitem.Amount = item.Amount; myitem.NoOfColors = item.NoOfColors; myitem.NoOfStyles = item.NoOfStyles; myitem.Retail = item.Retail; // myitem.TblSalesOrderColorTheme = item.TblSalesOrderColorTheme; // myitem.PaymentDate = item.PaymentDate; myitem.Qty = item.Qty; myitem.TblBrandBudgetHeader = x.Result.Iserial; myitem.TblFamily = item.TblFamily; myitem.TblLkpDirection = item.TblLkpDirection; myitem.TblStyleCategory = item.TblStyleCategory; Client.SaveBrandBudgetAsync(myitem, LoggedUserInfo.Iserial); } MessageBox.Show("All items have been saved successfully.", "Success", MessageBoxButton.OK); } catch (Exception) { MessageBox.Show("Couldn't save listed items..", "Failed", MessageBoxButton.OK); } } else { MessageBox.Show(x.Error.Message); } Loading = false; //TransactionHeader.InjectFrom(x.Result); }; Client.DeleteTblBrandBudgetHeaderCompleted += (w, k) => { Loading = false; TransactionHeader.InjectFrom(new TblBrandBudgetsHeaderViewModel()); }; } }
public ApprovalViewModel(StyleHeaderViewModel styleViewModel) { TempStyleViewModel = styleViewModel; Perm = 301; if (!DesignerProperties.IsInDesignTool) { User = LoggedUserInfo.Iserial; Salesorder = styleViewModel.SelectedDetailRow.Iserial; var approvalTypeService = new CRUD_ManagerServiceClient(); approvalTypeService.GetGenericAsync("TblApprovalTypes", "%%", "%%", "%%", "Iserial", "ASC"); approvalTypeService.GetGenericCompleted += (s, sv) => { var tblUserBrandSection = LoggedUserInfo.UserBrandSection.FirstOrDefault( x => x.BrandCode == styleViewModel.SelectedMainRow.Brand && x.TblLkpBrandSection == styleViewModel.SelectedMainRow.TblLkpBrandSection); switch (styleViewModel.SelectedDetailRow.SalesOrderType) { case (int)SalesOrderType.SalesOrderPo: Perm = 303; break; } if (tblUserBrandSection != null) { ApprovalTypesList = sv.Result; var userPerm = tblUserBrandSection.TblUserBrandSectionPermissions.SingleOrDefault( x => x.TblAuthPermission == Perm); if (userPerm != null) { if (!userPerm.Retail) { var tempRow = sv.Result.SingleOrDefault(x => x.Code == "Retail"); ApprovalTypesList.Remove(tempRow); } if (!userPerm.Financial) { var tempRow = sv.Result.SingleOrDefault(x => x.Code == "Financial"); ApprovalTypesList.Remove(tempRow); } if (!userPerm.Technical) { var tempRow = sv.Result.SingleOrDefault(x => x.Code == "Technical"); ApprovalTypesList.Remove(tempRow); } } else { ApprovalTypesList.Clear(); } } if (ApprovalTypesList != null && ApprovalTypesList.Count > 0) { GetMaindata(); } }; MainRowList = new ObservableCollection <TblApprovalViewModel>(); SelectedMainRow = new TblApprovalViewModel(); Client.GetTblApprovalCompleted += (s, sv) => { if (sv.Error != null) { MessageBox.Show(sv.Error.Message); } foreach (var row in sv.Result) { var newrow = new TblApprovalViewModel(); newrow.InjectFrom(row); newrow.ApprovalPerRow.InjectFrom(row.TblApprovalType); newrow.UserPerRow = row.TblAuthUser1; MainRowList.Add(newrow); } foreach (var row in ApprovalTypesList) { if (row.Iserial == 1 && !styleViewModel.SelectedDetailRow.IsRetailApproved || row.Iserial == 2 && !styleViewModel.SelectedDetailRow.IsFinancialApproved || row.Iserial == 3 && !styleViewModel.SelectedDetailRow.IsTechnicalApproved ) { AddNewMainRow(row); } } Loading = false; }; ProductionClient.GetTblUsersApprovalStatusAsync(LoggedUserInfo.Iserial); ProductionClient.GetTblUsersApprovalStatusCompleted += (s, sv) => { ApprovalStatusList.Clear(); foreach (var item in sv.Result.ToList()) { ApprovalStatusList.Add(new GenericTable().InjectFrom(item) as GenericTable); } }; Client.UpdateOrInsertTblApprovalCompleted += (s, x) => { Salesorder.InjectFrom(x.Result.TblSalesOrder); var savedRow = (TblApprovalViewModel)MainRowList.GetItemAt(x.outindex); if (savedRow != null) { savedRow.InjectFrom(x.Result); } OnApproveCompleted(); TempStyleViewModel.Loading = false; Loading = false; }; Client.DeleteTblApprovalCompleted += (s, ev) => { if (ev.Error != null) { throw ev.Error; } var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { MainRowList.Remove(oldrow); } }; } }
public AssetsViewModel() { if (!DesignerProperties.IsInDesignTool) { GetItemPermissions(PermissionItemName.AssetsForm.ToString()); var tblAssetsTypeclient = new CRUD_ManagerServiceClient(); tblAssetsTypeclient.GetGenericAsync("TblAssetsType", "%%", "%%", "%%", "Iserial", "ASC"); tblAssetsTypeclient.GetGenericCompleted += (s, sv) => { AssetsTypeList = sv.Result; }; var tblAssetsStatusclient = new CRUD_ManagerServiceClient(); tblAssetsStatusclient.GetGenericAsync("TblAssetsStatus", "%%", "%%", "%%", "Iserial", "ASC"); tblAssetsStatusclient.GetGenericCompleted += (s, sv) => { AssetsStatusList = sv.Result; }; var tblProcessorclient = new CRUD_ManagerServiceClient(); tblProcessorclient.GetGenericAsync("TblProcessor", "%%", "%%", "%%", "Iserial", "ASC"); tblProcessorclient.GetGenericCompleted += (s, sv) => { ProcessorList = sv.Result; }; var tblHardDiskclient = new CRUD_ManagerServiceClient(); tblHardDiskclient.GetGenericAsync("TblHardDisk", "%%", "%%", "%%", "Iserial", "ASC"); tblHardDiskclient.GetGenericCompleted += (s, sv) => { HardDiskList = sv.Result; }; var tblMemoryclient = new CRUD_ManagerServiceClient(); tblMemoryclient.GetGenericAsync("TblMemory", "%%", "%%", "%%", "Iserial", "ASC"); tblMemoryclient.GetGenericCompleted += (s, sv) => { MemoryList = sv.Result; }; Client.UpdateOrInsertTblAssetsCompleted += (s, x) => SelectedMainRow.InjectFrom(x.Result); Client.DeleteTblAssetsCompleted += (s, ev) => { if (ev.Error != null) { throw ev.Error; } SelectedMainRow = new TblAssetsViewModel(); }; Client.GetMaxAssetsCompleted += (s, sv) => { SelectedMainRow.Code = sv.Result; }; } }
public SalesOrderColorThemeViewModel() { if (!DesignerProperties.IsInDesignTool) { GetItemPermissions(PermissionItemName.ColorThemesForm.ToString()); lkpClient.GetTblBrandSectionLinkCompleted += (s, sv) => { BrandSectionList.Clear(); foreach (var row in sv.Result) { BrandSectionList.Add(new GenericTable().InjectFrom(row.TblLkpBrandSection1) as GenericTable); } }; var seasonClient = new CRUD_ManagerServiceClient(); seasonClient.GetGenericCompleted += (s, sv) => { SeasonList = sv.Result; }; seasonClient.GetGenericAsync("TblLkpSeason", "%%", "%%", "%%", "Iserial", "ASC"); MainRowList = new SortableCollectionView <TblSalesOrderColorThemeViewModel>(); MainRowList.CollectionChanged += MainRowList_CollectionChanged; SelectedMainRow = new TblSalesOrderColorThemeViewModel(); Client.GetAllBrandsCompleted += (s, sv) => { BrandList = sv.Result; }; Client.GetAllBrandsAsync(LoggedUserInfo.Iserial); Client.GetTblSalesOrderColorThemeCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblSalesOrderColorThemeViewModel(); 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; ExportGrid.ExportExcel("Style"); } }; Client.UpdateOrInsertTblSalesOrderColorThemeCompleted += (s, x) => { var savedRow = (TblSalesOrderColorThemeViewModel)MainRowList.GetItemAt(x.outindex); if (savedRow != null) { savedRow.InjectFrom(x.Result); } }; Client.DeleteTblSalesOrderColorThemeCompleted += (s, ev) => { if (ev.Error != null) { throw ev.Error; } var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result.Iserial); if (oldrow != null) { MainRowList.Remove(oldrow); } if (!MainRowList.Any()) { AddNewMainRow(false); } }; // Client.GetSeasonalMasterListNotLinkedToSalesorder } }
public ColorLinkViewModel() { if (!DesignerProperties.IsInDesignTool) { Client.GetAllBrandsCompleted += (s, sv) => { BrandsList = sv.Result; }; Client.GetAllBrandsAsync(LoggedUserInfo.Iserial); var seasonClient = new CRUD_ManagerServiceClient(); seasonClient.GetGenericCompleted += (s, sv) => { SeasonList = sv.Result; }; seasonClient.GetGenericAsync("TblLkpSeason", "%%", "%%", "%%", "Iserial", "ASC"); Client.GetTblColorCompleted += (s, sv) => { // ColorsList.Clear(); // GenericMapper.InjectFromObCollection(ColorsList, sv.Result); foreach (var row in sv.Result) { ColorsList.Add(new TblColor().InjectFrom(row) as TblColor); } Loading = false; DetailFullCount = sv.fullCount; }; Client.GetTblColorLinkCompleted += (s, sv) => { foreach (var row in sv.Result) { //if (!MainRowList.Contains(row.TblColor1)) //{ TblColor col = new TblColor(); col.Iserial = row.TblColor1.Iserial; col.Code = row.TblColor1.Code; col.Ename = row.TblColor1.Ename; col.Aname = row.TblColor1.Aname; col.PantonCode = row.PantonCode; MainRowList.Add(col); // } } Loading = false; FullCount = sv.fullCount; }; lkpClient.GetTblBrandSectionLinkCompleted += (s, sv) => { if (Copy) { BrandSectionListCopy.Clear(); foreach (var row in sv.Result) { BrandSectionListCopy.Add(row.TblLkpBrandSection1); } Copy = false; } else { BrandSectionList.Clear(); foreach (var row in sv.Result) { BrandSectionList.Add(row.TblLkpBrandSection1); } } Loading = false; }; Client.UpdateOrDeleteTblColorLinkCompleted += (s, ev) => { if (ev.Error != null) { } else { MainRowList.Clear(); GetMaindata(); } Loading = false; }; Client.CopyColorLinkCompleted += (s, sv) => { Loading = false; }; } }
public StandardBomViewModel() { if (!DesignerProperties.IsInDesignTool) { GetItemPermissions(PermissionItemName.StandardBomForm.ToString()); GetSeason(); var calculationClient = new CRUD_ManagerServiceClient(); calculationClient.GetGenericCompleted += (s, sv) => { BomCalcMethodList = sv.Result; }; calculationClient.GetGenericAsync("BOM_CalcMethod", "%%", "%%", "%%", "Iserial", "ASC"); //Client.GetTblPaymentScheduleCompleted += (s, sv) => //{ // PaymentScheduleList = sv.Result; //}; //Client.GetTblPaymentScheduleAsync(0, int.MaxValue, "it.Iserial", null, null); var uomClient = new CRUD_ManagerServiceClient(); uomClient.GetGenericCompleted += (s, sv) => { UomList = sv.Result; }; uomClient.GetGenericAsync("tbl_lkp_UoM", "%%", "%%", "%%", "Iserial", "ASC"); MainRowList = new SortableCollectionView <TblStandardBomHeaderViewModel>(); SelectedMainRow = new TblStandardBomHeaderViewModel(); // MainRowList.CollectionChanged += MainRowList_CollectionChanged; var factorGroupClient = new CRUD_ManagerServiceClient(); factorGroupClient.GetGenericCompleted += (s, sv) => { FactoryGroupList = sv.Result; }; factorGroupClient.GetGenericAsync("TblFactoryGroup", "%%", "%%", "%%", "Iserial", "ASC"); var complixtyGroupClient = new CRUD_ManagerServiceClient(); complixtyGroupClient.GetGenericCompleted += (s, sv) => { //complix GroupList = sv.Result; }; factorGroupClient.GetGenericAsync("TblFactoryGroup", "%%", "%%", "%%", "Iserial", "ASC"); Client.GetAllBrandsCompleted += (s, sv) => { BrandList = sv.Result; }; Client.GetAllBrandsAsync(LoggedUserInfo.Iserial); Client.GetTblStandardBOMHeaderCompleted += (s, sv) => { Loading = false; if (sv.Result != null) { foreach (var row in sv.Result) { var newrow = new TblStandardBomHeaderViewModel(); newrow.InjectFrom(row); if (!MainRowList.Contains(newrow)) { newrow.SeasonPerRow = new TblLkpSeason(); newrow.FactoryGroupPerRow = new GenericTable(); newrow.ComplexityGroupPerRow = new GenericTable(); if (BrandSectionList.All(x => x.Iserial != row.TblLkpBrandSection1.Iserial)) { BrandSectionList.Add(new LkpData.TblLkpBrandSection().InjectFrom(row.TblLkpBrandSection1) as LkpData.TblLkpBrandSection); } if (SeasonList.All(x => x.Iserial != row.TblLkpSeason)) { SeasonList.Add(new TblLkpSeason().InjectFrom(row.TblLkpSeason1) as TblLkpSeason); } newrow.FactoryGroupPerRow = new GenericTable().InjectFrom(row.TblFactoryGroup1) as GenericTable; if (row.TblComplexityGroup1 != null) { newrow.ComplexityGroupPerRow = new GenericTable().InjectFrom(row.TblComplexityGroup1) as GenericTable; } newrow.SectionPerRow = row.TblLkpBrandSection1; newrow.SeasonPerRow = SeasonList.FirstOrDefault(x => x.Iserial == newrow.TblLkpSeason); 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"); } }; GetMaindata(); Client.UpdateOrInsertTblStandardBOMHeaderCompleted += (s, sv) => { var savedRow = MainRowList.ElementAt(sv.outindex); if (savedRow != null) { savedRow.InjectFrom(sv.Result); } Loading = false; }; Client.DeleteTblStandardBOMHeaderCompleted += (s, ev) => { var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result.Iserial); if (oldrow != null) { MainRowList.Remove(oldrow); } Loading = false; if (!MainRowList.Any()) { AddNewMainRow(false); } }; Client.DeleteTblStandardBOMCompleted += (s, sv) => { Loading = false; if (sv.Error != null) { throw sv.Error; } var oldrow = SelectedMainRow.BomList.FirstOrDefault(x => x.Iserial == sv.Result); if (oldrow != null) { SelectedMainRow.BomList.Remove(oldrow); } }; Client.GetTblStandardBOMCompleted += (s, sv) => { SelectedMainRow.BomList.Clear(); foreach (var row in sv.Result) { var newrow = new BomViewModel { BOM_CalcMethodPerRow = new GenericTable().InjectFrom(row.BOM_CalcMethod) as GenericTable, BOM_FabricTypePerRow = new GenericTable().InjectFrom(row.BOM_FabricType) as GenericTable }; newrow.ColorPerRow = new TblColor(); newrow.ColorPerRow = row.TblColor1; newrow.InjectFrom(row); newrow.ItemPerRow = sv.itemsList.SingleOrDefault(x => x.Iserial == row.BOM_Fabric); SelectedMainRow.BomList.Add(newrow); } if (SelectedMainRow.BomList.Count == 0) { AddBom(false); } }; Client.UpdateOrInsertTblStandardBOMCompleted += (s, sv) => { Loading = false; if (sv.Error != null) { MessageBox.Show(sv.Error.Message); return; } GetSalesOrderBom(); }; } }
public AccGroupViewModel() { if (!DesignerProperties.IsInDesignTool) { Client.GetAccItemGroupTypesCompleted += (s, sv) => { TblItemGroupTypeList = sv.Result; }; Client.GetAccItemGroupTypesAsync(); MainRowList = new SortableCollectionView <TblLkpAccessoryGroupViewModel>(); SelectedMainRow = new TblLkpAccessoryGroupViewModel(); SelectedDetailRow = new TblAccessoriesSubGroupViewModel(); SelectedDetailSubRow = new TblAccessorySizeViewModel(); var client = new CRUD_ManagerServiceClient(); client.GetGenericAsync("TblAccSizeGroup", "%%", "%%", "%%", "Iserial", "ASC"); client.GetGenericCompleted += (s, ev) => { AccSizeGroupList = ev.Result; }; Client.GetTblAccessoriesGroupCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblLkpAccessoryGroupViewModel(); newrow.InjectFrom(row); newrow.ItemGroupTypePerRow = TblItemGroupTypeList.FirstOrDefault(x => x.Iserial == newrow.tbl_lkp_ItemGroupType); MainRowList.Add(newrow); } Loading = false; FullCount = sv.fullCount; if (FullCount == 0 && MainRowList.Count == 0) { AddNewMainRow(false); } }; Client.GetTblAccessoriesSubGroupCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblAccessoriesSubGroupViewModel(); newrow.InjectFrom(row); newrow.AccSizeGroupPerRow = AccSizeGroupList.FirstOrDefault(x => x.Iserial == newrow.TblAccSizeGroup); SelectedMainRow.DetailsList.Add(newrow); } Loading = false; DetailFullCount = sv.fullCount; if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0) { AddNewDetailRow(false); } }; Client.GetTblAccSizeCodeCompleted += (s, sv) => { SelectedDetailRow.DetailsList.Clear(); foreach (var row in sv.Result) { var newrow = new TblAccessorySizeViewModel(); newrow.SizePerRow.InjectFrom(row); SelectedDetailRow.DetailsList.Add(newrow); } Loading = false; Client.GetTblAccSubGroupSizeLinkAsync(SelectedDetailRow.Iserial); }; Client.GetTblAccSubGroupSizeLinkCompleted += (s, sv) => { foreach (var row in SelectedDetailRow.DetailsList) { row.UpdatedAllowed = false; row.Checked = false; } foreach (var row in sv.Result) { var subfamilyRow = SelectedDetailRow.DetailsList.SingleOrDefault(x => x.SizePerRow.Iserial == row.TblAccSize); subfamilyRow.Checked = true; } Loading = false; }; Client.UpdateOrInsertTblAccessoriesGroupCompleted += (s, x) => { var savedRow = (TblLkpAccessoryGroupViewModel)MainRowList.GetItemAt(x.outindex); if (savedRow != null) { savedRow.InjectFrom(x.Result); } }; Client.UpdateOrInsertTblAccessoriesSubGroupCompleted += (s, x) => { var savedRow = (TblAccessoriesSubGroupViewModel)SelectedMainRow.DetailsList.GetItemAt(x.outindex); if (savedRow != null) { savedRow.InjectFrom(x.Result); } //if (x.Result.TblSalaryRelation1 != null) //{ // var headerIserial = x.Result.TblSalaryRelation; // SelectedMainRow.Iserial = headerIserial; //} }; Client.DeleteTblAccessoriesGroupCompleted += (s, ev) => { if (ev.Error != null) { throw ev.Error; } var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { MainRowList.Remove(oldrow); } }; Client.DeleteTblAccessoriesSubGroupCompleted += (s, ev) => { if (ev.Error != null) { throw ev.Error; } var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { SelectedMainRow.DetailsList.Remove(oldrow); } }; GetMaindata(); } }