private void ALLBT_Click(object sender, EventArgs e) { if (ConnStatus == true) { MainDGV.DataSource = DB_Handle.Reader("SELECT * FROM Invoices").Tables[0]; } else { MessageBox.Show("DB connection not establised."); } }
private void SearchBT_Click(object sender, EventArgs e) { if (ConnStatus == true) { MainDGV.DataSource = DB_Handle.Reader( $"SELECT * FROM Invoices WHERE Client LIKE " + $"'%{Interaction.InputBox("Please input FIO or part of FIO.", "Search by FIO")}%'").Tables[0]; } else { MessageBox.Show("DB connection not establised."); } }
private void TotAmoBT_Click(object sender, EventArgs e) { if (ConnStatus == true) { MainDGV.DataSource = DB_Handle.Reader( "SELECT " + "CONCAT((SELECT MIN(date) FROM TestTaskInvoiceDB.dbo.Invoices), ' - '," + "(SELECT MAX(date) FROM TestTaskInvoiceDB.dbo.Invoices)) AS 'Period'," + "SUM(Invoice_amount) AS 'Total Amount'" + "FROM TestTaskInvoiceDB.dbo.Invoices" ).Tables[0]; MainDGV.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; } else { MessageBox.Show("DB connection not establised."); } }