Exemplo n.º 1
0
        //Reject Button
        private void Button1_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            if (DocEntry_ODRF > 0)
            {
                SAPbobsCOM.ApprovalRequestsService oApprovalRequestsService = (SAPbobsCOM.ApprovalRequestsService)oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ApprovalRequestsService);
                SAPbobsCOM.ApprovalRequestsParams  oApprovalRequestsParams  = (SAPbobsCOM.ApprovalRequestsParams)oApprovalRequestsService.GetDataInterface(SAPbobsCOM.ApprovalRequestsServiceDataInterfaces.arsApprovalRequestsParams);
                SAPbobsCOM.ApprovalRequest         oApprovalRequest         = (SAPbobsCOM.ApprovalRequest)oApprovalRequestsService.GetDataInterface(SAPbobsCOM.ApprovalRequestsServiceDataInterfaces.arsApprovalRequest);
                SAPbobsCOM.ApprovalRequestParams   oApprovalRequestParams   = (SAPbobsCOM.ApprovalRequestParams)oApprovalRequestsService.GetDataInterface(SAPbobsCOM.ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams);

                oApprovalRequestParams.Code = WddCode;
                //oApprovalRequestsParams = oApprovalRequestsService.GetAllApprovalRequestsList();
                //oApprovalRequestParams = oApprovalRequestsParams.Item(oApprovalRequestsParams.Count - 1);

                //Approve request
                oApprovalRequest = oApprovalRequestsService.GetApprovalRequest(oApprovalRequestParams);
                oApprovalRequest.ApprovalRequestDecisions.Add();
                oApprovalRequest.ApprovalRequestDecisions.Item(0).Remarks = EditText0.Value;
                oApprovalRequest.ApprovalRequestDecisions.Item(0).Status  = SAPbobsCOM.BoApprovalRequestDecisionEnum.ardNotApproved;
                try
                {
                    oApprovalRequestsService.UpdateRequest(oApprovalRequest);
                    oApp.MessageBox("Từ chối phê duyệt thành công");
                }
                catch (Exception ex)
                {
                    oApp.MessageBox(ex.Message);
                }
            }
        }
Exemplo n.º 2
0
        //Approve Button
        private void Button0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            if (DocEntry_ODRF > 0)
            {
                SAPbobsCOM.ApprovalRequestsService oApprovalRequestsService = (SAPbobsCOM.ApprovalRequestsService)oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ApprovalRequestsService);
                SAPbobsCOM.ApprovalRequestsParams  oApprovalRequestsParams  = (SAPbobsCOM.ApprovalRequestsParams)oApprovalRequestsService.GetDataInterface(SAPbobsCOM.ApprovalRequestsServiceDataInterfaces.arsApprovalRequestsParams);
                SAPbobsCOM.ApprovalRequest         oApprovalRequest         = (SAPbobsCOM.ApprovalRequest)oApprovalRequestsService.GetDataInterface(SAPbobsCOM.ApprovalRequestsServiceDataInterfaces.arsApprovalRequest);
                SAPbobsCOM.ApprovalRequestParams   oApprovalRequestParams   = (SAPbobsCOM.ApprovalRequestParams)oApprovalRequestsService.GetDataInterface(SAPbobsCOM.ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams);

                oApprovalRequestParams.Code = WddCode;

                //Approve request
                oApprovalRequest = oApprovalRequestsService.GetApprovalRequest(oApprovalRequestParams);
                oApprovalRequest.ApprovalRequestDecisions.Add();
                oApprovalRequest.ApprovalRequestDecisions.Item(0).Remarks = EditText0.Value;
                oApprovalRequest.ApprovalRequestDecisions.Item(0).Status  = SAPbobsCOM.BoApprovalRequestDecisionEnum.ardApproved;
                try
                {
                    oApprovalRequestsService.UpdateRequest(oApprovalRequest);
                    oApp.MessageBox("Phê duyệt thành công");
                    oApprovalRequest = oApprovalRequestsService.GetApprovalRequest(oApprovalRequestParams);
                    if (oApprovalRequest.Status == SAPbobsCOM.BoApprovalRequestStatusEnum.arsApproved)
                    {
                        try
                        {
                            //Approved Document Add to Valid Document
                            SAPbobsCOM.Documents oDraft = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
                            oDraft.GetByKey(oApprovalRequest.ObjectEntry);
                            int ErrorCode = oDraft.SaveDraftToDocument();
                            if (ErrorCode == 0)
                            {
                                oApp.SetStatusBarMessage("Document added successfully", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                            }
                            else
                            {
                                oApp.SetStatusBarMessage(ErrorCode.ToString() + "|" + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, true);
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                catch (Exception ex)
                {
                    oApp.MessageBox("Phê duyệt không thành công |" + ex.Message);
                }
            }
        }