private void buttonSearch_Click(object sender, EventArgs e) { string sql = "select barcode as Barcode, medicineName as Prouct, quantity as Quantity, expirayDate as [Expiry Date] from stock join medicine on stock.medicneID = medicine.medicineID where quantity<" + textBox1.Text; DatabaseWorking windowMain = new DatabaseWorking(); SqlConnection conn = windowMain.CreateConnectionToSqlDatabase(); DatagridStock.Rows.Clear(); windowMain.AddItemsToDataGrid(DatagridStock, sql, conn); }
private void ButtonStock_Click(object sender, EventArgs e) { Stock stock = new Stock(); ToggleColor(ButtonStock); ContentPanel.Controls.Clear(); CreateUserControl(stock); DatabaseWorking database = new DatabaseWorking(); string command = "select barcode,medicineName,salePrice,costPrice,quantity,expirayDate from stock join medicine on stock.medicneID=medicine.medicineID;"; SqlConnection sqlConnection = database.CreateConnectionToSqlDatabase(); database.AddItemsToDataGrid(stock.dataGridViewStock, command, sqlConnection); }
private void ButtonPurchase_Click(object sender, EventArgs e) { DatabaseWorking working = new DatabaseWorking(); Purcahse purcahseTab = new Purcahse(); ToggleColor(ButtonPurchase); ContentPanel.Controls.Clear(); CreateUserControl(purcahseTab); if (purcahseTab.DatagridStock.Rows.Count != 0) { string[] sql = new string[2]; sql[0] = "select barcode as Barcode, medicineName as Prouct, quantity as Quantity, expirayDate as [Expiry Date] from stock join medicine on stock.medicneID = medicine.medicineID"; sql[1] = "select SupplierName from supplier"; SqlConnection conn = working.CreateConnectionToSqlDatabase(); working.AddItemsToDataGrid(purcahseTab.DatagridStock, sql[0], conn); working.AddItemsToCombobox(purcahseTab.comboBox1, sql[1], conn); purcahseTab.comboBox1.SelectedIndex = 0; } }