public SearchAssetsViewModel() { if (!DesignerProperties.IsInDesignTool) { MainRowList = new SortableCollectionView <TblAssetsViewModel>(); SelectedMainRow = new TblAssetsViewModel(); Client.GetTblAssetsCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblAssetsViewModel(); newrow.InjectFrom(row); if (row.TblAssetsType1 != null) { newrow.AssetTypePerRow.InjectFrom(row.TblAssetsType1); } if (row.TblHardDisk1 != null) { newrow.HardDiskPerRow.InjectFrom(row.TblHardDisk1); } if (row.TblMemory1 != null) { newrow.MemoryPerRow.InjectFrom(row.TblMemory1); } if (row.TblProcessor1 != null) { newrow.ProcessorPerRow.InjectFrom(row.TblProcessor1); } newrow.Pending = sv.PendingAssets.Any(x => x == row.Iserial); MainRowList.Add(newrow); } Loading = false; FullCount = sv.fullCount; if (MainRowList.Any() && (SelectedMainRow == null || SelectedMainRow.Iserial == 0)) { SelectedMainRow = MainRowList.FirstOrDefault(); } if (Export) { Export = false; //var handler = ExportCompleted; //if (handler != null) handler(this, EventArgs.Empty); //ExportGrid.ExportExcel("Style"); } }; GetMaindata(); } }
public void DeleteMainRow() { var res = MessageBox.Show("Are You To Delete SelectedRecords From Database ?", "Delete", MessageBoxButton.OKCancel); if (res == MessageBoxResult.OK) { if (SelectedMainRow.Iserial != 0) { if (AllowDelete != true) { MessageBox.Show(strings.AllowDeleteMsg); return; } Loading = true; Client.DeleteTblAssetsAsync( (TblAsset) new TblAsset().InjectFrom(SelectedMainRow), 0); } else { SelectedMainRow = new TblAssetsViewModel(); } } }
public void SubmitSearch(TblAssetsViewModel row) { SelectedMainRow = row; SubmitSearchAction.Invoke(this, null); }
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; }; } }