Ejemplo n.º 1
0
        private void Action_API_PatchPurchaseCancel()
        {
            System.Threading.Thread.Sleep(2000);

            // 취소 요청
            rsp = APIController.API_PatchPurchaseCancel(XRfid, this.label_Display.Text);

            // 외부에서 결과 내용 사용하도록 노출
            XApiResponse = rsp;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// RestAPI 호출하여 RFID 확인
        /// </summary>
        private void RestAPI_CheckRFID()
        {
            System.Threading.Thread.Sleep(2000);

            HashLib.IHash      hash   = HashLib.HashFactory.Crypto.CreateSHA256();
            HashLib.HashResult digest = hash.ComputeString(strRfid.ToString(), Encoding.ASCII);
            {
                XstrHashedRFid = digest.ToString().Replace("-", "").ToLower();
            }
            XApiResponse = APIController.API_PostPurchaseId(XstrHashedRFid);

            if (XApiResponse != null && XApiResponse.code == 200)
            {
                apiResult = true;
            }
            else
            {
                apiResult = false;
            }
        }
Ejemplo n.º 3
0
        //========================================
        public FormMain()
        {
            InitializeComponent();
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            // 결제 방식 폼
            mFormPayType = new FormPayType();
            {
                mFormPayType.OnSelectedPayType += OnSelectedPayType;
            }

            // RFID 폼
            mFormRFRead = new FormRFRead();
            {
                mFormRFRead.PageSuccess += OnPageSuccess;
                mFormRFRead.PageCancel  += OnPageCancel;
            }

            // 메뉴 폼
            mFormMenuBoard = new FormMenuBoard();
            {
                mFormMenuBoard.PageSuccess += OnPageSuccess;
                mFormMenuBoard.PageCancel  += OnPageCancel;

                //-----------------------------------
                // 메뉴가 변경되면 프로그램 재시작 필요
                // 메뉴는 프로그램 시작될때 설정됨
                //-----------------------------------
                mCategoryMenus = APIController.API_GetMenus();

                if (mCategoryMenus != null)
                {
                    mFormMenuBoard.XCategoriesAndMenusDictionary = mCategoryMenus.dicCategoryMenus;
                    mFormMenuBoard.ResetForm();
                }
                else
                {
                    MessageBox.Show("DCCaffe 서버로 부터 메뉴 정보를 가져오지 못했습니다.\n\r인터넷 연결을 점검한 후 다시 실행해야 합니다.", "문제 보고", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Application.ExitThread();
                    Environment.Exit(0);
                    return;
                }
            }

            // 결제 완료 폼
            mFormResultOrder = new FormResultOrder();
            {
                mFormResultOrder.PageSuccess += OnPageSuccess;
                mFormResultOrder.PageCancel  += OnPageCancel;
            }

            // 취소 키패드 폼
            mFormKeyPad = new FormKeyPad();
            {
                mFormKeyPad.PageSuccess += OnPageSuccess;
                mFormKeyPad.PageCancel  += OnPageCancel;
            }

            // 취소 완료 폼
            mFormResultCancel = new FormResultCancel();
            {
                mFormResultCancel.PageSuccess += OnPageSuccess;
                mFormResultCancel.PageCancel  += OnPageCancel;
            }

            // 내역 조회 완료 폼
            mFormResultInquery = new FormResultInquery();
            {
                mFormResultInquery.PageSuccess += OnPageSuccess;
                mFormResultInquery.PageCancel  += OnPageCancel;
            }

            // 판넬에 페이지 추가
            AddForms2Panel(mFormPayType);
            AddForms2Panel(mFormRFRead);
            AddForms2Panel(mFormMenuBoard);
            AddForms2Panel(mFormResultOrder);
            AddForms2Panel(mFormKeyPad);
            AddForms2Panel(mFormResultCancel);
            AddForms2Panel(mFormResultInquery);

            // 시작 페이지 보이기
            DisplayPage(nameof(FormPayType));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 개별 페이지들의 성공 이벤트
        /// 다음 페이지 이동 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        ///
        ///================================================================================
        /// 월말 공제 프로세스 시작
        /// FormPayType -> FormRFReader -> FormMenuBoard -> FormResultOrder -> FormPayType
        ///
        /// 손님 결제 프로세스 시작
        /// FormPayType -> FormRFReader -> FormMenuBoard -> FormResultOrder -> FormPayType
        ///
        /// 주문 취소
        /// FormPayType -> FormRFReader -> FormKeyPad -> FormResultCancle -> FormPayType
        ///
        /// 사용자 이용 내역 조회
        /// FormPayType -> FormRFReader -> FormResultInquery -> FormPayType
        ///================================================================================
        private void OnPageSuccess(object sender, EventArgs e)
        {
            //------------------
            // from FormRFReader
            //------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormRFRead.ToString()) == 0)
            {
                // 현재 사용자 인증 정보 임시 저장
                {
                    this.mRFID      = mFormRFRead.XstrHashedRFid;
                    this.mName      = mFormRFRead.XApiResponse.name;
                    this.mCompany   = mFormRFRead.XApiResponse.company;
                    this.mReceiptId = mFormRFRead.XApiResponse.receipt_id; // new receipt id
                }

                // 다음 페이지 화면 보이기
                string nextPageName = NextPage(this.mCurrentPayType, PAGES.FormRFRead);
                {
                    if (nextPageName == PAGES.FormMenuBoard.ToString())
                    {
                        mFormMenuBoard.XCompany   = mCompany;
                        mFormMenuBoard.XName      = mName;
                        mFormMenuBoard.XPayType   = mCurrentPayType;
                        mFormMenuBoard.XReceiptId = mReceiptId;
                        mFormMenuBoard.ResetForm();
                    }
                    else if (nextPageName == PAGES.FormKeyPad.ToString())
                    {
                        mFormKeyPad.XCompany = mCompany;
                        mFormKeyPad.XName    = mName;
                        mFormKeyPad.XRfid    = mRFID;
                        mFormKeyPad.ResetForm();
                    }
                    else if (nextPageName == PAGES.FormResultInquery.ToString())
                    {
                        mFormResultInquery.XCompany   = mCompany;
                        mFormResultInquery.XName      = mName;
                        mFormResultInquery.XReceiptId = mReceiptId;

                        //----------------------------------------------
                        // 사용자 사용내역 URI 가져와서 QRCod Image 만들기
                        //----------------------------------------------
                        DateTime afterDt  = DateTime.Now;
                        DateTime beforeDt = new DateTime(afterDt.Year, afterDt.Month, 1);

                        long beforeTimestamp = Utilities.TimeStamp.getUnixTimeStamp(beforeDt);
                        long afterTimestamp  = Utilities.TimeStamp.getUnixTimeStamp(afterDt);

                        //-------------------------------------------------
                        DTOPurchaseHistoryOnetimeURLResponse _rsp =
                            APIController.API_PostPurchaseHistoryOnetimeURL(mRFID, beforeTimestamp, afterTimestamp);

                        if (_rsp.code == 200)
                        {
                            mFormResultInquery.XBitmapQRCode = Utilities.QRCode.GetQRCodeBitmap(_rsp.uri);
                        }
                        else
                        {
                            mFormResultInquery.XBitmapQRCode = null;
                        }
                        //-------------------------------------------------

                        mFormResultInquery.ResetForm();
                    }
                }
                DisplayPage(nextPageName);
            }

            //--------------------
            // from FormMenuBoard
            //--------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormMenuBoard.ToString()) == 0)
            {
                string nextPageName = NextPage(this.mCurrentPayType, PAGES.FormMenuBoard);
                {
                    mFormResultOrder.XCompany = mCompany;
                    mFormResultOrder.XName    = mName;
                    mFormResultOrder.XPayType = mCurrentPayType;
                    mFormResultOrder.ResetForm();
                }
                DisplayPage(nextPageName);
            }

            //---------------------
            // from FormResultOrder
            //---------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormResultOrder.ToString()) == 0)
            {
                string nextPageName = NextPage(this.mCurrentPayType, PAGES.FormResultOrder);
                DisplayPage(nextPageName);
            }

            //------------------
            // from FormKeyPad
            //------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormKeyPad.ToString()) == 0)
            {
                string nextPageName = NextPage(this.mCurrentPayType, PAGES.FormKeyPad);
                {
                    mFormResultCancel.XCompany       = mCompany;
                    mFormResultCancel.XName          = mName;
                    mFormResultCancel.XReceiptId     = mFormKeyPad.XApiResponse.receipt_id;
                    mFormResultCancel.XPurchasedDate = mFormKeyPad.XApiResponse.purchased_date;
                    mFormResultCancel.ResetForm();
                }
                DisplayPage(nextPageName);
            }

            //-----------------------
            // from FormResultCancel
            //-----------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormResultCancel.ToString()) == 0)
            {
                // nothing ...
            }

            //------------------------
            // from FormResultInquery
            //------------------------
            if ((sender.GetType()).Name.CompareTo(PAGES.FormResultInquery.ToString()) == 0)
            {
                // nothing ...
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 주문 완료 버튼 클릭
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnOkButton(object sender, EventArgs e)
        {
            //-------------------------------------------------------------------------------------
            using (FormMessageBox dlg = new FormMessageBox())
            {
                {
                    dlg.Left        = 1430;
                    dlg.Top         = this.Location.X + (ClientSize.Height / 2) - 100;
                    dlg.XColorTitle = Color.FromArgb(73, 156, 188);
                }
                DialogResult dlgResult =
                    dlg.ShowDialog(@"구매를 완료 하시겠습니까?", @"최종 확인", CustomMessageBoxButtons.YesNo);

                if (dlgResult == DialogResult.Yes)
                {
                    //-----------------------------------------------------------------------------
                    // 영수증 프린터 연결 확인
                    //if (!ReceiptController.Instance.ConnectToUSB()) // 영수증 프린터 연결 실패
                    if (ReceiptController.Instance.GetStatus() != PRINT_STATUS.BXL_STS_CASHDRAWER_HIGH)
                    {
                        using (FormMessageBox dlgPrint = new FormMessageBox())
                        {
                            {
                                dlgPrint.Left        = 1430;
                                dlgPrint.Top         = this.Location.X + (ClientSize.Height / 2) - 100;
                                dlgPrint.XColorTitle = Color.FromArgb(73, 156, 188);
                            }

                            PRINT_STATUS printStatus = ReceiptController.Instance.GetStatus();

                            DialogResult dlgPrintResult =
                                dlgPrint.ShowDialog(@"영수증 프린터를 점검해 주세요." + Environment.NewLine + printStatus.ToString(), @"영수증 프린터 점검", CustomMessageBoxButtons.OK);
                        }
                        return;
                    }

                    //-----------------------------------------------------------------------------
                    // 구매 확정 API 호출
                    DTOPurchasesRequest  _req = GetDTOPurchaseRequest();
                    DTOPurchasesResponse _rsp = APIController.API_PostPurchaseSuccess(XReceiptId.ToString(), _req);
                    //-----------------------------------------------------------------------------

                    if (_rsp.code == 200)
                    {
                        // 영수증 출력
                        string _strUserInfo  = string.Format("{0}님 ({1})", XName, XCompany);
                        string _strPayType   = "";
                        string _totalPayment = "0";
                        if (XPayType == PAY_TYPE.MonthlyDeduction)
                        {
                            _strPayType = "월말공제";

                            // 결제 총액 계산
                            _totalPayment = (_rsp.total_price - _rsp.total_dc_price).ToString("N0");
                        }
                        else if (XPayType == PAY_TYPE.CustomerPayment)
                        {
                            _strPayType = "손님결제";

                            // 손님결제일 경우, 영수증 결제 총액을 0원으로 표시
                            _totalPayment = "0";
                        }


                        string             _strCurrentDateTime = Utilities.DateTimeFormatString.getNowDateTimeFormatString();
                        List <VOPrintMenu> _printMenuList      = GetPurchasePrintObject();

                        ReceiptController.Instance.Print(
                            _strUserInfo,
                            XReceiptId.ToString(),
                            _strPayType,
                            _printMenuList,
                            _strCurrentDateTime,
                            _rsp.total_price.ToString("N0"),        // 구매 총액
                            _rsp.total_dc_price.ToString("N0"),     // 할인 총액
                            _totalPayment                           // 결제 총액
                            );

                        // 완료
                        OnPageSuccess();
                    }
                    else
                    {
                        //-------------------------------------------------------------------------
                        using (FormMessageBox dlg1 = new FormMessageBox())
                        {
                            {
                                dlg1.Left        = 1430;
                                dlg1.Top         = this.Location.X + (ClientSize.Height / 2) - 100;
                                dlg1.XColorTitle = Color.FromArgb(73, 156, 188);
                            }
                            DialogResult dlgResult1 =
                                dlg.ShowDialog(@"구매 처리를 완료하지 못했습니다." + Environment.NewLine + _rsp.reason, @"구매 확정 처리 결과", CustomMessageBoxButtons.OK);
                        }//using
                    }
                }
            }//using
        }