using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Management;
using ManualSoftwareSystem.lib;
using ManualSoftwareSystem.Operation_Manual;
using ManualSoftwareSystem.Inspection_Result;
using System.IO;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header;
using ManualSoftwareSystem.Work_History;
using ManualSoftwareSystem.Search_Function;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;

namespace ManualSoftwareSystem
{
    public partial class FrmMain : Form
    {
        private List<List<string>> Master = new List<List<string>>();
        private string loginUser = string.Empty;
        public dynamic objLanguage;
        private List<List<string>> CompleteResult = new List<List<string>>();
        private Excel.Application xlApp;
        private Excel.Workbook xlWorkBook;
        private Excel.Worksheet xlWorkSheet;
        private Excel.Worksheet xlWorkSheet2;

        public FrmMain(string loginUser)
        {
            InitializeComponent();
            this.loginUser = loginUser;
            this.objLanguage = FrmOperationManualOperator.objLanguage;
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {

            CheckSerialUSB.SerialUSB = CheckSerialUSB.CheckSerialUSBLicense();

            CheckSerialUSBWarning();


            string strOperationManual = "Operation Manual";
            string strInspectionWork = "Inspection Work";
            string strInspectionResult = "Inspection Result";
            string strInspectionResultOutput = "Inspection Result Output";
            string strWorkHistory = "Work History";
            string strSearchFunction = "Search Function";
            string strsettingMenu = "Setting";
            string strmasterMaintenanceMenu = "Master Maintenance";
            string strnewMenu = "New";
            string streditMenu = "Edit";


            btnOperationManual.Text = objLanguage.Translate(strOperationManual);
            btnInspectionWork.Text = objLanguage.Translate(strInspectionWork);
            btnInspectionResult.Text = objLanguage.Translate(strInspectionResult);
            btnInspectionResultOutput.Text = objLanguage.Translate(strInspectionResultOutput);
            btnWorkHistory.Text = objLanguage.Translate(strWorkHistory);
            btnSearchFunction.Text = objLanguage.Translate(strSearchFunction);
            settingMenu.Text = objLanguage.Translate(strsettingMenu);
            masterMaintenanceMenu.Text = objLanguage.Translate(strmasterMaintenanceMenu);
            newMenu.Text = objLanguage.Translate(strnewMenu);
            editMenu.Text = objLanguage.Translate(streditMenu);

            //textBox1.Text = CheckSerialUSB.SerialUSB;
            //textBox1.Visible = true;

            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            this.Text = "Checkru " + version;

        }

        public void CheckSerialUSBWarning()
        {
            if (CheckSerialUSB.SerialUSB == string.Empty)
            {
                //MessageBoxManager.OK = objLanguage.Translate("OK");
                MessageBox.Show(this, objLanguage.Translate("Please insert the USB key."),
                                       objLanguage.Translate("Warning"), MessageBoxButtons.OK,
                                       MessageBoxIcon.Exclamation,
                                       MessageBoxDefaultButton.Button1, 0);

                Application.Exit();
            }
            else if (CheckSerialUSB.SerialUSB == "Get")
            {
                //MessageBoxManager.OK = objLanguage.Translate("OK");
                MessageBox.Show(this, objLanguage.Translate("Not correct"),
                                       objLanguage.Translate("Warning"), MessageBoxButtons.OK,
                                       MessageBoxIcon.Exclamation,
                                       MessageBoxDefaultButton.Button1, 0);
                Application.Exit();
            }
        }

        private void settingMenu_Click(object sender, EventArgs e)
        {
            CheckSerialUSB.SerialUSB = CheckSerialUSB.CheckSerialUSBLicense();

            CheckSerialUSBWarning();

            FrmSettingLogIn frmSettingLogIn = new FrmSettingLogIn("Setting", loginUser);
            frmSettingLogIn.ShowDialog();

        }

        private void newMenu_Click(object sender, EventArgs e)
        {
            CheckSerialUSB.SerialUSB = CheckSerialUSB.CheckSerialUSBLicense();

            CheckSerialUSBWarning();

            FrmSettingLogIn frmSettingLogIn = new FrmSettingLogIn("MasterNew", loginUser);
            frmSettingLogIn.ShowDialog();

        }

        private void editMenu_Click(object sender, EventArgs e)
        {
            CheckSerialUSB.SerialUSB = CheckSerialUSB.CheckSerialUSBLicense();

            CheckSerialUSBWarning();

            FrmSettingLogIn frmSettingLogIn = new FrmSettingLogIn("MasterEdit", loginUser);
            frmSettingLogIn.ShowDialog();
        }

        private void btnOperationManual_Click(object sender, EventArgs e)
        {
            CheckSerialUSB.SerialUSB = CheckSerialUSB.CheckSerialUSBLicense();

            CheckSerialUSBWarning();

            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            //openFileDialog1.Filter = "Working (*.000)|*.000|Completion (*.001)|*.001|Error (*.002)|*.002|Master file (*.003)|*.003";
            openFileDialog1.Filter = objLanguage.Translate("Master file") + " (*.003)|*.003";
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                FrmOperationManualOperator.isViewer = false;
                FrmOperationManualOperator.strType = "Operation Manual";

                FrmOperationManualOperator frmOperationManualOperator = new FrmOperationManualOperator(openFileDialog1.FileName, "Operation Manual");

                //this.Dispose();

                frmOperationManualOperator.ShowDialog();


                //FrmMasterMaintenanceDetail frmMasterMaintenanceDetail = new FrmMasterMaintenanceDetail(openFileDialog1.FileName);
                //frmMasterMaintenanceDetail.ShowDialog();

            }

        }

        private void btnInspectionWork_Click(object sender, EventArgs e)
        {
            CheckSerialUSB.SerialUSB = CheckSerialUSB.CheckSerialUSBLicense();

            CheckSerialUSBWarning();

            FrmOperationManualOperator.isViewer = false;

            FrmOperationManualOperator.strType = "Inspection Work";

            FrmInspectionWorkSelectMode frmInspectionWorkSelectMode = new FrmInspectionWorkSelectMode();
            frmInspectionWorkSelectMode.ShowDialog();

        }

        private void btnInspectionResult_Click(object sender, EventArgs e)
        {
            CheckSerialUSB.SerialUSB = CheckSerialUSB.CheckSerialUSBLicense();

            CheckSerialUSBWarning();

            FrmInspectionResultSelectMode frmInspectionResultSelectMode = new FrmInspectionResultSelectMode();
            frmInspectionResultSelectMode.ShowDialog();

        }

        private void btnInspectionResultOutput_Click(object sender, EventArgs e)
        {
            string pathExcel = string.Empty;

            CheckSerialUSB.SerialUSB = CheckSerialUSB.CheckSerialUSBLicense();

            CheckSerialUSBWarning();

            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            //openFileDialog1.Filter = "Master file (*.003)|*.003|Working (*.000)|*.000";
            //openFileDialog1.Filter = objLanguage.Translate("Master file") + " (*.003)|*.003";
            openFileDialog1.Filter = objLanguage.Translate("Completion file") + " (*.001)|*.001";
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {

                if (openFileDialog1.FileName == string.Empty)
                {
                    MessageBox.Show(this, objLanguage.Translate("No file selected."),
                                   objLanguage.Translate("Warning"), MessageBoxButtons.OK,
                                   MessageBoxIcon.Exclamation,
                                   MessageBoxDefaultButton.Button1, 0);

                    return;
                }
                OpenCSVWithExcel(openFileDialog1.FileName);
            }
        }

        private void OpenCSVWithExcel(string path)
        {
            List<string> tmp = null;
            CompleteResult = new List<List<string>>();
            tmp = null;
            Int32 i = 0;
            using (var csv = new CsvReader(path))
            {
                while ((tmp = csv.ReadRow()) != null)
                {
                    CompleteResult.Add(tmp);

                    if (tmp.Count < 12)
                    {
                        //MessageBox.Show(this, objLanguage.Translate("File Format Wrong."),
                        MessageBox.Show(this, objLanguage.Translate("File Format is not correct."),
                               objLanguage.Translate("Warning"), MessageBoxButtons.OK,
                               MessageBoxIcon.Exclamation,
                               MessageBoxDefaultButton.Button1, 0);

                        return;

                    }
                    i++;
                }

                if (CompleteResult.Count < 17)
                {
                    //MessageBox.Show(this, objLanguage.Translate("File Format Wrong."),
                    MessageBox.Show(this, objLanguage.Translate("File Format is not correct."),
                           objLanguage.Translate("Warning"), MessageBoxButtons.OK,
                           MessageBoxIcon.Exclamation,
                           MessageBoxDefaultButton.Button1, 0);

                    return;

                }

                try
                {

                    if (this.CompleteResult[0][12] == string.Empty)
                    {
                        MessageBox.Show(this, objLanguage.Translate("Excel File Not Found."),
                               objLanguage.Translate("Warning"), MessageBoxButtons.OK,
                               MessageBoxIcon.Exclamation,
                               MessageBoxDefaultButton.Button1, 0);

                        return;
                    }

                    xlApp = new Excel.Application();
                    //xlWorkBook = xlApp.Workbooks.Open("C:\\TOMAS TECH\\Shodensha (Thailand)\\File\\Sample_02.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                    xlWorkBook = xlApp.Workbooks.Open(this.CompleteResult[0][12], 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

                    xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

                    // range = xlWorkSheet.UsedRange;

                    //  Object[,] saRet;
                    //  saRet = (System.Object[,])range.get_Value(Missing.Value);

                    xlWorkSheet.Cells[3, 3] = this.CompleteResult[1][0];
                    xlWorkSheet.Cells[3, 7] = this.CompleteResult[1][1];
                    xlWorkSheet.Cells[4, 3] = this.CompleteResult[1][2];
                    xlWorkSheet.Cells[4, 5] = this.CompleteResult[1][3];
                    xlWorkSheet.Cells[4, 7] = this.CompleteResult[1][4];
                    xlWorkSheet.Cells[5, 3] = this.CompleteResult[1][5];
                    xlWorkSheet.Cells[5, 7] = this.CompleteResult[1][6];
                    xlWorkSheet.Cells[6, 3] = this.CompleteResult[1][7];
                    xlWorkSheet.Cells[6, 7] = this.CompleteResult[1][8];
                    xlWorkSheet.Cells[7, 3] = this.CompleteResult[3][1];
                    xlWorkSheet.Cells[7, 5] = this.CompleteResult[3][0];
                    xlWorkSheet.Cells[7, 7] = this.CompleteResult[3][2];
                    xlWorkSheet.Cells[8, 3] = this.CompleteResult[3][3];
                    xlWorkSheet.Cells[8, 7] = this.CompleteResult[3][4];
                    xlWorkSheet.Cells[9, 3] = this.CompleteResult[3][5];
                    xlWorkSheet.Cells[9, 7] = this.CompleteResult[3][6];
                    xlWorkSheet.Cells[10, 3] = this.CompleteResult[3][7];
                    xlWorkSheet.Cells[10, 7] = this.CompleteResult[3][8];
                    xlWorkSheet.Cells[12, 3] = this.CompleteResult[1][9];
                    xlWorkSheet.Cells[12, 5] = this.CompleteResult[1][10];
                    xlWorkSheet.Cells[12, 7] = string.Empty; // this.CompleteResult[1][12];
                    xlWorkSheet.Cells[12, 9] = string.Empty; // this.CompleteResult[1][13];
                    xlWorkSheet.Cells[13, 3] = this.CompleteResult[2][9];
                    xlWorkSheet.Cells[13, 5] = this.CompleteResult[2][10];
                    xlWorkSheet.Cells[13, 7] = string.Empty; // this.CompleteResult[2][12];
                    xlWorkSheet.Cells[13, 9] = string.Empty; // this.CompleteResult[2][13];
                    xlWorkSheet.Cells[14, 3] = this.CompleteResult[2][11];
                    xlWorkSheet.Cells[14, 5] = this.CompleteResult[3][11];
                    xlWorkSheet.Cells[14, 7] = string.Empty; // this.CompleteResult[2][14];
                    xlWorkSheet.Cells[14, 9] = string.Empty; // this.CompleteResult[3][14];
                    xlWorkSheet.Cells[15, 3] = this.CompleteResult[1][11];
                    xlWorkSheet.Cells[15, 5] = this.CompleteResult[3][9];
                    xlWorkSheet.Cells[15, 7] = string.Empty; // this.CompleteResult[1][14];
                    xlWorkSheet.Cells[15, 9] = string.Empty; // this.CompleteResult[3][12];
                    xlWorkSheet.Cells[16, 3] = this.CompleteResult[3][10];
                    xlWorkSheet.Cells[16, 7] = string.Empty; // this.CompleteResult[3][13];
                    xlWorkSheet.Cells[19, 8] = this.CompleteResult[5][9];
                    xlWorkSheet.Cells[19, 9] = string.Empty; // this.CompleteResult[5][12];
                    xlWorkSheet.Cells[20, 8] = this.CompleteResult[6][9];
                    xlWorkSheet.Cells[20, 9] = string.Empty; // this.CompleteResult[6][12];

                    xlWorkSheet.Cells[23, 2] = this.CompleteResult[7][11];
                    xlWorkSheet.Cells[23, 4] = this.CompleteResult[8][11];
                    xlWorkSheet.Cells[23, 6] = this.CompleteResult[9][11];
                    xlWorkSheet.Cells[21, 8] = this.CompleteResult[10][9];
                    xlWorkSheet.Cells[24, 8] = this.CompleteResult[11][9];

                    xlWorkSheet.Cells[27, 2] = this.CompleteResult[11][11];
                    xlWorkSheet.Cells[27, 4] = this.CompleteResult[12][11];
                    xlWorkSheet.Cells[27, 6] = this.CompleteResult[13][11];
                    xlWorkSheet.Cells[25, 8] = this.CompleteResult[13][9];

                    xlWorkSheet.Cells[30, 2] = this.CompleteResult[14][11];
                    xlWorkSheet.Cells[30, 4] = this.CompleteResult[15][11];
                    xlWorkSheet.Cells[30, 6] = this.CompleteResult[16][11];
                    xlWorkSheet.Cells[28, 8] = this.CompleteResult[16][9];
                    xlWorkSheet.Cells[31, 8] = this.CompleteResult[17][9]; // this.CompleteResult[17][9];
                    xlWorkSheet.Cells[31, 9] = string.Empty; // this.CompleteResult[17][12];

                    xlWorkSheet.Cells[35, 1] = string.Empty;
                    xlWorkSheet.Cells[35, 3] = string.Empty;
                    xlWorkSheet.Cells[35, 5] = string.Empty;
                    xlWorkSheet.Cells[36, 1] = string.Empty;
                    xlWorkSheet.Cells[36, 3] = string.Empty;
                    xlWorkSheet.Cells[36, 5] = string.Empty;
                    xlWorkSheet.Cells[37, 1] = string.Empty;
                    xlWorkSheet.Cells[37, 3] = string.Empty;
                    xlWorkSheet.Cells[37, 5] = string.Empty;
                    xlWorkSheet.Cells[38, 1] = string.Empty;
                    xlWorkSheet.Cells[38, 3] = string.Empty;
                    xlWorkSheet.Cells[38, 5] = string.Empty;
                    xlWorkSheet.Cells[39, 1] = string.Empty;
                    xlWorkSheet.Cells[39, 3] = string.Empty;
                    xlWorkSheet.Cells[39, 5] = string.Empty;


                    //xlApp.WindowState = Excel.XlWindowState.xlMaximized;
                    //xlApp.Visible = true;


                    //xlApp = new Excel.Application();
                    //xlWorkBook = xlApp.Workbooks.Open("C:\\TOMAS TECH\\Shodensha (Thailand)\\File\\Sample_02.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                    //xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

                    // range = xlWorkSheet.UsedRange;

                    //  Object[,] saRet;
                    //  saRet = (System.Object[,])range.get_Value(Missing.Value);

                    xlWorkSheet.Cells[43, 3] = this.CompleteResult[1][0];
                    xlWorkSheet.Cells[43, 7] = this.CompleteResult[1][1];
                    xlWorkSheet.Cells[44, 3] = this.CompleteResult[1][2];
                    xlWorkSheet.Cells[44, 5] = this.CompleteResult[1][3];
                    xlWorkSheet.Cells[44, 7] = this.CompleteResult[1][4];
                    xlWorkSheet.Cells[45, 3] = this.CompleteResult[1][5];
                    xlWorkSheet.Cells[45, 7] = this.CompleteResult[1][6];
                    xlWorkSheet.Cells[46, 3] = this.CompleteResult[1][7];
                    xlWorkSheet.Cells[46, 7] = this.CompleteResult[1][8];
                    xlWorkSheet.Cells[47, 3] = this.CompleteResult[3][1];
                    xlWorkSheet.Cells[47, 5] = this.CompleteResult[3][0];
                    xlWorkSheet.Cells[47, 7] = this.CompleteResult[3][2];
                    xlWorkSheet.Cells[48, 3] = this.CompleteResult[3][3];
                    xlWorkSheet.Cells[48, 7] = this.CompleteResult[3][4];
                    xlWorkSheet.Cells[49, 3] = this.CompleteResult[3][5];
                    xlWorkSheet.Cells[49, 7] = this.CompleteResult[3][6];
                    xlWorkSheet.Cells[50, 3] = this.CompleteResult[3][7];
                    xlWorkSheet.Cells[50, 7] = this.CompleteResult[3][8];
                    xlWorkSheet.Cells[52, 3] = this.CompleteResult[1][9];
                    xlWorkSheet.Cells[52, 5] = this.CompleteResult[1][10];
                    xlWorkSheet.Cells[52, 7] = string.Empty; // this.CompleteResult[1][12];
                    xlWorkSheet.Cells[52, 9] = string.Empty; // this.CompleteResult[1][13];
                    xlWorkSheet.Cells[53, 3] = this.CompleteResult[2][9];
                    xlWorkSheet.Cells[53, 5] = this.CompleteResult[2][10];
                    xlWorkSheet.Cells[53, 7] = string.Empty; // this.CompleteResult[2][12];
                    xlWorkSheet.Cells[53, 9] = string.Empty; // this.CompleteResult[2][13];
                    xlWorkSheet.Cells[54, 3] = this.CompleteResult[2][11];
                    xlWorkSheet.Cells[54, 5] = this.CompleteResult[3][11];
                    xlWorkSheet.Cells[54, 7] = string.Empty; // this.CompleteResult[2][14];
                    xlWorkSheet.Cells[54, 9] = string.Empty; // this.CompleteResult[3][14];
                    xlWorkSheet.Cells[55, 3] = this.CompleteResult[1][11];
                    xlWorkSheet.Cells[55, 5] = this.CompleteResult[3][9];
                    xlWorkSheet.Cells[55, 7] = string.Empty; // this.CompleteResult[1][14];
                    xlWorkSheet.Cells[55, 9] = string.Empty; // this.CompleteResult[3][12];
                    xlWorkSheet.Cells[56, 3] = this.CompleteResult[3][10];
                    xlWorkSheet.Cells[56, 7] = string.Empty; // this.CompleteResult[3][13];

                    xlWorkSheet.Cells[59, 8] = this.CompleteResult[5][10];//DateTime
                    xlWorkSheet.Cells[59, 9] = string.Empty; // this.CompleteResult[5][12];
                    xlWorkSheet.Cells[60, 8] = this.CompleteResult[6][10];//DateTime
                    xlWorkSheet.Cells[60, 9] = string.Empty; // this.CompleteResult[6][12];

                    xlWorkSheet.Cells[63, 2] = this.CompleteResult[7][10];//DateTime
                    xlWorkSheet.Cells[63, 4] = this.CompleteResult[8][10];//DateTime
                    xlWorkSheet.Cells[63, 6] = this.CompleteResult[9][10];//DateTime
                    xlWorkSheet.Cells[61, 8] = this.CompleteResult[10][10];//DateTime
                    xlWorkSheet.Cells[64, 8] = this.CompleteResult[11][10];//DateTime

                    xlWorkSheet.Cells[67, 2] = this.CompleteResult[11][10];//DateTime
                    xlWorkSheet.Cells[67, 4] = this.CompleteResult[12][10];//DateTime
                    xlWorkSheet.Cells[67, 6] = this.CompleteResult[13][10];//DateTime
                    xlWorkSheet.Cells[65, 8] = this.CompleteResult[13][10];//DateTime

                    xlWorkSheet.Cells[70, 2] = this.CompleteResult[14][10];//DateTime
                    xlWorkSheet.Cells[70, 4] = this.CompleteResult[15][10];//DateTime
                    xlWorkSheet.Cells[70, 6] = this.CompleteResult[16][10];//DateTime
                    xlWorkSheet.Cells[68, 8] = this.CompleteResult[16][10];//DateTime
                    xlWorkSheet.Cells[71, 8] = this.CompleteResult[17][10]; // this.CompleteResult[17][9];
                    xlWorkSheet.Cells[71, 9] = string.Empty; // this.CompleteResult[17][12];

                    xlWorkSheet.Cells[75, 1] = string.Empty;
                    xlWorkSheet.Cells[75, 3] = string.Empty;
                    xlWorkSheet.Cells[75, 5] = string.Empty;
                    xlWorkSheet.Cells[76, 1] = string.Empty;
                    xlWorkSheet.Cells[76, 3] = string.Empty;
                    xlWorkSheet.Cells[76, 5] = string.Empty;
                    xlWorkSheet.Cells[77, 1] = string.Empty;
                    xlWorkSheet.Cells[77, 3] = string.Empty;
                    xlWorkSheet.Cells[77, 5] = string.Empty;
                    xlWorkSheet.Cells[78, 1] = string.Empty;
                    xlWorkSheet.Cells[78, 3] = string.Empty;
                    xlWorkSheet.Cells[78, 5] = string.Empty;
                    xlWorkSheet.Cells[79, 1] = string.Empty;
                    xlWorkSheet.Cells[79, 3] = string.Empty;
                    xlWorkSheet.Cells[79, 5] = string.Empty;

                    xlApp.WindowState = Excel.XlWindowState.xlMaximized;
                    xlApp.Visible = true;

                    //xlWorkBook.Close(true, null, null);
                    //xlApp.Quit();

                    //releaseObject(xlWorkSheet);
                    //releaseObject(xlWorkBook);
                    //releaseObject(xlApp);
                }
                catch (Exception)
                {

                    MessageBox.Show(this, objLanguage.Translate("Excel File Not Found."),
                               objLanguage.Translate("Warning"), MessageBoxButtons.OK,
                               MessageBoxIcon.Exclamation,
                               MessageBoxDefaultButton.Button1, 0);

                    return;
                }
            }

            //    var ExcelApp = new Excel.Application();
            //ExcelApp.Workbooks.OpenText(path, Comma: true);

            //ExcelApp.Visible = true;
        }

        private void btnWorkHistory_Click(object sender, EventArgs e)
        {
            CheckSerialUSB.SerialUSB = CheckSerialUSB.CheckSerialUSBLicense();

            CheckSerialUSBWarning();

            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            //openFileDialog1.Filter = "Master file (*.003)|*.003|Working (*.000)|*.000";
            openFileDialog1.Filter = objLanguage.Translate("CSV file") + " (*.csv)|*.csv";
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {

                if (openFileDialog1.FileName == string.Empty)
                {
                    MessageBox.Show(this, objLanguage.Translate("No file selected."),
                                   objLanguage.Translate("Warning"), MessageBoxButtons.OK,
                                   MessageBoxIcon.Exclamation,
                                   MessageBoxDefaultButton.Button1, 0);

                    return;
                }

                FrmWorkHistoryViewer frmWorkHistoryViewer = new FrmWorkHistoryViewer(openFileDialog1.FileName);
                frmWorkHistoryViewer.ShowDialog();


            }


        }

        private void btnSearchFunction_Click(object sender, EventArgs e)
        {
            CheckSerialUSB.SerialUSB = CheckSerialUSB.CheckSerialUSBLicense();

            CheckSerialUSBWarning();

            FrmSearchFunction frmSearchFunction = new FrmSearchFunction();
            frmSearchFunction.ShowDialog();

        }

        private void FrmMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}
