private Boolean SaveData(String approveFlag) { if (!CHelper.VerifyAccessRight(getAccessRightEdit())) { return(false); } vw.RefDocDate = vw.DocumentDate; vw.DocumentType = ((int)dt).ToString(); vw.ConstructWhDefinitionFromCrDr(); vw.CalculateARAmountForDrCr(); if (approveFlag.Equals("Y")) { Boolean result = SaveToView(); if (!result) { return(false); } CUtil.EnableForm(false, this); CTable t = OnixWebServiceAPI.ApproveAccountDoc(vw.GetDbObject().Clone()); CUtil.EnableForm(true, this); if (t != null) { MInventoryDoc vcd = new MInventoryDoc(t); vcd.InitErrorItem(); if (vcd.ErrorItems.Count > 0) { WinErrorDetails w = new WinErrorDetails(vcd.ErrorItems, "InventoryDoc"); w.Title = CLanguage.getValue("approve_error"); w.ShowDialog(); } else { if (Mode.Equals("A")) { vw.SetDbObject(t); vw.DocumentStatus = ((int)CashDocumentStatus.CashDocApproved).ToString(); (vw as MAccountDoc).NotifyAllPropertiesChanged(); if (itemAddedHandler != null) { itemAddedHandler(vw, null); } else { //Will be obsoleted soon parentItemsSource.Insert(0, vw); } } else if (Mode.Equals("E")) { actualView.SetDbObject(t); actualView.DocumentStatus = ((int)CashDocumentStatus.CashDocApproved).ToString(); (actualView as MAccountDoc).NotifyAllPropertiesChanged(); } vw.IsModified = false; this.Close(); } } } else if (Mode.Equals("A")) { if (SaveToView()) { CUtil.EnableForm(false, this); vw.DocumentStatus = ((int)CashDocumentStatus.CashDocPending).ToString(); CTable newobj = OnixWebServiceAPI.CreateAccountDoc(vw.GetDbObject()); CUtil.EnableForm(true, this); if (newobj != null) { vw.SetDbObject(newobj); if (itemAddedHandler != null) { itemAddedHandler(vw, null); } else { //Will be obsoleted soon parentItemsSource.Insert(0, vw); } return(true); } //Error here CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), "ERROR_USER_ADD", null); return(false); } } else if (Mode.Equals("E")) { if (vw.IsModified) { Boolean result = SaveToView(); if (result) { CUtil.EnableForm(false, this); CTable t = OnixWebServiceAPI.UpdateAccountDoc(vw.GetDbObject()); CUtil.EnableForm(true, this); if (t != null) { actualView.SetDbObject(t); actualView.NotifyAllPropertiesChanged(); return(true); } CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), "ERROR_USER_EDIT", null); } return(false); } return(true); } return(false); }