private void resetButton() { SystemUsers user = (SystemUsers)SecuritySystem.CurrentUser; bool IsPostUser = user.Roles.Where(p => p.Name == GeneralSettings.postrole).Count() > 0 ? true : false; this.PostClaim.Active.SetItemValue("Enabled", false); this.PostClaimV2.Active.SetItemValue("Enabled", false); if (IsPostUser) { if (View.GetType() == typeof(DetailView)) { ClaimTrxs selectedObject = (ClaimTrxs)View.CurrentObject; if (selectedObject.IsNew) { } else { if (selectedObject.IsClosed && !selectedObject.IsPosted) { this.PostClaimV2.Active.SetItemValue("Enabled", true); } } this.PostClaimV2.Enabled.SetItemValue("EditMode", ((DetailView)View).ViewEditMode == ViewEditMode.View); } else if (View is ListView) { //if (View.Id == "ClaimTrxs_ListView_Closed") this.PostClaimV2.Active.SetItemValue("Enabled", true); } } }
private void PostClaimV2_Execute(object sender, PopupWindowShowActionExecuteEventArgs e) { DateParameters p = (DateParameters)e.PopupWindow.View.CurrentObject; if (p.IsErr) { return; } _postdate = p.ParamDate; if (_postdate is null) { genCon.showMsg("Cannot post", "Posting Date is not valid.", InformationType.Error); return; } 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 { } }
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 { } }
private int PostToSAP(ClaimTrxs selectedObject, IObjectSpace ios) { int temp = 0; ClaimTrxs iobj = ios.GetObjectByKey <ClaimTrxs>(selectedObject.Oid); Companies Company = ios.FindObject <Companies>(new BinaryOperator("Oid", selectedObject.Company.Oid, BinaryOperatorType.Equal)); //ShowViewParameters svp = new ShowViewParameters(); //DetailView dv = Application.CreateDetailView(ios, iobj); //dv.ViewEditMode = ViewEditMode.View; //svp.CreatedView = dv; if (iobj.IsClosed && !iobj.IsPosted) { iobj.PaidDate = (DateTime)_postdate; if (GeneralSettings.B1Post) { if (Company.PostToDocument == PostToDocuments.JE) { if (Company.EClaimSAPDoc == EClaimSAPDocs.Document) { temp = genCon.PostJEtoSAP(iobj); } else if (Company.EClaimSAPDoc == EClaimSAPDocs.Draft) { temp = genCon.PostJVtoSAP(iobj); } } else if (Company.PostToDocument == PostToDocuments.APINV) { temp = genCon.PostAPIVtoSAP(iobj); } else { temp = genCon.DelayPostToSAP(iobj); } } if (temp > 0) { if (GeneralSettings.B1Post) { iobj.IsSAPPosted = true; } iobj.SAPKey = temp; iobj.IsClosed = false; iobj.IsPosted = true; ClaimTrxDocStatuses ds = ios.CreateObject <ClaimTrxDocStatuses>(); ds.DocStatus = DocumentStatus.Posted; ds.DocRemarks = ""; iobj.ClaimTrxDocStatus.Add(ds); //iobj.OnPropertyChanged("ClaimTrxDocStatus"); } else if (temp == 0) { } else if (temp == -1) { } } return(temp); }
private void Controller_ObjectCreated(object sender, ObjectCreatedEventArgs e) { ListView lv = ((ListView)View); if (lv.CollectionSource is PropertyCollectionSource) { PropertyCollectionSource collectionSource = (PropertyCollectionSource)lv.CollectionSource; if (collectionSource.MasterObject != null) { int minvalue = -1; int comparevalue = 0; if (View.ObjectTypeInfo.Type == typeof(ClaimTrxDetails)) { if (collectionSource.MasterObjectType == typeof(ClaimTrxs)) { ClaimTrxs masterobject = (ClaimTrxs)collectionSource.MasterObject; ClaimTrxDetails currentobject = (ClaimTrxDetails)e.CreatedObject; if (masterobject.Currency != null) { currentobject.Currency = currentobject.Session.GetObjectByKey <Currencies>(masterobject.Currency.Oid); } currentobject.FCRate = masterobject.FCRate; #region assign oid if (masterobject.ClaimTrxDetail.Count > 0) { comparevalue = masterobject.ClaimTrxDetail.Min(pp => pp.Oid); } if (comparevalue <= minvalue) { minvalue = comparevalue - 1; } currentobject.Oid = minvalue; #endregion } } if (View.ObjectTypeInfo.Type == typeof(ClaimTrxDetailNotes)) { if (collectionSource.MasterObjectType == typeof(ClaimTrxDetails)) { ClaimTrxDetails masterobject = (ClaimTrxDetails)collectionSource.MasterObject; ClaimTrxDetailNotes currentobject = (ClaimTrxDetailNotes)e.CreatedObject; if (masterobject.Currency != null) { currentobject.Currency = currentobject.Session.GetObjectByKey <Currencies>(masterobject.Currency.Oid); currentobject.FCRate = masterobject.FCRate; } else if (masterobject.ClaimTrx != null && masterobject.ClaimTrx.Currency != null) { currentobject.Currency = currentobject.Session.GetObjectByKey <Currencies>(masterobject.ClaimTrx.Currency.Oid); currentobject.FCRate = masterobject.ClaimTrx.FCRate; } else { currentobject.FCRate = masterobject.FCRate; } #region assign oid if (masterobject.ClaimTrxDetailNote.Count > 0) { comparevalue = masterobject.ClaimTrxDetailNote.Min(pp => pp.Oid); } if (comparevalue <= minvalue) { minvalue = comparevalue - 1; } currentobject.Oid = (masterobject.Oid < 0? masterobject.Oid * 100: masterobject.Oid * -100) + minvalue; #endregion } } if (View.ObjectTypeInfo.Type == typeof(ClaimTrxItems)) { if (collectionSource.MasterObjectType == typeof(ClaimTrxs)) { ClaimTrxs masterobject = (ClaimTrxs)collectionSource.MasterObject; ClaimTrxItems currentobject = (ClaimTrxItems)e.CreatedObject; if (masterobject.Currency != null) { currentobject.Currency = currentobject.Session.GetObjectByKey <Currencies>(masterobject.Currency.Oid); } currentobject.FCRate = masterobject.FCRate; #region assign oid if (masterobject.ClaimTrxItem.Count > 0) { comparevalue = masterobject.ClaimTrxItem.Min(pp => pp.Oid); } if (comparevalue <= minvalue) { minvalue = comparevalue - 1; } currentobject.Oid = minvalue; #endregion } } if (View.ObjectTypeInfo.Type == typeof(ClaimTrxMileages)) { if (collectionSource.MasterObjectType == typeof(ClaimTrxs)) { ClaimTrxs masterobject = (ClaimTrxs)collectionSource.MasterObject; ClaimTrxMileages currentobject = (ClaimTrxMileages)e.CreatedObject; #region assign oid if (masterobject.ClaimTrxMileage.Count > 0) { comparevalue = masterobject.ClaimTrxMileage.Min(pp => pp.Oid); } if (comparevalue <= minvalue) { minvalue = comparevalue - 1; } currentobject.Oid = minvalue; #endregion } } if (View.ObjectTypeInfo.Type == typeof(ClaimTrxPostDetails)) { if (collectionSource.MasterObjectType == typeof(ClaimTrxs)) { ClaimTrxs masterobject = (ClaimTrxs)collectionSource.MasterObject; ClaimTrxPostDetails currentobject = (ClaimTrxPostDetails)e.CreatedObject; #region assign oid if (masterobject.ClaimTrxPostDetail.Count > 0) { comparevalue = masterobject.ClaimTrxPostDetail.Min(pp => pp.Oid); } if (comparevalue <= minvalue) { minvalue = comparevalue - 1; } currentobject.Oid = minvalue; #endregion } } } } }