예제 #1
0
        string modifyPOCostAlloc(POOrder pOOrder, POLine pOLine, int purchaseMethod, string nonCoreDO)
        {
            string result    = "";
            string projectNo = "";

            if (nonCoreDO != string.Empty)
            {
                projectNo = nonCoreDO;
            }
            else
            {
                SOLineSplit sOLineSplit = PXSelect <SOLineSplit, Where <SOLineSplit.pONbr, Equal <Required <SOLineSplit.pONbr> > > > .Select(Base, pOOrder.OrderNbr);

                if (sOLineSplit != null)
                {
                    projectNo = sOLineSplit.OrderNbr.Trim();
                }
                else
                {
                    RQRequisitionOrder rQRequisitionOrder = PXSelect <RQRequisitionOrder,
                                                                      Where <RQRequisitionOrder.orderNbr, Equal <Required <RQRequisitionOrder.orderNbr> >,
                                                                             And <RQRequisitionOrder.orderCategory, Equal <RQOrderCategory.po> > > > .Select(Base, pOOrder.OrderNbr);

                    if (rQRequisitionOrder != null)
                    {
                        string             reqNbr = rQRequisitionOrder.ReqNbr;
                        RQRequisitionOrder poReq  = PXSelect <RQRequisitionOrder,
                                                              Where <RQRequisitionOrder.reqNbr, Equal <Required <RQRequisitionOrder.reqNbr> >,
                                                                     And <RQRequisitionOrder.orderCategory, Equal <RQOrderCategory.so>,
                                                                          And <RQRequisitionOrder.orderType, Equal <SOOrderTypeConstants.salesOrder> > > > > .Select(Base, reqNbr);

                        if (poReq != null)
                        {
                            projectNo = poReq.OrderNbr.Trim();
                        }
                    }
                }
            }


            PLNSC.ScreenService.OperationContext screenContext = new PLNSC.ScreenService.OperationContext()
            {
                district     = "SC01",
                position     = "INTPO",
                maxInstances = 1
            };

            ScreenService screenService = new ScreenService()
            {
                Timeout = sessionTimeout,
                Url     = $"{urlPrefix(dbName)}ScreenService"
            };
            ScreenDTO screenReply = new ScreenDTO();
            ScreenSubmitRequestDTO submitRequest = new ScreenSubmitRequestDTO();

            bool   loggedIn      = false;
            bool   modifyFlag    = false;
            string screenName    = "";
            string errMess       = "";
            string currentCursor = "";

            try
            {
                ClientConversation.authenticate(userName, password);
                loggedIn = true;
            }
            catch (Exception ex)
            {
                loggedIn = false;
                result   = ex.Message.Trim();
                throw new PXException(ex.Message);
            }

            if (loggedIn)
            {
                try
                {
                    screenReply = screenService.executeScreen(screenContext, "MSO230");
                    screenName  = screenReply.mapName;
                    if (screenName != "MSM230A")
                    {
                        result = CustomMessage.NotMSM220A;
                        throw new PXException(CustomMessage.NotMSM220A);
                    }
                    ScreenNameValueDTO[] fields = { new ScreenNameValueDTO(), new ScreenNameValueDTO() };

                    fields[0].fieldName = "OPTION1I";
                    fields[0].value     = "5";
                    fields[1].fieldName = "PREQ_NO1I";
                    fields[1].value     = pOLine.RQReqNbr;

                    submitRequest.screenFields = fields;

                    submitRequest.screenKey = "1"; // OK
                    screenReply             = screenService.submit(screenContext, submitRequest);
                    screenName = screenReply.mapName;
                    errMess    = screenReply.message;

                    if (errMess.Trim() != "")
                    {
                        result = errMess.Trim();
                        throw new PXException(errMess.Trim());
                    }

                    if (screenName == "MSM232A")
                    {
                        ScreenFieldDTO[] screenReplyFields = screenReply.screenFields;
                        foreach (ScreenFieldDTO screenFieldDto in screenReplyFields)
                        {
                            if (screenFieldDto.fieldName == "WO_PROJECT1I1")
                            {
                                if (screenFieldDto.value != null)
                                {
                                    if (screenFieldDto.value.Trim() != "")
                                    {
                                        return("OK");
                                    }
                                }
                            }
                        }

                        ScreenNameValueDTO[] fields232A = { new ScreenNameValueDTO(), new ScreenNameValueDTO() };

                        fields232A[0].fieldName = "WO_PROJECT1I1";
                        fields232A[0].value     = projectNo;
                        fields232A[1].fieldName = "PROJECT_IND1I1";
                        fields232A[1].value     = "P";

                        submitRequest.screenFields = fields232A;

                        submitRequest.screenKey = "1"; // OK
                        screenReply             = screenService.submit(screenContext, submitRequest);
                        screenName = screenReply.mapName;
                        errMess    = screenReply.message;

                        if (errMess.Trim() != "" && !screenReply.functionKeys.Contains("XMIT-Confirm"))
                        {
                            result = errMess.Trim();
                            throw new PXException(errMess.Trim());
                        }

                        if (screenReply.functionKeys.Contains("XMIT-Confirm"))
                        {
                            submitRequest.screenKey = "1"; // OK
                            screenReply             = screenService.submit(screenContext, submitRequest);
                        }

                        screenName = screenReply.mapName;
                        errMess    = screenReply.message;

                        if (errMess.Trim() != "" && !screenReply.functionKeys.Contains("XMIT-Confirm"))
                        {
                            result = errMess.Trim();
                            throw new PXException(errMess.Trim());
                        }
                        else
                        {
                            result = "OK";
                            screenService.positionToMenu(screenContext);
                        }
                    }
                }
                catch (Exception ex)
                {
                    screenService.positionToMenu(screenContext);
                    throw new PXException(ex.Message);
                }
            }

            return(result);
        }
예제 #2
0
        public virtual IEnumerable createPO(POOrder pOOrder, POLine pOLine)
        {
            RQRequisitionOrder rQRequisitionOrder = PXSelect <RQRequisitionOrder,
                                                              Where <RQRequisitionOrder.orderNbr, Equal <Required <RQRequisitionOrder.orderNbr> >,
                                                                     And <RQRequisitionOrder.orderCategory, Equal <RQOrderCategory.po> > > > .Select(Base, pOOrder.OrderNbr);

            RQRequisition rQRequisition = PXSelect <RQRequisition, Where <RQRequisition.reqNbr, Equal <Required <RQRequisitionOrder.reqNbr> > > > .Select(Base, rQRequisitionOrder.ReqNbr);

            RQRequisitionExt rQRequisitionExt = rQRequisition.GetExtension <RQRequisitionExt>();

            int    purchaseMethod = rQRequisition != null ? rQRequisitionExt.UsrPurchMethod ?? 2 : 2;
            string nonCoreDO      = rQRequisition != null ? rQRequisitionExt.UsrDONbr != null?rQRequisitionExt.UsrDONbr.Trim() : string.Empty : string.Empty;

            string modifyPRResult = string.Empty;

            if (purchaseMethod != 2)
            {
                modifyPRResult = modifyPOCostAlloc(pOOrder, pOLine, purchaseMethod, nonCoreDO);
                if (!modifyPRResult.Trim().Contains("OK"))
                {
                    return(modifyPRResult.Trim());
                }
            }

            PLNSC.ScreenService.OperationContext screenContext = new PLNSC.ScreenService.OperationContext()
            {
                district     = "SC01",
                position     = "INTPO",
                maxInstances = 1
            };

            ScreenService screenService = new ScreenService()
            {
                Timeout = sessionTimeout,
                Url     = $"{urlPrefix(dbName)}ScreenService"
            };
            ScreenDTO screenReply = new ScreenDTO();
            ScreenSubmitRequestDTO submitRequest = new ScreenSubmitRequestDTO();

            bool   loggedIn      = false;
            bool   modifyFlag    = false;
            string screenName    = "";
            string errMess       = "";
            string currentCursor = "";

            try
            {
                ClientConversation.authenticate(userName, password);
                loggedIn = true;
            }
            catch (Exception ex)
            {
                loggedIn = false;
                throw new PXException(ex.Message);
            }

            if (loggedIn)
            {
                try
                {
                    screenReply = screenService.executeScreen(screenContext, "MSO230");
                    screenName  = screenReply.mapName;
                    if (screenName != "MSM230A")
                    {
                        throw new PXException(CustomMessage.NotMSO230);
                    }
                    ScreenNameValueDTO[] fields = { new ScreenNameValueDTO(), new ScreenNameValueDTO(), new ScreenNameValueDTO() };

                    fields[0].fieldName = "OPTION1I";
                    fields[0].value     = "3";
                    fields[1].fieldName = "PREQ_NO1I";
                    fields[1].value     = pOLine.RQReqNbr;
                    fields[2].fieldName = "PREQ_ITEM_NO1I";
                    fields[2].value     = pOLine.RQReqLineNbr.ToString();

                    submitRequest.screenFields = fields;

                    submitRequest.screenKey = "1"; // OK
                    screenReply             = screenService.submit(screenContext, submitRequest);
                    screenName = screenReply.mapName;
                    errMess    = screenReply.message;

                    if (errMess.Trim() != "")
                    {
                        throw new PXException(errMess.Trim());
                    }

                    if (screenName == "MSM23EA")
                    {
                        ScreenFieldDTO[] screenFieldDTOs = screenReply.screenFields;
                        foreach (ScreenFieldDTO screenFieldDTO in screenFieldDTOs)
                        {
                            String fieldName  = screenFieldDTO.fieldName;
                            String preqItemNo = "";
                            if (fieldName == "PREQ_ITEM_NO1I")
                            {
                                preqItemNo = screenFieldDTO.value;
                            }
                        }

                        ScreenNameValueDTO[] field23E = new ScreenNameValueDTO[5];
                        field23E[0]           = new ScreenNameValueDTO();
                        field23E[0].fieldName = "PO_NO1I";
                        field23E[0].value     = pOOrder.OrderNbr.Trim();

                        field23E[1]           = new ScreenNameValueDTO();
                        field23E[1].fieldName = "PO_ITEM1I";
                        field23E[1].value     = pOLine.LineNbr.ToString();

                        field23E[2]           = new ScreenNameValueDTO();
                        field23E[2].fieldName = "PROCESS_ITEM1I";
                        field23E[2].value     = "L";

                        field23E[3]           = new ScreenNameValueDTO();
                        field23E[3].fieldName = "ORDER_DATE1I";
                        field23E[3].value     = DateTime.Now.ToString("yyyyMMdd");

                        field23E[4]           = new ScreenNameValueDTO();
                        field23E[4].fieldName = "PURCH_OFFICER1I";
                        field23E[4].value     = "ADMIN";

                        submitRequest.screenFields = field23E;

                        submitRequest.screenKey = "1"; // OK
                        screenReply             = screenService.submit(screenContext, submitRequest);

                        if (screenReply.functionKeys.Contains("XMIT-Confirm"))
                        {
                            submitRequest.screenKey = "1"; // OK
                            screenReply             = screenService.submit(screenContext, submitRequest);
                        }

                        screenName    = screenReply.mapName;
                        errMess       = screenReply.message;
                        currentCursor = screenReply.currentCursorFieldName;

                        if (errMess.Trim() != "" && !screenReply.functionKeys.Contains("XMIT-Confirm"))
                        {
                            throw new PXException(errMess.Trim());
                        }
                    }
                }
                catch (Exception e)
                {
                    throw new PXException(e.Message);
                }
            }

            return(null);
        }