using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

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

namespace Cosmos.Win
{
    public partial class frmSafetyDay : Form
    {
        #region 변수 선언
        private SManager sManager = new SManager();                                 // 이 객체를 통해 업무 Service 호출
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)
        private PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조
        private IDataCommonUs m_cDataCommon = null;                                 // POS 공통함수 인터페이스
        private IDataServiceUs m_cPrepStorNotice = null;                            // 점검리스트 가지고 오기
        private IStoreCheck m_cStoreCheck = null;                                   // 점검리스트 가지고 오기

        /// 상황에 맞는 화면을 띄워주기 위한 설정값
        // 판매준비점검(개점/마감)
        private string m_sSearchInfo = "";
        public string SearchInfo { set { m_sSearchInfo = value; } get { return m_sSearchInfo; } }

        // 점검일자
        private string m_sSaleDateInfo = "";
        public string DateInfo { set { m_sSaleDateInfo = value; } get { return m_sSaleDateInfo; } }

        // 점검코드
        private string m_sCheckCode = "";
        public string CheckCode { set { m_sCheckCode = value; } get { return m_sCheckCode; } }
        #endregion 변수 선언

        #region 생성자 & 소멸자
        public frmSafetyDay()
        {
            InitializeComponent();

            base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
            m_cStoreCheck = (IStoreCheck)sManager.InitServiceInstance(ServiceLists.BSV_OPEN_CLOSE.DLL, ServiceLists.BSV_OPEN_CLOSE.STORE_CHECK);
            //this.UpdateStyles();
        }

        private void frmSafetyDay_Load(object sender, EventArgs e)
        {
            UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "");

            InitControl();  
        }

        private void frmSafetyDay_FormClosing(object sender, FormClosingEventArgs e)
        {
            UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", lblTitle.Text);
        }
        #endregion 생성자 & 소멸자

        #region 폼 컨트롤 초기화
        /// <summary>
        /// 폼 컨트롤 초기화
        /// </summary>
        private void InitControl()
        {
            string sSaleDate = string.Empty;

            try
            {
                DataTable dtData = m_cStoreCheck.StoreNoticeDTL(m_sCheckCode);
                if (dtData == null || dtData.Rows.Count == 0)
                {
                    this.DialogResult = DialogResult.Cancel;
                    this.Close();
                    return;
                }

                FormManager.SetFormAllControlFont(this, m_cPosStatus.Base.FONT);
                FormManager.SetTextBoxGlobalInfo(this, m_cPosStatus.Global.m_stCultureMaster.nGroupingDigits, m_cPosStatus.Global.m_stCultureMaster.strGroupingSymbol
                    , m_cPosStatus.Global.m_stCultureMaster.nDecimalDigits, m_cPosStatus.Global.m_stCultureMaster.strDecimalSymbol);
                FormManager.MovePopUpForm(this, false, m_cPosStatus.Sale.ScreenSizeUser);
                picBack.Image = ImageManager.GetImage(Cosmos.BaseFrame.BaseCom.NxImgPath, ImageManager.POP_SIZE_S);

                btnExit.Text = "";
                btnExit.Enabled = false;

                // 라벨 이름 설정
                lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0766);

                txtMemo01.Text = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0559).Replace("\\r\\n", "\r\n").Replace("\\r", "\r").Replace("\\n", "\n");
                txtMemo02.Text = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0560).Replace("\\r\\n", "\r\n").Replace("\\r", "\r").Replace("\\n", "\n");
                txtMemo03.Text = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0561).Replace("\\r\\n", "\r\n").Replace("\\r", "\r").Replace("\\n", "\n");
            }
            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 폼 컨트롤 초기화

        private void btnPopUp_Click(object sender, EventArgs e)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                sRet = WinOpenClose.ShowForm(new string[] { FormManager.FORM_FOOD_SAFETY_DAY, PosKey.MENU_KEY.FOOD_SAFETY_DAY, PosConst.STORE_CHECK_FLAG.STORE_OPEN_CHECK, m_sSaleDateInfo, m_sCheckCode });
                
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
        }
    }
}
