Esempio n. 1
0
        public void LoadDataBase(EndLoadDatabaseDl finishLoadDb, string path)
        {
            Person p         = new Person();
            Thread newThread = new Thread(() => LoadDBFunc(finishLoadDb, path));

            newThread.Start();
        }
Esempio n. 2
0
        public void LoadDBFunc(EndLoadDatabaseDl finishLoadDb, string path)
        {
            luckyDrawData = new LuckyDrawData(path);
            PersonList    = luckyDrawData.GetListPersonFormDatabase();
            PersonListBackup.AddRange(PersonList);

            GetMaxNumberCharacterId();
            finishLoadDb();
        }
Esempio n. 3
0
        private void EndLoadDatabase()
        {
            if (lbLoadingDb.InvokeRequired == false)
            {
                lbLoadingDb.Visible = false;
                btStart.Enabled     = true;

                //set serial number
                int widthOfPb = serialNumber.ChangeNumberBox(luckyDrawController.GetMaxNumberCharacterId());
                pbSerialNumber.Width    = widthOfPb;
                pbSerialNumber.Location = new Point((this.Width - pbSerialNumber.Width) / 2, pbSerialNumber.Location.Y);
            }
            else
            {
                // Show progress asynchronously
                EndLoadDatabaseDl dl = new EndLoadDatabaseDl(EndLoadDatabase);
                //Invoke(dl);
                BeginInvoke(dl);
            }
        }
Esempio n. 4
0
        private void btOpenDatabase_Click(object sender, EventArgs e)
        {
            // Create an instance of the open file dialog box.
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            // Set filter options and filter index.
            openFileDialog1.Filter      = "Excel Files|*.xls;*.xlsx";
            openFileDialog1.FilterIndex = 1;
            openFileDialog1.Multiselect = false;

            // Call the ShowDialog method to show the dialog box.
            var userClickedOK = openFileDialog1.ShowDialog();

            // Process input if the user clicked OK.
            if (userClickedOK == DialogResult.OK)
            {
                this.tbDatabase.Text = openFileDialog1.FileName;
                EndLoadDatabaseDl end = new EndLoadDatabaseDl(EndLoadDatabase);
                luckyDrawController.LoadDataBase(end, this.tbDatabase.Text);
                lbLoadingDb.Visible = true;
                btStart.Enabled     = false;
            }
        }