using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UAS_MES_NEW.PublicMethod;
using UAS_MES_NEW.CustomControl.TextBoxWithIcon;

namespace UAS_MES_NEW.CustomControl.CustomCheckBox
{
    public partial class LockCheckBox : CheckBox
    {
        /// <summary>
        /// 存放工单的控件
        /// </summary>
        MaCodeSearchTextBox MaCtl;

        bool LeaveEvent1;

        public bool LeaveEvent
        {
            get
            {
                return LeaveEvent1;
            }

            set
            {
                LeaveEvent1 = value;
            }
        }

        public LockCheckBox()
        {
            InitializeComponent();
        }

        public void GetMakeCodeCtl(MaCodeSearchTextBox ctl)
        {
            MaCtl = ctl;
        }

        private void LockCheckBox_CheckStateChanged(object sender, EventArgs e)
        {
            if (Checked)
            {
                if (MaCtl.Text != "")
                {
                    string ErrorMessage;
                    if (LogicHandler.CheckMakeStatus(MaCtl.Text, out ErrorMessage))
                        MaCtl.Enabled = false;
                    else
                    {
                        Checked = false;
                        MaCtl.Text = "";
                        BaseUtil.ShowError(ErrorMessage);
                    }
                }
                else
                {
                    Checked = false;
                    MaCtl.Text = "";
                    BaseUtil.ShowError("工单号不能为空");
                }
            }
            else
            {
                MaCtl.Enabled = true;
                MaCtl.Focus();
            }
        }
    }
}