Example #1
0
        private Boolean SaveData(String approveFlag)
        {
            if (!CHelper.VerifyAccessRight("PURCHASE_PO_EDIT"))
            {
                return(false);
            }

            if (approveFlag.Equals("Y"))
            {
                Boolean result = SaveToView();
                if (!result)
                {
                    return(false);
                }

                CUtil.EnableForm(false, this);

                CTable t = approveAccountDocWrapper();

                CUtil.EnableForm(true, this);
                if (t != null)
                {
                    actualView.DocumentStatus = ((int)PoDocumentStatus.PoApproved).ToString();
                    if (Mode.Equals("A"))
                    {
                        vw.SetDbObject(t);
                        vw.NotifyAllPropertiesChanged();
                        createdID = vw.AuxilaryDocID;

                        parentItemsSource.Insert(0, vw);
                    }
                    else if (Mode.Equals("E"))
                    {
                        actualView.SetDbObject(t);
                        actualView.NotifyAllPropertiesChanged();
                    }

                    vw.IsModified = false;
                    this.Close();
                }
            }
            else
            {
                if (!SaveToView())
                {
                    return(false);
                }

                CUtil.EnableForm(false, this);
                vw.DocumentType = ((int)docType).ToString();
                CTable newobj = OnixWebServiceAPI.SubmitObjectAPI("SaveAuxilaryDoc", vw.GetDbObject());
                CUtil.EnableForm(true, this);

                if (newobj != null)
                {
                    if (Mode.Equals("A"))
                    {
                        vw.SetDbObject(newobj);
                        parentItemsSource.Insert(0, vw);
                    }
                    else
                    {
                        actualView.SetDbObject(newobj);
                        actualView.NotifyAllPropertiesChanged();
                    }

                    return(true);
                }

                //Error here
                CHelper.ShowErorMessage(OnixWebServiceAPI.GetLastErrorDescription(), "ERROR_USER_ADD", null);
                return(false);
            }

            return(false);
        }