private void DuplicateNote_Execute(object sender, SimpleActionExecuteEventArgs e) { if (!ObjectSpace.IsModified) { genCon.showMsg("Error", "Please edit the item 1st.", InformationType.Error); return; } if (((ListView)View).SelectedObjects.Count != 1) { genCon.showMsg("Error", "Only 1 record to be duplicated at once.", InformationType.Error); } else { int minoid = 0; foreach (ClaimTrxDetailNotes dtl in ((ListView)View).CollectionSource.List) { if (dtl.Oid < minoid) { minoid = dtl.Oid - 1; } } foreach (ClaimTrxDetailNotes dtl in ((ListView)View).SelectedObjects) { ClaimTrxDetailNotes newdtl = ObjectSpace.CreateObject <ClaimTrxDetailNotes>(); genCon.duplicatedetailnote(ref newdtl, dtl, ObjectSpace); newdtl.Oid = (dtl.ClaimTrxDetail.Oid < 0 ? dtl.ClaimTrxDetail.Oid * 100 : dtl.ClaimTrxDetail.Oid * -100) + minoid; newdtl.IsDuplicated = true; ((ListView)View).CollectionSource.Add(newdtl); } genCon.showMsg("Success", "Item duplicated.", InformationType.Success); } }
private void SwitchView_Execute(object sender, SimpleActionExecuteEventArgs e) { if (ObjectSpace.ModifiedObjects.Count == 0) { ((DetailView)View).ViewEditMode = ViewEditMode.View; View.BreakLinksToControls(); View.CreateControls(); } else { genCon.showMsg("Error", "Please save the document 1st.", InformationType.Info); } }
private void PostClaim_Execute(object sender, SimpleActionExecuteEventArgs e) { if (GeneralSettings.B1Post && genCon.ConnectSAP()) { IObjectSpace ios = Application.CreateObjectSpace(); if (View is DetailView) { ClaimTrxs selectedObject = (ClaimTrxs)View.CurrentObject; if (GeneralSettings.B1Post) { GeneralSettings.oCompany.StartTransaction(); } if (PostToSAP(selectedObject, ios) == -1) { if (GeneralSettings.B1Post) { if (GeneralSettings.oCompany.InTransaction) { GeneralSettings.oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } } ios.Rollback(false); } if (GeneralSettings.B1Post) { if (GeneralSettings.oCompany.InTransaction) { GeneralSettings.oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); } } ios.CommitChanges(); } else if (View is ListView) { if (e.SelectedObjects.Count > 0) { //IObjectSpace os; //os = Application.CreateObjectSpace(); //ClaimTrxs obj = os.CreateObject<ClaimTrxs>(); if (GeneralSettings.B1Post) { GeneralSettings.oCompany.StartTransaction(); } foreach (ClaimTrxs selectedObject in e.SelectedObjects) { if (PostToSAP(selectedObject, ios) == -1) { if (GeneralSettings.B1Post) { if (GeneralSettings.oCompany.InTransaction) { GeneralSettings.oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } } ios.Rollback(false); break; } } if (GeneralSettings.B1Post) { if (GeneralSettings.oCompany.InTransaction) { GeneralSettings.oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); } } ios.CommitChanges(); } } RefreshController refreshController = Frame.GetController <RefreshController>(); if (refreshController != null) { refreshController.RefreshAction.DoExecute(); } genCon.showMsg("Successful", "Post to SAP B1 Done.", InformationType.Success); } else { } }