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

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

namespace Cosmos.Win
{
    public class WinAdmin
    {
        /// <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_TEST_MODE_LIST || aPara[0] == FormManager.FORM_TEST_MODE)
                {
                    // 판매원(캐셔) 등록 화면
                    sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_LOG_ON, PosKey.MENU_KEY.TEST_MODE });
                    //sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_CASHIER_INPUT });
                    if (sRet == UserCom.RST_ERR) return sRet;
                    
                    // 시험모드 시험 리스트 화면
                    frmTestModeList fForm = (frmTestModeList)FormManager.GetForm(FormManager.FORM_TEST_MODE_LIST);
                    if (fForm == null)
                    {
                        fForm = new frmTestModeList();
                        FormManager.AddForm(FormManager.FORM_TEST_MODE_LIST, fForm);
                    }
                    
                    string[] saCshInfo = sRet.Split('|');
                    fForm.CashierNo = saCshInfo[0];
                    fForm.CashierName = saCshInfo[1];
                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                //#13753 POS MOT음성 기능 추가 개발요청 start,phj
                else if (aPara[0] == FormManager.FORM_SOUND_MOT_SETTING)
                {
                    // 음성 MOT 설정
                    frmSoundMotSetting fForm = (frmSoundMotSetting)FormManager.GetForm(FormManager.FORM_SOUND_MOT_SETTING);
                    if (fForm == null)
                    {
                        fForm = new frmSoundMotSetting();
                        FormManager.AddForm(FormManager.FORM_SOUND_MOT_SETTING, fForm);
                    }
                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                //#13753 POS MOT음성 기능 추가 개발요청 end,phj
                else if (aPara[0] == FormManager.FORM_SAL_CUSTOMER_CLAIMS_LIST)
                {
                    frmCustomerClaimsList fForm = (frmCustomerClaimsList)FormManager.GetForm(FormManager.FORM_SAL_CUSTOMER_CLAIMS_LIST);
                    if (fForm == null)
                    {
                        fForm = new frmCustomerClaimsList();
                        FormManager.AddForm(FormManager.FORM_SAL_CUSTOMER_CLAIMS_LIST, fForm);
                    }
                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_SAL_CUSTOMER_CLAIMS_INPUT)
                {
                    frmCustomerClaimInput fForm = (frmCustomerClaimInput)FormManager.GetForm(FormManager.FORM_SAL_CUSTOMER_CLAIMS_INPUT);
                    if (fForm == null)
                    {
                        fForm = new frmCustomerClaimInput();
                        FormManager.AddForm(FormManager.FORM_SAL_CUSTOMER_CLAIMS_INPUT, fForm);
                    }
                    // 수정을 위한 상세값 전달
                    fForm.SearchInfo = aPara[2];

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

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_ETC_PVC)
                {
                    frmEtcPvc fForm = (frmEtcPvc)FormManager.GetForm(FormManager.FORM_ETC_PVC);
                    if (fForm == null)
                    {
                        fForm = new frmEtcPvc();
                        FormManager.AddForm(FormManager.FORM_ETC_PVC, fForm);
                    }
                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_TEST_MODE_SEARCH)
                {
                    // 판매원(캐셔) 등록 화면
                    sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_LOG_ON, PosKey.MENU_KEY.TEST_MODE });
                    //sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_CASHIER_INPUT });
                    if (sRet == UserCom.RST_ERR) return sRet;

                    // 시험 결과조회 화면
                    frmTestModeSearch fForm = (frmTestModeSearch)FormManager.GetForm(FormManager.FORM_TEST_MODE_SEARCH);
                    if (fForm == null)
                    {
                        fForm = new frmTestModeSearch();
                        FormManager.AddForm(FormManager.FORM_TEST_MODE_SEARCH, fForm);
                    }
                    fForm.PosMenuKeyIn = aPara[1];

                    string[] saCshInfo = sRet.Split('|');
                    fForm.CashierNo = saCshInfo[0];
                    fForm.CashierName = saCshInfo[1];
                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_TEST_EDU_PLU)
                {
                    // 판매원(캐셔) 등록 화면
                    sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_LOG_ON, PosKey.MENU_KEY.TEST_MODE });
                    //sRet = WinBasic.ShowForm(new string[] { FormManager.FORM_CASHIER_INPUT });
                    if (sRet == UserCom.RST_ERR) return sRet;

                    // 시험 상품 교육
                    frmTestEduPlu fForm = (frmTestEduPlu)FormManager.GetForm(FormManager.FORM_TEST_EDU_PLU);
                    if (fForm == null)
                    {
                        fForm = new frmTestEduPlu();
                        FormManager.AddForm(FormManager.FORM_TEST_EDU_PLU, fForm);
                    }
                    fForm.PosMenuKeyIn = aPara[1];

                    string[] saCshInfo = sRet.Split('|');
                    fForm.CashierNo = saCshInfo[0];
                    fForm.CashierName = saCshInfo[1];

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_TEST_PLU_SEARCH)
                {
                    // 시험 상품조회
                    frmTestPluSearch fForm = (frmTestPluSearch)FormManager.GetForm(FormManager.FORM_TEST_PLU_SEARCH);
                    if (fForm == null)
                    {
                        fForm = new frmTestPluSearch();
                        FormManager.AddForm(FormManager.FORM_TEST_PLU_SEARCH, fForm);
                    }
                    fForm.PosMenuKeyIn = aPara[1];

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_ETC_INEMP)
                {
                    // 직원방문등록
                    frmEtcInEMP fForm = (frmEtcInEMP)FormManager.GetForm(FormManager.FORM_ETC_INEMP);
                    if (fForm == null)
                    {
                        fForm = new frmEtcInEMP();
                        FormManager.AddForm(FormManager.FORM_ETC_INEMP, fForm);
                    }
                    //fForm.PosMenuKeyIn = aPara[1];

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_ETC_POS_SETTING)
                {
                    // 기타설정
                    frmEtcSetting fForm = (frmEtcSetting)FormManager.GetForm(FormManager.FORM_ETC_POS_SETTING);
                    if (fForm == null)
                    {
                        fForm = new frmEtcSetting();
                        FormManager.AddForm(FormManager.FORM_ETC_POS_SETTING, fForm);
                    }
                    //fForm.PosMenuKeyIn = aPara[1];

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_SCH_DATA || aPara[0] == FormManager.FORM_SCH_SALE_DATA)
                {
                    // 자료조회, 매출자료 조회
                    frmDataSearch fForm = (frmDataSearch)FormManager.GetForm(FormManager.FORM_SCH_DATA);
                    if (fForm == null)
                    {
                        fForm = new frmDataSearch();
                        FormManager.AddForm(FormManager.FORM_SCH_DATA, fForm);
                    }
                    fForm.SetPosMenuKey = aPara[1];

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_BUSI_NOTICE)
                {
                    // 영업공지사항
                    frmBusiNotice fForm = (frmBusiNotice)FormManager.GetForm(FormManager.FORM_BUSI_NOTICE);
                    if (fForm == null)
                    {
                        fForm = new frmBusiNotice();
                        FormManager.AddForm(FormManager.FORM_BUSI_NOTICE, fForm);
                    }
                    fForm.SetPosMenuKey = 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);
                    }
                    fForm.SetPosMenuKey = aPara[1];

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_CERTIFY_INTEGRITY)
                {
                    // 무결성 관리
                    frmIntegrity fForm = (frmIntegrity)FormManager.GetForm(FormManager.FORM_CERTIFY_INTEGRITY);
                    if (fForm == null)
                    {
                        fForm = new frmIntegrity();
                        FormManager.AddForm(FormManager.FORM_CERTIFY_INTEGRITY, fForm);
                    }
                    fForm.SetPosMenuKey = aPara[1];
                    fForm.SetDeviceType = aPara[2];
                    fForm.SetAutoMode = (aPara[3] == "1" ? true : false);

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_TRAN_RESEND)
                {
                    // 매출 재전송
                    frmTranResend fForm = (frmTranResend)FormManager.GetForm(FormManager.FORM_TRAN_RESEND);
                    if(fForm == null)
                    {
                        fForm = new frmTranResend();
                        FormManager.AddForm(FormManager.FORM_TRAN_RESEND, fForm);
                    }
                    fForm.SetPosMenuKey = PosKey.MENU_KEY.TRAN_RESEND;

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_EX_RESEND)
                {
                    // 도로공사 매출 재전송
                    frmTranResend fForm = (frmTranResend)FormManager.GetForm(FormManager.FORM_TRAN_RESEND);
                    if (fForm == null)
                    {
                        fForm = new frmTranResend();
                        FormManager.AddForm(FormManager.FORM_TRAN_RESEND, fForm);
                    }
                    fForm.SetPosMenuKey = PosKey.MENU_KEY.EX_RESEND_SALE;

                    if (fForm.ShowDialog() == DialogResult.OK) sRet = UserCom.RST_OK;
                }
                else if (aPara[0] == FormManager.FORM_CERTIFY_INTEGRITY_THREAD)
                {
                    // IC리더기/ 서명패트  DLL 쓰래드 처리
                    frmIntegrityThead fForm = (frmIntegrityThead)FormManager.GetForm(FormManager.FORM_CERTIFY_INTEGRITY_THREAD);
                    if (fForm == null)
                    {
                        fForm = new frmIntegrityThead();
                        FormManager.AddForm(FormManager.FORM_CERTIFY_INTEGRITY_THREAD, fForm);
                    }

                    fForm.CheckType = aPara[1];
                    fForm.Device = aPara[2];
                    fForm.AutoMode = aPara[3];
                    fForm.PosMessageStr = aPara[4]; 

                    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;
        }

        
    }
}
