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

using ITC81DB.Forms;
using ITC81DB.DialogForms;
using ITC81DB_ImageDll;

namespace ITC81DB.Controls
{
    public partial class ControlCenterEquipUserGroupEditor : UserControl
    {
        #region Field
        private FormMenu m_ParentForm;
        #endregion

        #region Constructor
        public ControlCenterEquipUserGroupEditor(FormMenu parent)
        {
            InitializeComponent();

            this.ParentForm = parent;

            this.InitializeDesign();
            this.DefaultSetting();
        } 
        #endregion

        #region Property
        public FormMenu ParentForm
        {
            get { return this.m_ParentForm; }
            private set { this.m_ParentForm = value; }
        }
        #endregion

        #region Method
        public void InitializeDesign()
        {
            Class1 images = new Class1();

            if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English)
            {
                #region 영어
                this.labelTitleMainScreen.Text = "Main screen";
                this.labelTitleProductNo.Text = "Product change";
                this.labelTitleWeightSetting.Text = "Weight settings";
                this.labelTitleClear.Text = "Clear";
                this.labelTitleSubMenu.Text = "Sub menu";

                this.labelTitleBasic.Text = "Basic";
                this.labelTitleTime.Text = "Time setting";
                this.labelTitleProduct.Text = "Product settings";
                this.labelTitleDataBackup.Text = "Data backup";
                this.labelTitleDataStat.Text = "Data stats";

                this.labelTitleConfiguration.Text = "Configuration";
                this.labelTitleSerial.Text = "Serial";
                this.labelTitleEthernet.Text = "Ethernet";
                this.labelTitleCountingOutput.Text = "Counting output";
                this.labelTitleOptionBoard.Text = "Option board(When using options)";

                this.labelTitleSystem.Text = "System";
                this.labelTitleCalibration.Text = "Calibration";
                this.labelTitleJudgment.Text = "Judgment";
                this.labelTitleSorter.Text = "Sorter settings";
                this.labelTitleAutoZero.Text = "Auto zero";
                this.labelTitleIOTest.Text = "I/O test";
                this.labelTitleExternalOutput.Text = "External output";
                this.labelTitleExternalInput.Text = "External input";

                this.labelTitleEquipment.Text = "Equipment";
                this.labelTitleUpdate.Text = "Update";
                this.labelTitleInitialization.Text = "Initialization";
                this.labelTitleFunction.Text = "Feature settings";
                this.labelTitleSystemLog.Text = "System Log";
                this.labelTitleUser.Text = "User settings";
                this.labelTitleEngineer.Text = "Engineer settings";
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
            {
                #region 중국어
                this.labelTitleMainScreen.Text = "主屏幕";
                this.labelTitleProductNo.Text = "产品变化";
                this.labelTitleWeightSetting.Text = "体重设定";
                this.labelTitleClear.Text = "消除";
                this.labelTitleSubMenu.Text = "子菜单";

                this.labelTitleBasic.Text = "基本";
                this.labelTitleTime.Text = "时间设定";
                this.labelTitleProduct.Text = "产品设置";
                this.labelTitleDataBackup.Text = "数据备份";
                this.labelTitleDataStat.Text = "数据统计";

                this.labelTitleConfiguration.Text = "选项";
                this.labelTitleSerial.Text = "串行端口";
                this.labelTitleEthernet.Text = "以太网";
                this.labelTitleCountingOutput.Text = "计数输出";
                this.labelTitleOptionBoard.Text = "选项板(使用选择权时)";

                this.labelTitleSystem.Text = "系统设定";
                this.labelTitleCalibration.Text = "校准";
                this.labelTitleJudgment.Text = "判断设置";
                this.labelTitleSorter.Text = "筛选设定";
                this.labelTitleAutoZero.Text = "自动零点跟踪";
                this.labelTitleIOTest.Text = "I/O测试";
                this.labelTitleExternalOutput.Text = "外部输出";
                this.labelTitleExternalInput.Text = "外部输入";

                this.labelTitleEquipment.Text = "设备设置";
                this.labelTitleUpdate.Text = "更新";
                this.labelTitleInitialization.Text = "工厂初期化";
                this.labelTitleFunction.Text = "功能设定";
                this.labelTitleSystemLog.Text = "系统日志";
                this.labelTitleUser.Text = "用户设置";
                this.labelTitleEngineer.Text = "工程师设置";
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
            {
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
            {
                #region 러시아어
                this.labelTitleMainScreen.Text = "Зернистый";
                this.labelTitleProductNo.Text = "Изменять товар";
                this.labelTitleWeightSetting.Text = "Настройки вектора";
                this.labelTitleClear.Text = "Сброс";
                this.labelTitleSubMenu.Text = "Подменю";

                this.labelTitleBasic.Text = "Основной";
                this.labelTitleTime.Text = "Настройки времени";
                this.labelTitleProduct.Text = "Настройки продукта";
                this.labelTitleDataBackup.Text = "Резервное копирование данных";
                this.labelTitleDataStat.Text = "Статистика данных";

                this.labelTitleConfiguration.Text = "Конфигурация";
                this.labelTitleSerial.Text = "Послед. порт";
                this.labelTitleEthernet.Text = "Локальная сеть";
                this.labelTitleCountingOutput.Text = "Счетный выход";
                this.labelTitleOptionBoard.Text = "Опции(Bei Verwendung)";

                this.labelTitleSystem.Text = "Системные настройки";
                this.labelTitleCalibration.Text = "Калибровка";
                this.labelTitleJudgment.Text = "Настройка отбраковки";
                this.labelTitleSorter.Text = "Настройка сортировки";
                this.labelTitleAutoZero.Text = "Автоотслеживание нуля";
                this.labelTitleIOTest.Text = "Тест ввода/вывода";
                this.labelTitleExternalOutput.Text = "Внешний выход";
                this.labelTitleExternalInput.Text = "Внешний вход";

                this.labelTitleEquipment.Text = "Настройка оборудования";
                this.labelTitleUpdate.Text = "Обновить";
                this.labelTitleInitialization.Text = "Инициализация";
                this.labelTitleFunction.Text = "Функциональные настройки";
                this.labelTitleSystemLog.Text = "Системный журнал";
                this.labelTitleUser.Text = "Настройки пользователя";
                this.labelTitleEngineer.Text = "Инженерные настройки";
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
            {
                #region 독일어
                this.labelTitleMainScreen.Text = "Hauptbildschirm";
                this.labelTitleProductNo.Text = "Warenwechsel";
                this.labelTitleWeightSetting.Text = "Gewichts-Einstellungen";
                this.labelTitleClear.Text = "Löschen";
                this.labelTitleSubMenu.Text = "Untermenü";

                this.labelTitleBasic.Text = "Basic";
                this.labelTitleTime.Text = "Zeiteinstellung";
                this.labelTitleProduct.Text = "Produkteinstellung";
                this.labelTitleDataBackup.Text = "Datensicherung";
                this.labelTitleDataStat.Text = "Statistik";

                this.labelTitleConfiguration.Text = "Konfiguration";
                this.labelTitleSerial.Text = "Kommunikationseinstellung";
                this.labelTitleEthernet.Text = "Ethernet";
                this.labelTitleCountingOutput.Text = "Ausgabe wird gezählt";
                this.labelTitleOptionBoard.Text = "Optionsplatine(Bei Verwendung)";

                this.labelTitleSystem.Text = "Systemeinstellung";
                this.labelTitleCalibration.Text = "Kalibrierung";
                this.labelTitleJudgment.Text = "Tascheneinstellung";
                this.labelTitleSorter.Text = "Sortierereinstellung";
                this.labelTitleAutoZero.Text = "Automatische Nullung";
                this.labelTitleIOTest.Text = "I/O Test";
                this.labelTitleExternalOutput.Text = "Externer Ausgang";
                this.labelTitleExternalInput.Text = "Externer Eingang";

                this.labelTitleEquipment.Text = "Vorrichtungeinstellung";
                this.labelTitleUpdate.Text = "Aktualisierung";
                this.labelTitleInitialization.Text = "Werkseinstellung";
                this.labelTitleFunction.Text = "Funktionseinstellungen";
                this.labelTitleSystemLog.Text = "Systemprotokoll";
                this.labelTitleUser.Text = "Benutzereinstellungen";
                this.labelTitleEngineer.Text = "Ingenieur-Einstellungen";
                #endregion
            }
            else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Spanish)
            {
                #region 스페인어
                this.labelTitleMainScreen.Text = "Pantalla Principal";
                this.labelTitleProductNo.Text = "Cambiar Producto";
                this.labelTitleWeightSetting.Text = "Ajuste de peso";
                this.labelTitleClear.Text = "Borrar";
                this.labelTitleSubMenu.Text = "Sub menu";

                this.labelTitleBasic.Text = "Básico";
                this.labelTitleTime.Text = "Ajuste de tiempo";
                this.labelTitleProduct.Text = "Ajuste de producto";
                this.labelTitleDataBackup.Text = "Copia de seguridad";
                this.labelTitleDataStat.Text = "Estadistica de datos";

                this.labelTitleConfiguration.Text = "Configuración";
                this.labelTitleSerial.Text = "Puesto serial";
                this.labelTitleEthernet.Text = "Ethernet";
                this.labelTitleCountingOutput.Text = "Conteo de salida";
                this.labelTitleOptionBoard.Text = "Tablero opcional";

                this.labelTitleSystem.Text = "Sistema";
                this.labelTitleCalibration.Text = "Calibración";
                this.labelTitleJudgment.Text = "Dictar sentencia";
                this.labelTitleSorter.Text = "Clasificador";
                this.labelTitleAutoZero.Text = "Seguimiento de cero";
                this.labelTitleIOTest.Text = "Test I/O";
                this.labelTitleExternalOutput.Text = "Salida externa";
                this.labelTitleExternalInput.Text = "Salida internet";

                this.labelTitleEquipment.Text = "Equipos";
                this.labelTitleUpdate.Text = "Actualizar";
                this.labelTitleInitialization.Text = "Inicializar";
                this.labelTitleFunction.Text = "Funciones";
                this.labelTitleSystemLog.Text = "Registro del sistema";
                this.labelTitleUser.Text = "Usuario";
                this.labelTitleEngineer.Text = "Ingeniería";
                #endregion
            }
            else
            {
                #region 한국어
                this.labelTitleMainScreen.Text = "메인화면 접근";
                this.labelTitleProductNo.Text = "품번변경";
                this.labelTitleWeightSetting.Text = "중량설정";
                this.labelTitleClear.Text = "소거";
                this.labelTitleSubMenu.Text = "서브메뉴";

                this.labelTitleBasic.Text = "기본";
                this.labelTitleTime.Text = "시간설정";
                this.labelTitleProduct.Text = "품목설정";
                this.labelTitleDataBackup.Text = "데이터백업";
                this.labelTitleDataStat.Text = "데이터집계";

                this.labelTitleConfiguration.Text = "환경";
                this.labelTitleSerial.Text = "시리얼통신";
                this.labelTitleEthernet.Text = "이더넷통신";
                this.labelTitleCountingOutput.Text = "카운터출력";
                this.labelTitleOptionBoard.Text = "옵션보드(옵션 사용 시)";

                this.labelTitleSystem.Text = "시스템";
                this.labelTitleCalibration.Text = "중량조정";
                this.labelTitleJudgment.Text = "판정설정";
                this.labelTitleSorter.Text = "선별기설정";
                this.labelTitleAutoZero.Text = "자동영점";
                this.labelTitleIOTest.Text = "I/O테스트";
                this.labelTitleExternalOutput.Text = "외부출력";
                this.labelTitleExternalInput.Text = "외부입력";

                this.labelTitleEquipment.Text = "장비";
                this.labelTitleUpdate.Text = "업데이트";
                this.labelTitleInitialization.Text = "공장초기화";
                this.labelTitleFunction.Text = "기능설정";
                this.labelTitleSystemLog.Text = "시스템로그";
                this.labelTitleUser.Text = "유저설정";
                this.labelTitleEngineer.Text = "엔지니어설정"; 
                #endregion
            }
        }
        private void DefaultSetting()
        {
        }

        private void UpdateDisplay(UserGroup group)
        {
            #region Level1
            this.checkBoxL1MainClear.Checked = group.Level1.IsMainDisplayClear;
            this.checkBoxL1MainProductNo.Checked = group.Level1.IsMainDisplayProductNo;
            this.checkBoxL1MainSubMenu.Checked = group.Level1.IsMainDisplaySubMenu;
            this.checkBoxL1MainWeightSetting.Checked = group.Level1.IsMainDisplayWeightSetting;

            this.checkBoxL1BasicDataBackup.Checked = group.Level1.IsBasicDataBackup;
            this.checkBoxL1BasicDataStat.Checked = group.Level1.IsBasicDataStatistics;
            this.checkBoxL1BasicProduct.Checked = group.Level1.IsBasicProduct;
            this.checkBoxL1BasicTime.Checked = group.Level1.IsBasicTime;

            this.checkBoxL1ConfigCountingOutput.Checked = group.Level1.IsConfiCountingOutput;
            this.checkBoxL1ConfigEthernet.Checked = group.Level1.IsConfiEthernet;
            this.checkBoxL1ConfigOptionBoard.Checked = group.Level1.IsConfiOptionBoard;
            this.checkBoxL1ConfigSerial.Checked = group.Level1.IsConfiSerial;

            this.checkBoxL1SystemAutoZero.Checked = group.Level1.IsSystemAutoZero;
            this.checkBoxL1SystemCalibration.Checked = group.Level1.IsSystemCalibration;
            this.checkBoxL1SystemExternalInput.Checked = group.Level1.IsSystemExternalInput;
            this.checkBoxL1SystemExternalOutput.Checked = group.Level1.IsSystemExternalOutput;
            this.checkBoxL1SystemIOTest.Checked = group.Level1.IsSystemIOTest;
            this.checkBoxL1SystemJudgment.Checked = group.Level1.IsSystemJudgmentSetting;
            this.checkBoxL1SystemSorter.Checked = group.Level1.IsSystemSorterSetting;

            this.checkBoxL1EquipmentSystemLog.Checked = group.Level1.IsEquipSystemLog;
            this.checkBoxL1EquipmentEngineer.Checked = group.Level1.IsEquipEngineerSetting;
            this.checkBoxL1EquipmentFunction.Checked = group.Level1.IsEquipFunctionSetting;
            this.checkBoxL1EquipmentInitialization.Checked = group.Level1.IsEquipInitialize;
            this.checkBoxL1EquipmentUpdate.Checked = group.Level1.IsEquipUpdate;
            this.checkBoxL1EquipmentUser.Checked = group.Level1.IsEquipUserSetting;
            #endregion

            #region Level2
            this.checkBoxL2MainClear.Checked = group.Level2.IsMainDisplayClear;
            this.checkBoxL2MainProductNo.Checked = group.Level2.IsMainDisplayProductNo;
            this.checkBoxL2MainSubMenu.Checked = group.Level2.IsMainDisplaySubMenu;
            this.checkBoxL2MainWeightSetting.Checked = group.Level2.IsMainDisplayWeightSetting;

            this.checkBoxL2BasicDataBackup.Checked = group.Level2.IsBasicDataBackup;
            this.checkBoxL2BasicDataStat.Checked = group.Level2.IsBasicDataStatistics;
            this.checkBoxL2BasicProduct.Checked = group.Level2.IsBasicProduct;
            this.checkBoxL2BasicTime.Checked = group.Level2.IsBasicTime;

            this.checkBoxL2ConfigCountingOutput.Checked = group.Level2.IsConfiCountingOutput;
            this.checkBoxL2ConfigEthernet.Checked = group.Level2.IsConfiEthernet;
            this.checkBoxL2ConfigOptionBoard.Checked = group.Level2.IsConfiOptionBoard;
            this.checkBoxL2ConfigSerial.Checked = group.Level2.IsConfiSerial;

            this.checkBoxL2SystemAutoZero.Checked = group.Level2.IsSystemAutoZero;
            this.checkBoxL2SystemCalibration.Checked = group.Level2.IsSystemCalibration;
            this.checkBoxL2SystemExternalInput.Checked = group.Level2.IsSystemExternalInput;
            this.checkBoxL2SystemExternalOutput.Checked = group.Level2.IsSystemExternalOutput;
            this.checkBoxL2SystemIOTest.Checked = group.Level2.IsSystemIOTest;
            this.checkBoxL2SystemJudgment.Checked = group.Level2.IsSystemJudgmentSetting;
            this.checkBoxL2SystemSorter.Checked = group.Level2.IsSystemSorterSetting;

            this.checkBoxL2EquipmentSystemLog.Checked = group.Level2.IsEquipSystemLog;
            this.checkBoxL2EquipmentEngineer.Checked = group.Level2.IsEquipEngineerSetting;
            this.checkBoxL2EquipmentFunction.Checked = group.Level2.IsEquipFunctionSetting;
            this.checkBoxL2EquipmentInitialization.Checked = group.Level2.IsEquipInitialize;
            this.checkBoxL2EquipmentUpdate.Checked = group.Level2.IsEquipUpdate;
            this.checkBoxL2EquipmentUser.Checked = group.Level2.IsEquipUserSetting;
            #endregion

            #region Level3
            this.checkBoxL3MainClear.Checked = group.Level3.IsMainDisplayClear;
            this.checkBoxL3MainProductNo.Checked = group.Level3.IsMainDisplayProductNo;
            this.checkBoxL3MainSubMenu.Checked = group.Level3.IsMainDisplaySubMenu;
            this.checkBoxL3MainWeightSetting.Checked = group.Level3.IsMainDisplayWeightSetting;

            this.checkBoxL3BasicDataBackup.Checked = group.Level3.IsBasicDataBackup;
            this.checkBoxL3BasicDataStat.Checked = group.Level3.IsBasicDataStatistics;
            this.checkBoxL3BasicProduct.Checked = group.Level3.IsBasicProduct;
            this.checkBoxL3BasicTime.Checked = group.Level3.IsBasicTime;

            this.checkBoxL3ConfigCountingOutput.Checked = group.Level3.IsConfiCountingOutput;
            this.checkBoxL3ConfigEthernet.Checked = group.Level3.IsConfiEthernet;
            this.checkBoxL3ConfigOptionBoard.Checked = group.Level3.IsConfiOptionBoard;
            this.checkBoxL3ConfigSerial.Checked = group.Level3.IsConfiSerial;

            this.checkBoxL3SystemAutoZero.Checked = group.Level3.IsSystemAutoZero;
            this.checkBoxL3SystemCalibration.Checked = group.Level3.IsSystemCalibration;
            this.checkBoxL3SystemExternalInput.Checked = group.Level3.IsSystemExternalInput;
            this.checkBoxL3SystemExternalOutput.Checked = group.Level3.IsSystemExternalOutput;
            this.checkBoxL3SystemIOTest.Checked = group.Level3.IsSystemIOTest;
            this.checkBoxL3SystemJudgment.Checked = group.Level3.IsSystemJudgmentSetting;
            this.checkBoxL3SystemSorter.Checked = group.Level3.IsSystemSorterSetting;

            this.checkBoxL3EquipmentSystemLog.Checked = true;
            this.checkBoxL3EquipmentEngineer.Checked = group.Level3.IsEquipEngineerSetting;
            this.checkBoxL3EquipmentFunction.Checked = true;
            this.checkBoxL3EquipmentInitialization.Checked = group.Level3.IsEquipInitialize;
            this.checkBoxL3EquipmentUpdate.Checked = group.Level3.IsEquipUpdate;
            this.checkBoxL3EquipmentUser.Checked = true;
            #endregion

            #region Not Login
            this.checkBoxNotLoginMainClear.Checked = group.NotLogin.IsMainDisplayClear;
            this.checkBoxNotLoginMainProductNo.Checked = group.NotLogin.IsMainDisplayProductNo;
            this.checkBoxNotLoginMainSubMenu.Checked = group.NotLogin.IsMainDisplaySubMenu;
            this.checkBoxNotLoginMainWeightSetting.Checked = group.NotLogin.IsMainDisplayWeightSetting;

            this.checkBoxNotLoginBasicDataBackup.Checked = group.NotLogin.IsBasicDataBackup;
            this.checkBoxNotLoginBasicDataStat.Checked = group.NotLogin.IsBasicDataStatistics;
            this.checkBoxNotLoginBasicProduct.Checked = group.NotLogin.IsBasicProduct;
            this.checkBoxNotLoginBasicTime.Checked = group.NotLogin.IsBasicTime;

            this.checkBoxNotLoginConfigCountingOutput.Checked = group.NotLogin.IsConfiCountingOutput;
            this.checkBoxNotLoginConfigEthernet.Checked = group.NotLogin.IsConfiEthernet;
            this.checkBoxNotLoginConfigOptionBoard.Checked = group.NotLogin.IsConfiOptionBoard;
            this.checkBoxNotLoginConfigSerial.Checked = group.NotLogin.IsConfiSerial;

            this.checkBoxNotLoginSystemAutoZero.Checked = group.NotLogin.IsSystemAutoZero;
            this.checkBoxNotLoginSystemCalibration.Checked = group.NotLogin.IsSystemCalibration;
            this.checkBoxNotLoginSystemExternalInput.Checked = group.NotLogin.IsSystemExternalInput;
            this.checkBoxNotLoginSystemExternalOutput.Checked = group.NotLogin.IsSystemExternalOutput;
            this.checkBoxNotLoginSystemIOTest.Checked = group.NotLogin.IsSystemIOTest;
            this.checkBoxNotLoginSystemJudgment.Checked = group.NotLogin.IsSystemJudgmentSetting;
            this.checkBoxNotLoginSystemSorter.Checked = group.NotLogin.IsSystemSorterSetting;

            this.checkBoxNotLoginEquipmentSystemLog.Checked = group.NotLogin.IsEquipSystemLog;
            this.checkBoxNotLoginEquipmentEngineer.Checked = group.NotLogin.IsEquipEngineerSetting;
            this.checkBoxNotLoginEquipmentFunction.Checked = group.NotLogin.IsEquipFunctionSetting;
            this.checkBoxNotLoginEquipmentInitialization.Checked = group.NotLogin.IsEquipInitialize;
            this.checkBoxNotLoginEquipmentUpdate.Checked = group.NotLogin.IsEquipUpdate;
            this.checkBoxNotLoginEquipmentUser.Checked = false;
            #endregion

            if (this.buttonSave.Visible == true)
                this.buttonSave.Visible = false;
        }
        public void UpdateAllMenu(SystemStatus status)
        {         
            this.ParentForm.ParentForm.ChildFormMainDisplay.UpdateMainDisplay(status);

            this.ParentForm.UpdateMenuDisplay(status);

            this.ParentForm.CenterBasicHelp.UpdateMenuDisplay(status);
            this.ParentForm.CenterConfiHelp.UpdateMenuDisplay(status);
            this.ParentForm.CenterEquipHelp.UpdateMenuDisplay(status);
            this.ParentForm.CenterInforHelp.UpdateMenuDisplay(status);
            this.ParentForm.CenterSystemHelp.UpdateMenuDisplay(status);

            this.ParentForm.bottomBasic.UpdateMenuDisplay(status);
            this.ParentForm.bottomConfiguration.UpdateMenuDisplay(status);
            this.ParentForm.bottomEquipment.UpdateMenuDisplay(status);
            this.ParentForm.bottomInformation.UpdateMenuDisplay(status);
            this.ParentForm.bottomSystem.UpdateMenuDisplay(status);
        }

        public void DisplayRefresh(SystemStatus status)
        {
            this.UpdateDisplay(this.ParentForm.ParentForm.CurrentUserGroup);
        }
        #endregion

        #region Event Handler
        private void checkBox_Click(object sender, EventArgs e)
        {
            if (this.buttonSave.Visible == false)
                this.buttonSave.Visible = true;
        }

        private void buttonSave_Click(object sender, EventArgs e)
        {
            #region Level1
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMainDisplayClear = this.checkBoxL1MainClear.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMainDisplayProductNo = this.checkBoxL1MainProductNo.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMainDisplaySubMenu = this.checkBoxL1MainSubMenu.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsMainDisplayWeightSetting = this.checkBoxL1MainWeightSetting.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsBasicDataBackup = this.checkBoxL1BasicDataBackup.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsBasicDataStatistics = this.checkBoxL1BasicDataStat.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsBasicProduct = this.checkBoxL1BasicProduct.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsBasicTime = this.checkBoxL1BasicTime.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiCountingOutput = this.checkBoxL1ConfigCountingOutput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiEthernet = this.checkBoxL1ConfigEthernet.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiOptionBoard = this.checkBoxL1ConfigOptionBoard.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsConfiSerial = this.checkBoxL1ConfigSerial.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemAutoZero = this.checkBoxL1SystemAutoZero.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemCalibration = this.checkBoxL1SystemCalibration.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemExternalInput = this.checkBoxL1SystemExternalInput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemExternalOutput = this.checkBoxL1SystemExternalOutput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemIOTest = this.checkBoxL1SystemIOTest.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemJudgmentSetting = this.checkBoxL1SystemJudgment.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsSystemSorterSetting = this.checkBoxL1SystemSorter.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipEngineerSetting = this.checkBoxL1EquipmentEngineer.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipFunctionSetting = this.checkBoxL1EquipmentFunction.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipInitialize = this.checkBoxL1EquipmentInitialization.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipUpdate = this.checkBoxL1EquipmentUpdate.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipUserSetting = this.checkBoxL1EquipmentUser.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level1.IsEquipSystemLog = this.checkBoxL1EquipmentSystemLog.Checked;
            #endregion

            #region Level2
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMainDisplayClear = this.checkBoxL2MainClear.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMainDisplayProductNo = this.checkBoxL2MainProductNo.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMainDisplaySubMenu = this.checkBoxL2MainSubMenu.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsMainDisplayWeightSetting = this.checkBoxL2MainWeightSetting.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsBasicDataBackup = this.checkBoxL2BasicDataBackup.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsBasicDataStatistics = this.checkBoxL2BasicDataStat.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsBasicProduct = this.checkBoxL2BasicProduct.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsBasicTime = this.checkBoxL2BasicTime.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiCountingOutput = this.checkBoxL2ConfigCountingOutput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiEthernet = this.checkBoxL2ConfigEthernet.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiOptionBoard = this.checkBoxL2ConfigOptionBoard.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsConfiSerial = this.checkBoxL2ConfigSerial.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemAutoZero = this.checkBoxL2SystemAutoZero.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemCalibration = this.checkBoxL2SystemCalibration.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemExternalInput = this.checkBoxL2SystemExternalInput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemExternalOutput = this.checkBoxL2SystemExternalOutput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemIOTest = this.checkBoxL2SystemIOTest.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemJudgmentSetting = this.checkBoxL2SystemJudgment.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsSystemSorterSetting = this.checkBoxL2SystemSorter.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipEngineerSetting = this.checkBoxL2EquipmentEngineer.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipFunctionSetting = this.checkBoxL2EquipmentFunction.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipInitialize = this.checkBoxL2EquipmentInitialization.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipUpdate = this.checkBoxL2EquipmentUpdate.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipUserSetting = this.checkBoxL2EquipmentUser.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level2.IsEquipSystemLog = this.checkBoxL2EquipmentSystemLog.Checked;
            #endregion

            #region Level3
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMainDisplayClear = this.checkBoxL3MainProductNo.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMainDisplayProductNo = this.checkBoxL3MainProductNo.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMainDisplaySubMenu = this.checkBoxL3MainSubMenu.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsMainDisplayWeightSetting = this.checkBoxL3MainWeightSetting.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsBasicDataBackup = this.checkBoxL3BasicDataBackup.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsBasicDataStatistics = this.checkBoxL3BasicDataStat.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsBasicProduct = this.checkBoxL3BasicProduct.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsBasicTime = this.checkBoxL3BasicTime.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiCountingOutput = this.checkBoxL3ConfigCountingOutput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiEthernet = this.checkBoxL3ConfigEthernet.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiOptionBoard = this.checkBoxL3ConfigOptionBoard.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsConfiSerial = this.checkBoxL3ConfigSerial.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemAutoZero = this.checkBoxL3SystemAutoZero.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemCalibration = this.checkBoxL3SystemCalibration.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemExternalInput = this.checkBoxL3SystemExternalInput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemExternalOutput = this.checkBoxL3SystemExternalOutput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemIOTest = this.checkBoxL3SystemIOTest.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemJudgmentSetting = this.checkBoxL3SystemJudgment.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsSystemSorterSetting = this.checkBoxL3SystemSorter.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsEquipEngineerSetting = true;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsEquipFunctionSetting = true;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsEquipInitialize = this.checkBoxL3EquipmentInitialization.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsEquipUpdate = this.checkBoxL3EquipmentUpdate.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsEquipUserSetting = true;
            this.ParentForm.ParentForm.CurrentUserGroup.Level3.IsEquipSystemLog = true;
            #endregion

            #region Not Login
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsMainDisplayClear = this.checkBoxNotLoginMainClear.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsMainDisplayProductNo = this.checkBoxNotLoginMainProductNo.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsMainDisplaySubMenu = this.checkBoxNotLoginMainSubMenu.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsMainDisplayWeightSetting = this.checkBoxNotLoginMainWeightSetting.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsBasicDataBackup = this.checkBoxNotLoginBasicDataBackup.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsBasicDataStatistics = this.checkBoxNotLoginBasicDataStat.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsBasicProduct = this.checkBoxNotLoginBasicProduct.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsBasicTime = this.checkBoxNotLoginBasicTime.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiCountingOutput = this.checkBoxNotLoginConfigCountingOutput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiEthernet = this.checkBoxNotLoginConfigEthernet.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiOptionBoard = this.checkBoxNotLoginConfigOptionBoard.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsConfiSerial = this.checkBoxNotLoginConfigSerial.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemAutoZero = this.checkBoxNotLoginSystemAutoZero.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemCalibration = this.checkBoxNotLoginSystemCalibration.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemExternalInput = this.checkBoxNotLoginSystemExternalInput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemExternalOutput = this.checkBoxNotLoginSystemExternalOutput.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemIOTest = this.checkBoxNotLoginSystemIOTest.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemJudgmentSetting = this.checkBoxNotLoginSystemJudgment.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsSystemSorterSetting = this.checkBoxNotLoginSystemSorter.Checked;

            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipEngineerSetting = true;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipFunctionSetting = this.checkBoxNotLoginEquipmentFunction.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipInitialize = this.checkBoxNotLoginEquipmentInitialization.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipUpdate = this.checkBoxNotLoginEquipmentUpdate.Checked;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipUserSetting = false;
            this.ParentForm.ParentForm.CurrentUserGroup.NotLogin.IsEquipSystemLog = this.checkBoxNotLoginEquipmentSystemLog.Checked;
            #endregion

            this.ParentForm.ParentForm.SaveUserGroupFile(this.ParentForm.ParentForm.CurrentUserGroup);
            this.UpdateAllMenu(this.ParentForm.ParentForm.CurrentSystemStatus);

            this.buttonSave.Visible = false;
        }
        private void buttonBack_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            this.ParentForm.CenterEquipUser.BringToFront();
            this.ParentForm.CenterEquipUser.DisplayRefresh(this.ParentForm.ParentForm.CurrentSystemStatus);
        }
        #endregion
    }
}
