protected void PoPuPOB(object sender, DirectEventArgs e) { string positionId = e.ExtraParams["positionId"]; string categoryId = e.ExtraParams["categoryId"]; string delivery = e.ExtraParams["deliveryDuration"]; string type = e.ExtraParams["type"]; switch (type) { case "imgEdit": //Step 1 : get the object from the Web Service //Step 2 : call setvalues with the retrieved object AssetCategoryControl.setCategory(categoryId); if (!string.IsNullOrEmpty(delivery)) { deliveryDuration.Value = Convert.ToInt32(delivery); } this.EditRecordWindow.Title = Resources.Common.EditWindowsTitle; this.EditOnBoardingRecordWindow.Show(); break; case "imgDelete": X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig { Yes = new MessageBoxButtonConfig { //We are call a direct request metho for deleting a record Handler = String.Format("App.direct.DeleteRecord({0})", categoryId), Text = Resources.Common.Yes }, No = new MessageBoxButtonConfig { Text = Resources.Common.No } }).Show(); break; case "colAttach": //Here will show up a winow relatice to attachement depending on the case we are working on break; default: break; } }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; AssetManagementOnBoarding b = JsonConvert.DeserializeObject <AssetManagementOnBoarding>(obj); if (string.IsNullOrEmpty(CurrentPositionId.Text)) { return; } //if (tsId.SelectedItem != null) // b.tsName = tsId.SelectedItem.Text; b.categoryId = AssetCategoryControl.GetCategoryId(); b.positionId = CurrentPositionId.Text; // Define the object to add or edit as null if (string.IsNullOrEmpty(b.categoryId)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <AssetManagementOnBoarding> request = new PostRequest <AssetManagementOnBoarding>(); request.entity = b; PostResponse <AssetManagementOnBoarding> r = _branchService.ChildAddOrUpdate <AssetManagementOnBoarding>(request); //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { //Add this record to the store this.OnboardingStore.Reload(); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditOnBoardingRecordWindow.Close(); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { PostRequest <AssetManagementOnBoarding> request = new PostRequest <AssetManagementOnBoarding>(); request.entity = b; PostResponse <AssetManagementOnBoarding> r = _assetManagementService.ChildAddOrUpdate <AssetManagementOnBoarding>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); return; } else { OnboardingStore.Reload(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditOnBoardingRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }