Esempio n. 1
0
        private void Reload(object sender, EventArgs e)
        {
            string filePath = excelFileSelect.FileName;

            try { if (ExcelDataReader_StackBuilder.LoadFile(filePath, ref _listTypes))
                  {
                  }
            }
            catch (System.Security.SecurityException ex)    { MessageBox.Show(ex.Message);    return; }
            catch (Exception ex)                            { MessageBox.Show(ex.Message);    return; }

            if (null != _listTypes && _listTypes.Count > 0)
            {
                tabControlLibrary.Show();
                // is tabcontrol already initialized
                if (tabControlLibrary.TabPages.Count == 0)
                {
                    if (HasType(typeof(DataCase)))
                    {
                        tabControlLibrary.TabPages.Add(Properties.Resources.ID_CASES); _classes.Add(typeof(DataCase));
                    }
                    if (HasType(typeof(DataBox)))
                    {
                        tabControlLibrary.TabPages.Add(Properties.Resources.ID_BOXES); _classes.Add(typeof(DataBox));
                    }
                    if (HasType(typeof(DataCylinder)))
                    {
                        tabControlLibrary.TabPages.Add(Properties.Resources.ID_CYLINDERS); _classes.Add(typeof(DataCylinder));
                    }
                    if (HasType(typeof(DataPallet)))
                    {
                        tabControlLibrary.TabPages.Add(Properties.Resources.ID_PALLETS); _classes.Add(typeof(DataPallet));
                    }
                    if (HasType(typeof(DataInterlayer)))
                    {
                        tabControlLibrary.TabPages.Add(Properties.Resources.ID_INTERLAYERS); _classes.Add(typeof(DataInterlayer));
                    }
                    if (HasType(typeof(DataPalletCap)))
                    {
                        tabControlLibrary.TabPages.Add(Properties.Resources.ID_PALLETCAPS); _classes.Add(typeof(DataPalletCap));
                    }
                    if (HasType(typeof(DataPalletFilm)))
                    {
                        tabControlLibrary.TabPages.Add(Properties.Resources.ID_PALLETFILMS); _classes.Add(typeof(DataPalletFilm));
                    }
                }
                tabControlLibrary.SelectedIndex = 0;
                OnTabPageSelected(this, null);
            }
            else
            {
                tabControlLibrary.Hide();
            }
        }
Esempio n. 2
0
        private void OnFileNameChanged(object sender, EventArgs e)
        {
            string filePath  = excelFileSelect.FileName;
            bool   fileExist = File.Exists(filePath);

            // enable disable import button
            bnImport.Enabled = fileExist;
            UpdateStatus(fileExist ? string.Empty : Properties.Resources.ID_DEFINEVALIDFILEPATH);

            if (fileExist)
            {
                // load file
                try { if (ExcelDataReader_StackBuilder.LoadFile(filePath, ref _listTypes))
                      {
                      }
                }
                catch (System.Security.SecurityException ex) { MessageBox.Show(ex.Message); return; }
                catch (Exception ex) { MessageBox.Show(ex.Message); return; }

                bnImport.Enabled    = _listTypes.Count > 0;
                progressBar.Maximum = _listTypes.Count > 0 ? _listTypes.Count - 1 : 0;
                UpdateStatus(string.Format("{0} items found", _listTypes.Count));
            }
        }