using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Windows.Forms;
using System.IO;
using System.Data;

using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;

using Cosmos.UI;
using System.Drawing;

namespace Cosmos.Win
{
    public class WinSale
    {
        #region FORM 화면 표시
        /// <summary>
        /// FORM 화면 표시
        /// </summary>
        /// <param name="aPara"></param>
        /// <returns></returns>
        public static string ShowForm(string[] aPara)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                if (aPara[0] == FormManager.FORM_SAL_MAIN)
                {
                    // 판매 화면
                    frmSaleMain fForm = (frmSaleMain)FormManager.GetForm(FormManager.FORM_SAL_MAIN);
                    if (fForm == null)
                    {
                        fForm = new frmSaleMain();
                        FormManager.AddForm(FormManager.FORM_SAL_MAIN, fForm);
                    }
                    // FormDisplayTricker 사용을 위한 수정(CHOCY-20160701)
                    if(aPara.Length > 1)
                    {
                        fForm.SetSaleMainCaller = aPara[1];
                    }
                    else
                    {
                        fForm.SetSaleMainCaller = string.Empty;
                    }
                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                    //fForm.Opacity = 0.99999999;
                    //var activeForm = Form.ActiveForm;
                    //FormDisplayTricker.SetLayer(null);
                    //fForm.TopMost = false;
                    //DialogResult dResult = fForm.ShowDialog(activeForm);
                    //return dResult == DialogResult.OK ? UserCom.RST_OK : UserCom.RST_ERR;
                }
                //else if (aPara[0] == FormManager.FORM_PAY_MAIN)
                //{
                //    // 결제 화면
                //    frmPayMain fForm = (frmPayMain)FormManager.GetForm(FormManager.FORM_PAY_MAIN);
                //    if (fForm == null)
                //    {
                //        fForm = new frmPayMain();
                //        FormManager.AddForm(FormManager.FORM_PAY_MAIN, fForm);
                //    }

                //    fForm.PosMenuKey = aPara[1];
                //    fForm.PosInPutData = aPara[2];
                //    // FormDisplayTricker 사용을 위한 수정(CHOCY-20160701)
                //    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                //    ////fForm.Opacity = 0.99999999;
                //    ////var activeForm = Form.ActiveForm;
                //    //var activeForm = ((Form)(FormManager.GetForm(FormManager.FORM_SAL_MAIN)));
                //    ////FormDisplayTricker.SetLayer(null);
                //    ////activeForm.TopLevel = true;
                //    //fForm.TopMost = false;
                //    //DialogResult dResult = fForm.ShowDialog();
                //    //return dResult == DialogResult.OK ? UserCom.RST_OK : UserCom.RST_ERR;
                //}
                else if(aPara[0] == FormManager.FORM_TBL_REG)
                {
                    frmTableMain fForm = (frmTableMain)FormManager.GetForm(FormManager.FORM_TBL_REG);
                    if (fForm == null)
                    {
                        fForm = new frmTableMain();
                        FormManager.AddForm(FormManager.FORM_TBL_REG, fForm);
                    }
                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_SAL_RETURN_RECEIPT)
                {
                    // 영수증 반품
                    frmRefundRec fForm = (frmRefundRec)FormManager.GetForm(FormManager.FORM_SAL_RETURN_RECEIPT);
                    if (fForm == null)
                    {
                        fForm = new frmRefundRec();
                        FormManager.AddForm(FormManager.FORM_SAL_RETURN_RECEIPT, fForm);
                    }
                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_SAL_HPP_APPROVAL_LATER)
                {
                    // 추후 적립
                    frmHPAfterSave fForm = (frmHPAfterSave)FormManager.GetForm(FormManager.FORM_SAL_HPP_APPROVAL_LATER);
                    if (fForm == null)
                    {
                        fForm = new frmHPAfterSave();
                        FormManager.AddForm(FormManager.FORM_SAL_HPP_APPROVAL_LATER, fForm);
                    }
                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }

                //#16401 해피오더)주문내역 바코드 리딩 시 자동 완료처리 start
                else if (aPara[0] == FormManager.FORM_SAL_HPORD_MSG)
                {
                    // 해피오더 주문자동처리 안내팝업
                    frmHappyOrderMsg fForm = (frmHappyOrderMsg)FormManager.GetForm(FormManager.FORM_SAL_HPORD_MSG);
                    if (fForm == null)
                    {
                        fForm = new frmHappyOrderMsg();
                        FormManager.AddForm(FormManager.FORM_SAL_HPORD_MSG, fForm);
                    }
                    fForm.PosMenuKeyIn = aPara[1];

                    // 주문번호
                    if (aPara.Length > 2)
                    {
                        fForm.HPOrderNo = aPara[2];
                    }
                    else
                    {
                        fForm.HPOrderNo = string.Empty;
                    }
                    // 주문건타입
                    if (aPara.Length > 3)
                    {
                        fForm.HPOrderType = aPara[3];
                    }
                    else
                    {
                        fForm.HPOrderType = string.Empty;
                    }

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                //#16401 해피오더)주문내역 바코드 리딩 시 자동 완료처리 end
                else if (aPara[0] == FormManager.FORM_SAL_HPORD)
                {
                    // 해피오더 주문내역
                    frmHappyOrderList fForm = (frmHappyOrderList)FormManager.GetForm(FormManager.FORM_SAL_HPORD);
                    if (fForm == null)
                    {
                        fForm = new frmHappyOrderList();
                        FormManager.AddForm(FormManager.FORM_SAL_HPORD, fForm);
                    }

                    //#16756 판매POS 해피오더 주문내역 상태 변경 디자인 변경 start
                    //기존
                    //fForm.PosMenuKeyIn = aPara[1];
                    //변경
                    fForm.PosMenuKeyIn = "00";
                    //#16756 판매POS 해피오더 주문내역 상태 변경 디자인 변경 end

                    //#20180126 해피오더 당일픽업 건 보여주기 start,phj
                    if (aPara.Length > 2)
                    {
                        fForm.PicupSearchYN = aPara[2];
                    }
                    else
                    {
                        fForm.PicupSearchYN = string.Empty;
                    }
                    //#20180126 해피오더 당일픽업 건 보여주기 end,phj

                    //#16401 해피오더)주문내역 바코드 리딩 시 자동 완료처리 start
                    if (aPara.Length > 3)
                    {
                        fForm.InPutData = aPara[3];
                    }
                    else
                    {
                        fForm.InPutData = string.Empty;
                    }
                    //#16401 해피오더)주문내역 바코드 리딩 시 자동 완료처리 end

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_SAL_DUTCH_PAY)
                {
                    // 더치페이
                    frmDutchPay fForm = (frmDutchPay)FormManager.GetForm(FormManager.FORM_SAL_DUTCH_PAY);
                    if (fForm == null)
                    {
                        fForm = new frmDutchPay();
                        FormManager.AddForm(FormManager.FORM_SAL_DUTCH_PAY, fForm);
                    }

                    fForm.Paying = aPara[2];
                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                //else if (aPara[0] == FormManager.FORM_SAL_DUTCH_PAY_AMT)
                //{
                //    // 더치페이
                //    frmDutchPayAmt fForm = (frmDutchPayAmt)FormManager.GetForm(FormManager.FORM_SAL_DUTCH_PAY_AMT);
                //    if (fForm == null)
                //    {
                //        fForm = new frmDutchPayAmt();
                //        FormManager.AddForm(FormManager.FORM_SAL_DUTCH_PAY_AMT, fForm);
                //    }

                //    //fForm.Paying = aPara[2];
                //    if (fForm.ShowDialog() == DialogResult.OK) sRet = fForm.PosMenuKeyOut;
                //}
                else if (aPara[0] == FormManager.FORM_SAL_HPORD_POPUP)
                {
                    // 해피오더 POP-UP
                    frmHappyOrderPopup fForm = (frmHappyOrderPopup)FormManager.GetForm(FormManager.FORM_SAL_HPORD_POPUP);
                    if (fForm == null)
                    {
                        fForm = new frmHappyOrderPopup();
                        FormManager.AddForm(FormManager.FORM_SAL_HPORD_POPUP, fForm);
                    }

                    fForm.PosMenuKeyIn = aPara[1];
                    if (fForm.ShowDialog() == DialogResult.OK)
                    {
                        sRet = ProcessHPOrdForm();
                    }
                }
                else if (aPara[0] == FormManager.FORM_SAL_HPORD_BARCODE_REG)
                {
                    // 해피오더 바코드 등록
                    frmHappyOrderBarcodeRegMain fForm = (frmHappyOrderBarcodeRegMain)FormManager.GetForm(FormManager.FORM_SAL_HPORD_BARCODE_REG);
                    if (fForm == null)
                    {
                        fForm = new frmHappyOrderBarcodeRegMain();
                        FormManager.AddForm(FormManager.FORM_SAL_HPORD_BARCODE_REG, fForm);
                    }

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_SAL_HPORD_WEIGHT_PRINT)
                {
                    // 해피오더 중량 출력
                    frmHappyOrderWeightPrint fForm = (frmHappyOrderWeightPrint)FormManager.GetForm(FormManager.FORM_SAL_HPORD_WEIGHT_PRINT);
                    if (fForm == null)
                    {
                        fForm = new frmHappyOrderWeightPrint();
                        FormManager.AddForm(FormManager.FORM_SAL_HPORD_WEIGHT_PRINT, fForm);
                    }

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_SAL_RESERVATION_REG)
                {
                    frmReservedCustInfo fForm = (frmReservedCustInfo)FormManager.GetForm(FormManager.FORM_SAL_RESERVATION_REG);
                    if (fForm == null)
                    {
                        fForm = new frmReservedCustInfo();
                        FormManager.AddForm(FormManager.FORM_SAL_RESERVATION_REG, fForm);
                    }

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_SAL_RESERVATION_FNS)
                {
                    frmReservedFinsh fForm = (frmReservedFinsh)FormManager.GetForm(FormManager.FORM_SAL_RESERVATION_FNS);
                    if (fForm == null)
                    {
                        fForm = new frmReservedFinsh();
                        FormManager.AddForm(FormManager.FORM_SAL_RESERVATION_FNS, fForm);
                    }

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_SAL_RECEIPT_REPRINT)
                {
                    frmReJournal fForm = (frmReJournal)FormManager.GetForm(FormManager.FORM_SAL_RECEIPT_REPRINT);
                    if (fForm == null)
                    {
                        fForm = new frmReJournal();
                        FormManager.AddForm(FormManager.FORM_SAL_RECEIPT_REPRINT, fForm);
                    }

                    fForm.SetCallBiz = aPara[1];

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_DEVICE_STATUS_SEARCH)
                {
                    frmDeviceStatusSearch fForm = (frmDeviceStatusSearch)FormManager.GetForm(FormManager.FORM_DEVICE_STATUS_SEARCH);
                    if (fForm == null)
                    {
                        fForm = new frmDeviceStatusSearch();
                        FormManager.AddForm(FormManager.FORM_DEVICE_STATUS_SEARCH, fForm);
                    }

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_PAY_ONLINE_COUPON_SCH)
                {
                    // 온라인쿠폰 조회
                    frmOnLineCouponSch fForm = (frmOnLineCouponSch)FormManager.GetForm(FormManager.FORM_PAY_ONLINE_COUPON_SCH);
                    if (fForm == null)
                    {
                        fForm = new frmOnLineCouponSch();
                        FormManager.AddForm(FormManager.FORM_PAY_ONLINE_COUPON_SCH, fForm);
                    }

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_HP_SAVE_COMPLETE_MSG)
                {
                    // 해피포인트 적립 안내 메시지
                    frmHpSaveMsg fForm = (frmHpSaveMsg)FormManager.GetForm(FormManager.FORM_HP_SAVE_COMPLETE_MSG);
                    if (fForm == null)
                    {
                        fForm = new frmHpSaveMsg();
                        FormManager.AddForm(FormManager.FORM_HP_SAVE_COMPLETE_MSG, fForm);
                    }
                    fForm.PopUpTitle = aPara[1];
                    fForm.PopUpMessage = aPara[2];
                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }
        #endregion

        #region 거래유형 정의
        /// <summary>
        /// 거래유형 정의
        /// </summary>
        public static void SetTradType(CsmLabel lblStat, Panel pnlTopBg, string sTradeDiv, string sTranKind)
        {
            string tmpStr = string.Empty;

            Color clrTopPnl = Color.FromArgb(34, 34, 34);


            TranStatus m_cTrnStatus = new TranStatus();     //거래정보 참조
            m_cTrnStatus = (TranStatus)((StateServer)StateServer.GetInstance()).TRAN;    //POS 거래정보

            try
            {
                if (sTradeDiv != "") m_cTrnStatus.Head.TradeDiv = sTradeDiv;
                if (sTranKind != "") m_cTrnStatus.Head.TradeKind = sTranKind;

                lblStat.BackColor = Color.FromArgb(24, 24, 24);

                if (m_cTrnStatus.Head.TradeDiv == ItemConst.TRAN_DIV.REFUND)    //반품
                {
                    tmpStr = string.Format("{0}{1}", MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0075), MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0126));
                    lblStat.BackColor = Color.Red;
                    clrTopPnl = Color.FromArgb(245, 10, 10);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.UNDECIDED.RESERVATION_REG)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0077);
                    lblStat.BackColor = Color.FromArgb(88, 25, 161);
                    clrTopPnl = Color.FromArgb(98, 35, 171);

                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.UNDECIDED.RESERVATION_COMPLETE)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0078);
                    lblStat.BackColor = Color.FromArgb(88, 25, 161);
                    clrTopPnl = Color.FromArgb(98, 35, 171);

                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.FORIGN.O2O)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0079);
                    lblStat.BackColor = Color.FromArgb(91, 91, 91);
                    clrTopPnl = Color.FromArgb(101, 101, 101);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.FORIGN.SHOPPINGMALL)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0080);
                    lblStat.BackColor = Color.FromArgb(102, 102, 102);
                    clrTopPnl = Color.FromArgb(112, 112, 112);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.CHARGESALE.CHARGE)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0081);
                    lblStat.BackColor = Color.FromArgb(232, 142, 180);
                    clrTopPnl = Color.FromArgb(242, 152, 190);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.CHARGESALE.REFUND)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0082);
                    lblStat.BackColor = Color.FromArgb(232, 142, 180);
                    clrTopPnl = Color.FromArgb(242, 152, 190);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.CHARGESALE.PREPAID)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0095);
                    lblStat.BackColor = Color.FromArgb(232, 142, 180);
                    clrTopPnl = Color.FromArgb(242, 152, 190);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.CHARGESALE.GIFT)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0083);
                    lblStat.BackColor = Color.FromArgb(151, 151, 151);
                    clrTopPnl = Color.FromArgb(161, 161, 161);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.ETC.LOSS)
                {
                    tmpStr = string.Format("{0}\r\n({1})", MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0084), m_cTrnStatus.Head.LossTitle);
                    lblStat.BackColor = Color.FromArgb(0, 102, 150);
                    clrTopPnl = Color.FromArgb(10, 112, 160);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.RESERVE_FUND)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0085);
                    lblStat.BackColor = Color.FromArgb(246, 141, 31);
                    clrTopPnl = Color.FromArgb(255, 151, 41);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.CLOSING_MONEY)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0086);
                    lblStat.BackColor = Color.FromArgb(246, 141, 31);
                    clrTopPnl = Color.FromArgb(255, 151, 41);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.ETC_STATEMENT)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0087);
                    lblStat.BackColor = Color.FromArgb(246, 141, 31);
                    clrTopPnl = Color.FromArgb(255, 151, 41);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0088);
                    lblStat.BackColor = Color.FromArgb(246, 141, 31);
                    clrTopPnl = Color.FromArgb(255, 151, 41);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0089);
                    lblStat.BackColor = Color.FromArgb(246, 141, 31);
                    clrTopPnl = Color.FromArgb(255, 151, 41);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.LOG.STOP)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0090);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.LOG.HOLD_DEAL)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0091);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.LOG.LOGIN)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0092);
                }
                else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.LOG.LOGOFF)
                {
                    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0093);
                }
                else
                {
                    tmpStr = string.Format("{0}{1}", MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0094), MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0126));
                    //tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0094);
                }

                #region 주석(기존 표시 방식 Ex.정상(매출)
                //if (m_cTrnStatus.Head.TradeDiv == ItemConst.TRAN_DIV.REFUND)    //반품
                //{
                //    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0075);
                //    lblStat.BackColor = Color.Red;
                //}
                //else
                //{
                //    tmpStr = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0076);
                //    lblStat.BackColor = Color.FromArgb(24, 24, 24);
                //}
                //if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.UNDECIDED.RESERVATION_REG)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0077));
                //    lblStat.BackColor = Color.FromArgb(51, 51, 51);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.UNDECIDED.RESERVATION_COMPLETE)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0078));
                //    lblStat.BackColor = Color.FromArgb(51, 51, 51);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.FORIGN.O2O)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0079));
                //    lblStat.BackColor = Color.FromArgb(102, 102, 102);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.FORIGN.SHOPPINGMALL)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0080));
                //    lblStat.BackColor = Color.FromArgb(102, 102, 102);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.CHARGESALE.CHARGE)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0081));
                //    lblStat.BackColor = Color.FromArgb(232, 142, 180);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.CHARGESALE.REFUND)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0082));
                //    lblStat.BackColor = Color.FromArgb(232, 142, 180);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.CHARGESALE.PREPAID)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0095));
                //    lblStat.BackColor = Color.FromArgb(232, 142, 180);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.CHARGESALE.GIFT)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0083));
                //    lblStat.BackColor = Color.FromArgb(232, 142, 180);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.ETC.LOSS)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0084));
                //    lblStat.BackColor = Color.FromArgb(0, 102, 150);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.RESERVE_FUND)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0085));
                //    lblStat.BackColor = Color.FromArgb(246, 141, 31);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.CLOSING_MONEY)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0086));
                //    lblStat.BackColor = Color.FromArgb(246, 141, 31);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.ETC_STATEMENT)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0087));
                //    lblStat.BackColor = Color.FromArgb(246, 141, 31);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0088));
                //    lblStat.BackColor = Color.FromArgb(246, 141, 31);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0089));
                //    lblStat.BackColor = Color.FromArgb(246, 141, 31);
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.LOG.STOP)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0090));
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.LOG.HOLD_DEAL)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0091));
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.LOG.LOGIN)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0092));
                //}
                //else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.LOG.LOGOFF)
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0093));
                //}
                //else
                //{
                //    tmpStr = string.Format("{0}({1})", tmpStr, MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0094));
                //}
                #endregion

                pnlTopBg.BackColor = clrTopPnl;

                lblStat.Text = tmpStr;

                if (pnlTopBg != null)
                {
                    foreach (Control c in pnlTopBg.Controls)
                    {
                        if (c is Cosmos.UI.CsmLabel || c is Panel || c is Cosmos.UI.CsmPictureBox)
                        {
                            if (c.Name.Equals("lblSaleStatus") == false && c.Name.Equals("lblOffLine") == false)
                            {
                                c.BackColor = clrTopPnl;
                            }
                            
                        }
                    }
                }


            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            //return tmpStr;
        }
        #endregion

        #region 공통 기능 처리
        /// <summary>
        /// 공통 기능 처리
        /// </summary>
        /// <param name="sMenuKey"></param>
        /// <returns></returns>
        //#20171117 통제, 슈퍼바이저 로그인창 여러번 표시 되는 현상 수정 start
        //기존
        //public static string ExecuteBinessRun(string sMenuKey)
        //변경
        public static string ExecuteBinessRun(string sMenuKey, bool sMenuKeyAuth = false)
        //#20171117 통제, 슈퍼바이저 로그인창 여러번 표시 되는 현상 수정 end
        {
            string sRet = UserCom.RST_OK;
            PosStatus m_cPosStatus = new PosStatus();
            m_cPosStatus = (PosStatus)((StateServer)StateServer.GetInstance()).POS;     //POS 정보

            //#20171117 통제, 슈퍼바이저 로그인창 여러번 표시 되는 현상 수정 start
            //기존
            //if (WinBasic.CheckMenuKeyAuth(sMenuKey) == false) return sRet;      // 기능키 판매원 권한 체크
            //변경
            
            if (sMenuKeyAuth == false)
            {
                if (WinBasic.CheckMenuKeyAuth(sMenuKey) == false) return sRet;      // 기능키 판매원 권한 체크
            }
            
            //#20171117 통제, 슈퍼바이저 로그인창 여러번 표시 되는 현상 수정 end

            //PosStatus m_cPosStatus = new PosStatus();                                   //거래정보 참조
            //m_cPosStatus = (PosStatus)((StateServer)StateServer.GetInstance()).POS;     //POS 정보

            //string sMngAuth = PosMstManager.GetMstPicAuth(m_cPosStatus.Base.CashierNo + sMenuKey);

            //switch(sMngAuth)
            //{
            //    case PosConst.MNG_AUTH_DIV.NON_PERMISSION:
            //        WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0308), MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0505), false);
            //        return UserCom.RST_ERR;
            //    case PosConst.MNG_AUTH_DIV.PERMISSION:
            //        break;
            //    case PosConst.MNG_AUTH_DIV.SUPERVISOR:
            //        if (WinBasic.ShowForm(new string[] { FormManager.FORM_LOG_ON, PosKey.MENU_KEY.REGISTER_ADMIN }) == UserCom.RST_ERR) return UserCom.RST_ERR;
            //        //sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_CASHIER_INPUT, "Supervisor" });
            //        //if (sRet != UserCom.RST_OK)
            //        //{
            //        //    return UserCom.RST_ERR;
            //        //}
            //        break;
            //}

            try
            {
                switch (sMenuKey)
                {
                    case PosKey.MENU_KEY.TOP_MENU_ETC:
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_MENU_SUB, sMenuKey });
                        if (sRet != UserCom.RST_ERR)
                        {
                            sRet = ExecuteBinessRun(sRet);             // 선택된 업무 실행
                        }
                        break;
                    //WEB 메뉴
                    case PosKey.MENU_KEY.TOP_MENU_WEB:
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_MENU_SUB, sMenuKey });
                        if (sRet != UserCom.RST_ERR)
                        {
                            sRet = ExecuteBinessRun(sRet);             // 선택된 업무 실행
                        }
                        break;
                    //case PosKey.MENU_KEY.DLV_CMD_LIST:             //배송지시서
                    //    break;
                    case PosKey.MENU_KEY.FOREIGNERS_RESPONSE:      //외국인 응대
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_SAL_FOREIGNERS_RESPONSE, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.STOR_ARRV_INFO:           //점착정보
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_STOR_ARRV_INFO, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.DEVICE_STATUS_SEARCH:      // 주변장치 상태 조회
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_DEVICE_STATUS_SEARCH, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.SALES_NOTE:               //영업공지사항출력
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_BUSI_NOTICE, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.EMERGENCY_NOTICE:         //긴급공지
                        break;
                    case PosKey.MENU_KEY.WEB_SHPNG_MALL:           //쇼핑몰
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_SHOPPING_MALL, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_ORD_NOTE:             //주문공지
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_ORDER_LIST, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_EMG_NOTE:           //긴급공지
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_EMGNCY_LIST, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_WORK:                 //웹업무
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_LINK, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_EZWELL:               //이지웹
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_EZWELW, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_HP_ORD:               //해피오더
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_HAPPY_ORDER, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_BIZEUN_MALL:          //빚은몰
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_BIZEUN, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_STOR_ARRV_INFO:          //점착정보
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_STOR_ARRV_INFO, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_STOR_ARRV_DETAIL:          //배송추적
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_STOR_ARRV_DETAIL, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_TMPRT:          //온도정보
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_TMPRT, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_SEVERANCE:          //세브란스
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_SEVERANCE, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_MAKE_MENUAL:          //제조메뉴얼
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_MAKE_MENUAL, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.WEB_MONTH_EVENT:          //이달의행사
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_MONTH_EVENT, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.REG_GRP_MENU_CHNG:         // 그룹/메뉴위치변경(상품키관리)
                        sRet = WinBasic.ShowWebPos(sMenuKey);

                        m_cPosStatus.Sale.WebPosAfterDown = "MEMUKEY";
                        //frmWebMasterDown fForm = new frmWebMasterDown();
                        //fForm.PosMenuKey = "MEMUKEY";
                        //fForm.ShowDialog();
                        break;

                    //#15884 해피오더 실시간 추가재고 등록메뉴 및 알람기능 개발 start
                    case PosKey.MENU_KEY.HPO_INVENTORY_ALRAM:
                    //#15884 해피오더 실시간 추가재고 등록메뉴 및 알람기능 개발 end
                    case PosKey.MENU_KEY.OPTION_SETTING:            // POS 옵션설정
                    case PosKey.MENU_KEY.REG_FLOVOR:                // 플레이버관리
                        sRet = WinBasic.ShowWebPos(sMenuKey);
                        break;
                    //case PosKey.MENU_KEY.WEB_POS_PLU_MGR:          // 상품키관리
                    //    sRet = WinBasic.ShowWebPos(sMenuKey);
                    //    break;
                    //case PosKey.MENU_KEY.WEB_POS_SETTING:          //판매POS환경설정
                    //    sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_POS_SETTING, sMenuKey });
                    //    break;
                    //case PosKey.MENU_KEY.WEB_POS_OPTION:          //판매POS옵션설정
                    //    sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_POS_OPTION, sMenuKey });
                    //    break;
                    //case PosKey.MENU_KEY.REG_FLOVOR:          //플레이버관리
                    //    sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_POS_REG_FLOVOR, sMenuKey });
                    //    break;
                    //case PosKey.MENU_KEY.TABLE_MANAGEMENT_MENU:    //매장테이블관리
                    //    sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_POS_TABLE_MANAGEMENT, sMenuKey });
                    //    break;
                    case PosKey.MENU_KEY.REMONEY_AMT:              // 준비금
                        m_cPosStatus = new PosStatus();                                             //거래정보 참조
                        m_cPosStatus = (PosStatus)((StateServer)StateServer.GetInstance()).POS;     //POS 정보
                        if (m_cPosStatus.Base.OpenClose != "0")
                        {
                            sRet = WinOpenClose.ShowForm(new string[] { FormManager.FORM_ACC_REMONEY });
                        }
                        else
                        {
                            WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0185);
                        }
                        break;
                    case PosKey.MENU_KEY.ETC_DPST_WTHDR:           // 기타입출금
                        sRet = WinOpenClose.ShowForm(new string[] { FormManager.FORM_ACC_ETC_INOUT, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.MIDDLE_POS_CLOSE:         // 중간입금
                        sRet = WinOpenClose.ShowForm(new string[] { FormManager.FORM_ACC_SALE_END, sMenuKey, ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT, ItemConst.TRAN_DIV.NORMAL });
                        break;
                    case PosKey.MENU_KEY.MIDDLE_POS_CLOSE_CANCEL:  // 중간입금 취소
                        sRet = WinOpenClose.ShowForm(new string[] { FormManager.FORM_ACC_SALE_END_CAN, sMenuKey, ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT, ItemConst.TRAN_DIV.REFUND });
                        break;
                    case PosKey.MENU_KEY.SALE_CLOSE:                // 마감입금 
                        sRet = WinOpenClose.ShowForm(new string[] { FormManager.FORM_ACC_SALE_END, sMenuKey, ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT, ItemConst.TRAN_DIV.NORMAL });
                        break;
                    case PosKey.MENU_KEY.SALE_CLOSE_CANCEL:         // 마감입금 취소
                        sRet = WinOpenClose.ShowForm(new string[] { FormManager.FORM_ACC_SALE_END_CAN, sMenuKey, ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT, ItemConst.TRAN_DIV.REFUND });
                        break;
                    case PosKey.MENU_KEY.POS_CLOSE_CANCEL:         // 마감취소
                        sRet = WinOpenClose.ShowForm(new string[] { FormManager.FORM_ACC_SALE_END_CAN, sMenuKey, ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT, ItemConst.TRAN_DIV.REFUND });
                        break;
                    case PosKey.MENU_KEY.KITHEN_PRINTER_SETTING:   // 주방프린터설정
                        break;
                    case PosKey.MENU_KEY.KITHEN_PRINTER_CHECK:     // Check of kitchen Printer
                        sRet = KPS_CheckInfo();
                        break;
                    //case PosKey.MENU_KEY.MST_DOWNLOAD:              // MST 다운로드
                    //    break;
                    //case PosKey.MENU_KEY.BILL_SETTING:             // 영수증설정
                    //    break;
                    //case PosKey.MENU_KEY.DEVICE_SETTING:           // 장비설정
                    //    break;
                    case PosKey.MENU_KEY.ENVIRONMENT_SETTING:      // 환경설정
                        {
                            string sFilePath = BaseCom.NxBinPath + "PosConfiguration.exe";

                            if (CmUtil.Exists(sFilePath) == true)
                            {
                                CmUtil.ExecuteWaitProcess(sFilePath, "POS");

                                System.Threading.Thread.Sleep(1000);

                                // 환경설정 파일 읽기
                                SManager sManager = new SManager();        // 이 객체를 통해 업무 Service 호출
                                IServiceUs cReadCfgSrv = (IServiceUs)sManager.InitServiceInstance(ServiceLists.BSV_OPEN_CLOSE.DLL, ServiceLists.BSV_OPEN_CLOSE.READ_CONFIGINFO);
                                cReadCfgSrv.Execute(new string[] { });     // POS 환경설정 파일 읽기
                            }
                            else
                            {
                                WinManager.ErrorMessage("File Not Found!");
                            }
                        }
                        break;
                    //case PosKey.MENU_KEY.SEND_RECV_SETTING:        // 송/수신 설정
                    //    break;
                    //case PosKey.MENU_KEY.DISPLAY_SETTING:          // 화면설정
                    //    break;
                    //case PosKey.MENU_KEY.SHPNG_MALL_SETTING:       // 쇼핑몰설정
                    //    break;

                    //#13753 POS MOT음성 기능 추가 개발요청 start,phj
                    case PosKey.MENU_KEY.SOUND_MOT_SETTING_FORM:     // 음성 MOT 설정        
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_SOUND_MOT_SETTING, sMenuKey });
                        break;
                    //#13753 POS MOT음성 기능 추가 개발요청 end,phj
                    case PosKey.MENU_KEY.ETC_SETTING:              // 기타설정
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_ETC_POS_SETTING, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.SALES_REPORT:             // 매출자료조회
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_SCH_DATA, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.DATA_SEARCH:              // 자료조회
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_SCH_DATA, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.SALE_EMP_SEARCH:          // 담당자별매출조회
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_SCH_DATA, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.RECEIPT_REPRINT:          // 영수증조회
                        sRet = WinSale.ShowForm(new string[] { FormManager.FORM_SAL_RECEIPT_REPRINT, "" });
                        break;
                    case PosKey.MENU_KEY.CARDS_SEARCH:             // 카드승인내역
                        break;
                    case PosKey.MENU_KEY.SHIPMENT_SEARCH:          // 출하/예정내역
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_SCH_SHIPEMNT, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.HP_RATE_REPORT:           // 해피포인트추후적립
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_SCH_HPLATE, sMenuKey });
                        break;
                    //case PosKey.MENU_KEY.CASHBILL_REPORT:          // 현금영수증승인내역
                    //    break;
                    //case PosKey.MENU_KEY.DPST_WTHDR_SEARCH:        // 입출금내역
                    //    break;
                    //case PosKey.MENU_KEY.SHPNG_MALL_SEARCH:        // 쇼핑몰주문정보출력
                    //    break;
                    case PosKey.MENU_KEY.ALIPAY_SEARCH:            // 알리페이인위개입내역
                        break;
                    //case PosKey.MENU_KEY.REG_BOOKMK:               // 즐겨찾기등록
                    //    break;
                    case PosKey.MENU_KEY.REG_IN_OUT:               // 출근/퇴근등록
                        if (CmUtil.IsNull(PosMstManager.GetPosOption(POS_OPTION.OPT307), "1") == "0")
                        {
                            //해당 기능은 POS 옵션에서 미사용으로 되어 있습니다.
                            WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0414);
                        }
                        else
                        {
                            sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_ETC_CHECK_EMP, sMenuKey });
                        }
                        break;
                    case PosKey.MENU_KEY.TMONEY_START:             
                        if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.MOBILECASH_ITEM, ItemConst.TR_ITEM_ID.MOBILECASH.T_MONEY, PosMst.MST_PAY_DC.DATA.USE_YN) == "1")
                        {
                            // TMoney 개시
                            WinAdmin.ShowForm(new string[] { FormManager.FORM_CERTIFY_INTEGRITY_THREAD, PosConst.SCFBA_BIZ_TYPE.OPENSTART, PosConst.POS_CARD_READER_DEVICE_TYPE.TMONEY, PosConst.SCFBA_PROC_TYPE.AUTO, MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0348) });
                            // TMoney 운영정보
                            WinAdmin.ShowForm(new string[] { FormManager.FORM_CERTIFY_INTEGRITY_THREAD, PosConst.SCFBA_BIZ_TYPE.BIZDOWNLOAD, PosConst.POS_CARD_READER_DEVICE_TYPE.TMONEY, PosConst.SCFBA_PROC_TYPE.AUTO, MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0349) });
                        }              
                        if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.MOBILECASH_ITEM, ItemConst.TR_ITEM_ID.MOBILECASH.CASHBEE, PosMst.MST_PAY_DC.DATA.USE_YN) == "1")
                        {
                            // CashBee 개시
                            WinAdmin.ShowForm(new string[] { FormManager.FORM_CERTIFY_INTEGRITY_THREAD, PosConst.SCFBA_BIZ_TYPE.OPENSTART, PosConst.POS_CARD_READER_DEVICE_TYPE.CASHBEE, PosConst.SCFBA_PROC_TYPE.AUTO, MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0359) });
                            // CashBee 운영정보
                            WinAdmin.ShowForm(new string[] { FormManager.FORM_CERTIFY_INTEGRITY_THREAD, PosConst.SCFBA_BIZ_TYPE.BIZDOWNLOAD, PosConst.POS_CARD_READER_DEVICE_TYPE.CASHBEE, PosConst.SCFBA_PROC_TYPE.AUTO, MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0360) });
                        }

                        // PayOn SAM 등록
                        WinAdmin.ShowForm(new string[] { FormManager.FORM_CERTIFY_INTEGRITY_THREAD, PosConst.SCFBA_BIZ_TYPE.OPENSTART, PosConst.POS_CARD_READER_DEVICE_TYPE.PAYON, PosConst.SCFBA_PROC_TYPE.AUTO, MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0350) });

                        break;
                    case PosKey.MENU_KEY.POS_CERTIFY_KEYDOWNLOAD:   // 상호인증
                        //LS_Certify_KeyDownload();
                        break;
                    case PosKey.MENU_KEY.POS_CERTIFY_INTEGRITY:   // 무결성
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_CERTIFY_INTEGRITY, sMenuKey, "", "0" });
                        break;
                    case PosKey.MENU_KEY.REG_EXCHG_RATE:           // 환율등록
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_ETC_EXCHANGE_REG, sMenuKey });
                        break;
                    
                    case PosKey.MENU_KEY.REG_EMP_IN:               // 직원방문등록
                        if (CmUtil.IsNull(PosMstManager.GetPosOption(POS_OPTION.OPT308), "1") == "0")
                        {
                            //해당 기능은 POS 옵션에서 미사용으로 되어 있습니다.
                            WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0414);
                        }
                        else
                        {
                            sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_ETC_INEMP, sMenuKey });
                        }
                        break;
                    case PosKey.MENU_KEY.REG_PVC:                  // PVC상자재고
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_ETC_PVC, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.REG_TABLE:                // 테이블셋팅
                        //sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_POS_TABLE_MANAGEMENT, sMenuKey });
                        {
                            PosStatus cPosStatus = new PosStatus();                                   //거래정보 참조
                            cPosStatus = (PosStatus)((StateServer)StateServer.GetInstance()).POS;     //POS 정보

                            string filePath = BaseCom.NxBinPath + "TableConfiguration.exe";
                            if (CmUtil.Exists(filePath))
                            {
                                CmUtil.ExecuteWaitProcess(filePath, cPosStatus.Base.CashierNo);
                                //CmUtil.ExecuteProcess(filePath, cPosStatus.Base.CashierNo);
                                sRet = UserCom.RST_OK;
                            }
                            else
                            {
                                WinManager.ErrorMessage("File Not Found!");
                                sRet = UserCom.RST_ERR;
                            }
                        }
                        break;
                    case PosKey.MENU_KEY.TEST_MODE:                 // 시험모드
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_TEST_MODE });
                        break;
                    case PosKey.MENU_KEY.TEST_MODE_SEARCH:          // 시험 결과조회
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_TEST_MODE_SEARCH, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.TEST_MODE_PLU_ALL:         // 시험 전체상품교육
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_TEST_EDU_PLU, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.TEST_MODE_PLU_NEW:         // 시험 신상품교육
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_TEST_EDU_PLU, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.TEST_MODE_PLU_SEARCH:      // 상품교육 결과조회
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_TEST_MODE_SEARCH, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.TEST_PLU_SEARCH_ALL:      // 시험 전체상품 조회
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_TEST_PLU_SEARCH, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.TEST_PLU_SEARCH_NEW:      // 시험 신상품 조회
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_TEST_PLU_SEARCH, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.POS_ETC_RECEIPT:          // 간이영수증
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_ETC_RECEIPT, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.SAL_CALC:                  // 계산기
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_SAL_CAL, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.CUSTOMER_CLAIMS_LIST:      // 고객 불만 등록
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_SAL_CUSTOMER_CLAIMS_LIST, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.VISIT_GOVERNMENT_OFFICE:   // 관공서 방문 알림 등록
                        if (WinManager.QuestionMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0183)) == true)
                        {
                            // Form 없이 서비스에서 직접 처리 하기 때문에 여기서만 선언하여 사용한다. 
                            IDataServiceUs m_cVisitGovernment = null;                           // 테스트모드 서비스
                            SManager sManager = new SManager();                                 //이 객체를 통해 업무 Service 호출

                            m_cVisitGovernment = (IDataServiceUs)sManager.InitServiceInstance(ServiceLists.BSV_ADMIN.DLL, ServiceLists.BSV_ADMIN.VISIT_GOVERNMENT);

                            // 전송실패시 재전송 처리
                            while (true)
                            {
                                string sVRet = m_cVisitGovernment.Execute(new string[] { });

                                if (sVRet != UserCom.RST_OK)
                                {
                                    if (WinManager.QuestionMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0215)) != true)
                                    {
                                        // 재전송을 하지 않겠다면 멈춘다.
                                        break;
                                    }
                                }
                                else
                                {
                                    WinManager.ConfirmMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0222));
                                    break;
                                }
                            }

                        }
                        break;
                    case PosKey.MENU_KEY.HAPPY_POINT_SCH:   // 해피포인트 조회
                        sRet = WinPay.ShowForm(new string[] { FormManager.FORM_PAY_POINT_HAPPY_POINT, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.SCH_EVT:   // 행사주문취합내역조회
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_SCH_EVT, sMenuKey });
                        break;
		            case PosKey.MENU_KEY.RETURN_COMPANY:   // 본사반품내역조회
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_SCH_RETURN_COMPAY, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.TRANLOG_DOWNLOAD:   // 매출 자료 수신
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_TRANLOG_DOWNLOAD, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.PGM_DOWNLOAD:      // PGM 다운로드
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_PGM_DOWNLOAD, sMenuKey, "K" });
                        break;
                    case PosKey.MENU_KEY.SCH_KTCH_ORDER:      // 주방주문내역조회
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_SCH_KTCH_ORDER, sMenuKey});
                        break;
                    case PosKey.MENU_KEY.VACCINE_EXE:
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_EXE_VACCINE });
                        break;
                    case PosKey.MENU_KEY.PRINT_INIT:
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_ETC_POS_SETTING });
                        break;
                    case PosKey.MENU_KEY.WEB_SCH_APPROVAL:              // 승인내역조회
                        //sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_SCH_APPROVAL, sMenuKey });
                        sRet = WinBasic.ShowWebPos(PosKey.MENU_KEY.WEB_SCH_APPROVAL);
                        break;
                    case PosKey.MENU_KEY.WEB_MGR_BGM:                  // BGM 관리사이트
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_MGR_BGM, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.BARCODE_PRINT:                  // 바코드 출력
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_BARCODE_PRINT, sMenuKey });
                        // 바코드 출력 함수
                        //LabelBarCodePrint();
                        break;
                    case PosKey.MENU_KEY.SIGNPAD_UPDATE:                  // 서명패드 업데이트
                        if (SignPadOpenCheck() == true)
                        {
                        	sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_SIGNPAD_UPDATE, sMenuKey });
                        }
                        break;
                    case PosKey.MENU_KEY.POS_LOG_SEARCH:                  // 서명패드 업데이트
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_SCH_POS_LOG, sMenuKey });
                        break;
                    case PosKey.MENU_KEY.SIMPLE_LOG_ON:                 // 간편로그인
                        m_cPosStatus = new PosStatus();                                   //거래정보 참조
                        m_cPosStatus = (PosStatus)((StateServer)StateServer.GetInstance()).POS;     //POS 정보
                        if (m_cPosStatus.Sale.SaleFlow == PosConst.SALE_FLOW.SALE_WAIT)
                        {
                            sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_LOG_ON, PosKey.MENU_KEY.SIMPLE_LOG_ON });
                        }
                        break;
                    case PosKey.MENU_KEY.PREP_STOR_NOTICE:               // 준비점검 공지사항
                        //sRet = WinOpenClose.ShowForm(new string[] { FormManager.FORM_SCH_PREP_STOR_NOTICE, PosKey.MENU_KEY.PREP_STOR_NOTICE, "02" });
                        sRet = WinOpenClose.EndStoreCheck(PosConst.POS_CHECK_ALARM_TYPE.CHECK_TYPE_NONE, PosKey.MENU_KEY.PREP_STOR_NOTICE);
                        sRet = WinOpenClose.EndStoreCheck(PosConst.POS_CHECK_ALARM_TYPE.CHECK_TYPE_LOGIN, PosKey.MENU_KEY.PREP_STOR_NOTICE);
                        sRet = WinOpenClose.EndStoreCheck(PosConst.POS_CHECK_ALARM_TYPE.CHECK_TYPE_SOD, PosKey.MENU_KEY.PREP_STOR_NOTICE);
                        sRet = WinOpenClose.EndStoreCheck(PosConst.POS_CHECK_ALARM_TYPE.CHECK_TYPE_EOD, PosKey.MENU_KEY.PREP_STOR_NOTICE);
                        break;
		            case PosKey.MENU_KEY.REMB_ORDER_PRINT:               // 기념일배송 주문정보 출력
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_REMB_ORDER_PRINT, PosKey.MENU_KEY.REMB_ORDER_PRINT });
                        break;
                    case PosKey.MENU_KEY.TRAN_RESEND:                   // 매출재전송
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_TRAN_RESEND });
                        break;
                    case PosKey.MENU_KEY.EX_RESEND_SALE:                // 도로공사 매출재전송
                        sRet = WinAdmin.ShowForm(new string[] { FormManager.FORM_EX_RESEND });
                        break;
                    case PosKey.MENU_KEY.STORE_CHECK_LIST:
                        sRet = WinOpenClose.ShowForm(new string[] { FormManager.FORM_SOD_CHECK, PosKey.MENU_KEY.STORE_CHECK_LIST });
                        break;
                    case PosKey.MENU_KEY.LOG_VIEWER:                    // 로그Viewer
                        sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_SCH_POS_LOG, PosKey.MENU_KEY.LOG_VIEWER });
                        break;
                    case PosKey.MENU_KEY.STORE_EQUIP_CHECK_LIST:              // 일일점검리스트
                        sRet = WinOpenClose.ShowForm(new string[] { FormManager.FORM_STORE_EQUIP_CHECK_LIST, PosKey.MENU_KEY.STORE_EQUIP_CHECK_LIST });
                        break;

                    //#15897 요청)점포생산제품 바코드 출력기능 수정요청 start
                    case PosKey.MENU_KEY.SRM_LABELPRT:      // 점포생산제품 바코드 출력
                        {
                            string sFilePath = BaseCom.NxBinPath + "SRM_PRT.exe";

                            if (CmUtil.Exists(sFilePath) == true)
                            {
                                CmUtil.ExecuteProcess(sFilePath, "");
                                sRet = UserCom.RST_OK;
                            }
                            else
                            {
                                WinManager.ErrorMessage("File Not Found!");
                                sRet = UserCom.RST_ERR;
                            }
                        }
                        break;
                    //#15897 요청)점포생산제품 바코드 출력기능 수정요청 end

                    default:
                        sRet = UserCom.RST_IGNORE;
                        break;
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;

        }
        #endregion

        #region 주방프린트 체크
        /// <summary>
        /// 주방프린트 체크
        /// </summary>
        /// <param name="sFuncKey"></param>
        /// <returns></returns>
        private static string KPS_CheckInfo()
        {
            string sRet = UserCom.RST_ERR;
            //string KtchUseDiv = "";
            try
            {
                //IServiceUs m_KPSCheck = null;                                   //주방프린트 체크 
                //SManager sManager = new SManager();                             // 이 객체를 통해 업무 Service 호출
                //DataTable dtData = new DataTable();
                //m_KPSCheck = (IServiceUs)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.KPS_CHECK);
                //sRet = m_KPSCheck.Execute(new string[] { });


                sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_KPS_CHECK });
                

                return sRet;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }
        #endregion 

        #region 교통카드 개시
        /// <summary>
        /// 교통카드 개시 
        /// </summary>
        /// <param name="sCardType"></param>
        private static void LS_TMoneyOpen(string sCardType)
        {
            SManager sManager = new SManager();                                 //이 객체를 통해 업무 Service 호출
            PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조
            StateServer StateObject = (StateServer)StateServer.GetInstance();

            m_cPosStatus = (PosStatus)StateObject.POS;              //POS 기본정보

            string sPayDCGrpCD = "";
            string sPayDcCd = "";
            try
            {
                ISignPadUs m_cDeviceSignPad = (ISignPadUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_SIGNPAD);

                // 구분 T:TMoney, E:CashBee
                sPayDCGrpCD = ItemConst.TR_ITEM_ID.MOBILECASH_ITEM;
                sPayDcCd = ItemConst.TR_ITEM_ID.MOBILECASH.T_MONEY;
                if (sCardType == "E")
                    sPayDcCd = ItemConst.TR_ITEM_ID.MOBILECASH.CASHBEE;

                string sApprID = PosMstManager.GetMstVan(sPayDCGrpCD, sPayDcCd, PosMst.MST_VAN.DATA.APPR_ID);
                string sBizNM = PosMstManager.GetMstVan(sPayDCGrpCD, sPayDcCd, PosMst.MST_VAN.DATA.CMP_APPR_ID);

                string sRet = m_cDeviceSignPad.TMoneyOpen(sApprID, sBizNM, m_cPosStatus.Base.MsgSeqNo, sCardType);

                if (sRet != UserCom.RST_OK) 
                {
                    if (sCardType == "T") WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0322);
                    if (sCardType == "E") WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0323);
                    if (sCardType == "Y") WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0343);
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);

            }
        }
        #endregion

	    #region 서명패드 체크
        /// <summary>
        /// 상호인증
        /// </summary>
        /// <returns></returns>
        private static bool SignPadOpenCheck()
        {
            bool lRet = false;

            SManager sManager = new SManager();                                 //이 객체를 통해 업무 Service 호출
            PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조
            StateServer StateObject = (StateServer)StateServer.GetInstance();
            ISignPadUs m_cDeviceSignPad = null;                       // 서명패드

            m_cPosStatus = (PosStatus)StateObject.POS;              //POS 기본정보

            m_cDeviceSignPad = (ISignPadUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_SIGNPAD);

            //lRet = m_cDeviceSignPad.OpenDevice(m_cPosStatus.Base.OlePosSignPadSerialPortNumber, m_cPosStatus.Base.OlePosSignPadSerialBaudRate);
            //if (lRet != true)
            //{
            //    WinManager.ErrorMessage("서명패드 연결상태를 확인해 주십시오");
            //    return false;
            //}

            return true;
        }
        #endregion

        #region 해피오더 폼 처리
        public static string ProcessHPOrdForm()
        {
            string sRet = UserCom.RST_ERR;
            PosStatus cPosStatus = new PosStatus();
            cPosStatus = (PosStatus)((StateServer)StateServer.GetInstance()).POS;     //POS 정보

            try
            {
                switch(cPosStatus.Base.HappyOrderMode)
                {
                    case FormManager.FORM_WEB_HAPPY_ORDER:      // 점주WEB 연결
                        WinBasic.ShowForm(new string[] { FormManager.FORM_WEB_HAPPY_ORDER, PosKey.MENU_KEY.WEB_HP_ORD });
                        break;
                    case FormManager.FORM_SAL_HPORD:            // 해피오더 내역 조회
                        WinSale.ShowForm(new string[] { FormManager.FORM_SAL_HPORD, "01" });
                        break;
                    case FormManager.FORM_SAL_MAIN:             // 해피오더 현장결제
                        WinSale.ShowForm(new string[] { FormManager.FORM_SAL_MAIN, PosConst.SAL_MAIN_FORM_CALLER_TYPE.HPORD });
                        break;
                    default:
                        break;
                }
                sRet = UserCom.RST_OK;
            }
            catch(Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }

            return sRet;
        }
        #endregion 해피오더 폼 처리

        ///// <summary>
        ///// 웹 호출
        ///// </summary>
        //private static void WebRun(string sType, string sKeyCode)
        //{
        //    try
        //    {

        //        if (sType == "EXE")
        //        {
        //            CmUtil.ExecuteWaitProcess(BaseCom.NxBinPath + " PosConfiguration.exe");
        //        }
        //        else
        //        {
        //            //WEB 링크 조회
        //            SManager sManager = new SManager();                                 //이 객체를 통해 업무 Service 호출
        //            IDataServiceUs cWebBiz = (IDataServiceUs)sManager.InitServiceInstance(ServiceLists.BSV_BASIC.DLL, ServiceLists.BSV_BASIC.WEB_POS);

        //            if (cWebBiz != null)
        //            {

        //                string sUrl = string.Empty;

        //                sUrl = (string)cWebBiz.GetData(new string[] { sKeyCode });

        //                if (sUrl != UserCom.ERROR && sUrl != null)
        //                {
        //                    System.Diagnostics.Process.Start("iexplore.exe", CmUtil.MidH(sUrl, 31, CmUtil.LenH(sUrl)));
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
        //           System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
        //    }
        //}

    }
}
