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 WinTable
    {
        /// <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_ETC_STORE_NOTICE_REG)
                {
                    frmRegStorNotice fForm = (frmRegStorNotice)FormManager.GetForm(FormManager.FORM_ETC_STORE_NOTICE_REG);
                    if (fForm == null)
                    {
                        fForm = new frmRegStorNotice();
                        FormManager.AddForm(FormManager.FORM_ETC_STORE_NOTICE_REG, fForm);
                    }
                    DialogResult dReturn = fForm.ShowDialog();
                    sRet = (dReturn == DialogResult.OK ? UserCom.RST_OK : UserCom.RST_ERR);
                }
                else if (aPara[0] == FormManager.FORM_ETC_TABLE_ITEM_MOVE)
                {
                    frmTableItemMove fForm = (frmTableItemMove)FormManager.GetForm(FormManager.FORM_ETC_TABLE_ITEM_MOVE);
                    if (fForm == null)
                    {
                        fForm = new frmTableItemMove();
                        FormManager.AddForm(FormManager.FORM_ETC_TABLE_ITEM_MOVE, fForm);
                    }
                    fForm.FirstSelectedFloorCd = aPara[1];
                    fForm.FirstSelectedTableNo = aPara[2];
                    fForm.SecondSelectedFloorCd = aPara[3];
                    fForm.SecondSelectedTableNo = aPara[4];

                    DialogResult dReturn = fForm.ShowDialog();
                    //sRet = (dReturn == DialogResult.OK ? UserCom.RST_OK : UserCom.RST_ERR);
                    if (dReturn == DialogResult.OK)
                        sRet = UserCom.RST_OK;
                    else if (dReturn == DialogResult.Ignore)
                        sRet = UserCom.RST_IGNORE;
                    else
                        sRet = UserCom.RST_ERR;
                }
                else if (aPara[0] == FormManager.FORM_ETC_TABLE_MEMO)
                {
                    frmKtchMsg fForm = (frmKtchMsg)FormManager.GetForm(FormManager.FORM_ETC_TABLE_MEMO);
                    if (fForm == null)
                    {
                        fForm = new frmKtchMsg();
                        FormManager.AddForm(FormManager.FORM_ETC_TABLE_MEMO, fForm);
                    }
                    fForm.MsgId = aPara[1];
                    if (fForm.MsgId == PosConst.KPS_ORD_MSG_ID.ITEM_MEMO)       // 상품메모
                    {
                        fForm.ItemRow = int.Parse(aPara[2]);
                    }
                    else if (fForm.MsgId == PosConst.KPS_ORD_MSG_ID.SEAT_MEMO)   // 좌석메모
                    {
                        fForm.FloorCd = aPara[2];
                        fForm.TableNo = aPara[3];
                        fForm.TableNm = aPara[4];
                    }
                    else        // FIRE KEY
                    {
                        fForm.ItemRow = int.Parse(aPara[2]);
                    }
                    DialogResult dReturn = fForm.ShowDialog();
                    sRet = (dReturn == DialogResult.OK ? UserCom.RST_OK : UserCom.RST_ERR);
                }
                else if (aPara[0] == FormManager.FORM_ETC_TABLE_MEMO_LIST)
                {
                    frmKitchMsgList fForm = (frmKitchMsgList)FormManager.GetForm(FormManager.FORM_ETC_TABLE_MEMO_LIST);
                    if (fForm == null)
                    {
                        fForm = new frmKitchMsgList();
                        FormManager.AddForm(FormManager.FORM_ETC_TABLE_MEMO_LIST, fForm);
                    }
                    fForm.FloorCd = aPara[1];
                    fForm.FloorNm = aPara[2];
                    fForm.TableNo = aPara[3];
                    fForm.TableNm = aPara[4];
                    DialogResult dReturn = fForm.ShowDialog();
                    sRet = (dReturn == DialogResult.OK ? UserCom.RST_OK : UserCom.RST_ERR);
                }
                else if (aPara[0] == FormManager.FORM_ETC_RESERV_MAIN)
                {
                    frmReservMain fForm = (frmReservMain)FormManager.GetForm(FormManager.FORM_ETC_RESERV_MAIN);
                    if (fForm == null)
                    {
                        fForm = new frmReservMain();
                        FormManager.AddForm(FormManager.FORM_ETC_RESERV_MAIN, fForm);
                    }
                    DialogResult dReturn = fForm.ShowDialog();
                    sRet = (dReturn == DialogResult.OK ? UserCom.RST_OK : UserCom.RST_ERR);
                }
                else if (aPara[0] == FormManager.FORM_ETC_RESERV_REG)
                {
                    frmReservReg fForm = (frmReservReg)FormManager.GetForm(FormManager.FORM_ETC_RESERV_REG);
                    if (fForm == null)
                    {
                        fForm = new frmReservReg();
                        FormManager.AddForm(FormManager.FORM_ETC_RESERV_REG, fForm);
                    }
                    if (aPara.Length == 2)
                    {
                        fForm.RegType = aPara[1];
                    }
                    else if (aPara.Length == 3)
                    {
                        fForm.RegType = aPara[1];
                        fForm.ReservNo = aPara[2];
                    }
                    DialogResult dReturn = fForm.ShowDialog();
                    sRet = (dReturn == DialogResult.OK ? UserCom.RST_OK : UserCom.RST_ERR);
                }
                else if (aPara[0] == FormManager.FORM_MENUAL_ORDER_KPS)
                {
                    // 주방프린터 수동 출력 (장치선택)
                }
                else if (aPara[0] == FormManager.FORM_MENUAL_ORDER_ITEM)
                {
                    // 주방프린터 수동 출력 (상품선택)
                }

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