Esempio n. 1
0
        private void AddStock_Shown(object sender, EventArgs e)
        {
            var t = new Task(() => { });

            t.Start();
            t.ContinueWith(task => {
                Connector databaseConnectCompany = new MYSQLDatabaseConnection();

                if (databaseConnectCompany.establish() == true)
                {
                    List <DatabaseColumn> CompanyList = databaseConnectCompany.GetAllCompanyNameWithId();

                    foreach (DatabaseColumn databseColumn in CompanyList)
                    {
                        cmbCompanyName.Items.Add(databseColumn.company_name);//add company name into combo box

                        tempCompanyList.Add(new DatabaseColumn()
                        {
                            company_name = databseColumn.company_name,
                            company_id   = databseColumn.company_id,
                        }
                                            );
                    }
                }
                else
                {
                    MessageBox.Show("connection error");
                }
            }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
        }
Esempio n. 2
0
        private void txtBarcode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                Connector      conection = new MYSQLDatabaseConnection();
                DatabaseColumn dataset   = new DatabaseColumn();
                dataset.barcode = txtBarcode.Text.ToString();
                barcode         = txtBarcode.Text.ToString();
                conection.SetData(dataset);
                conection.establish();
                DatabaseColumn data = conection.GetStockUsingBarcode();
                txtBarcode.Clear();

                txtExpDate.Text       = data.exp_date;
                txtGetPrice.Text      = data.get_price;
                txtInvoiceNumber.Text = data.invoice_number;
                txtQuantity.Text      = data.start_quantity;
                txtStockDate.Text     = data.stock_date;
                cmbCompanyName.Text   = data.company_name;
                cmbCategoryName.Text  = data.category_name;
                cmbProductName.Text   = data.product_name;

                var t = new Task(() => { });
                t.Start();
                t.ContinueWith(task => {
                    Connector databaseConnectCompany = new MYSQLDatabaseConnection();

                    if (databaseConnectCompany.establish() == true)
                    {
                        List <DatabaseColumn> CompanyList = databaseConnectCompany.GetAllCompanyNameWithId();

                        foreach (DatabaseColumn databseColumn in CompanyList)
                        {
                            cmbCompanyName.Items.Add(databseColumn.company_name);//add company name into combo box

                            tempCompanyList.Add(new DatabaseColumn()
                            {
                                company_name = databseColumn.company_name,
                                company_id   = databseColumn.company_id,
                            }
                                                );
                        }
                    }
                    else
                    {
                        MessageBox.Show("connection error");
                    }
                }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
            }
        }