I have this method that correctly displays a list of batch numbers. I would like to refine it by passing down a batch prefix and have the display begin at whatever that prefix is. I want the user to still be able to go forward and backward in the list.The data resides in an MSSQL table.Is this something that can added or is it best to use some third-party developer tool?
private void DisplayBatches()
{
DataTable dataTable = new DataTable();
/* dataTable = new DataTable(); */
string commandText = "SELECT BACHNUMB AS 'Batch ID'," +
"CASE WHEN BCHSOURC = 'GL_Clearing' THEN 'Clearing Entry' " +
"WHEN BCHSOURC = 'GL_Normal' THEN 'General Entry' " +
"WHEN BCHSOURC = 'Invoice Entry' THEN 'Invoice Entry' " +
"WHEN BCHSOURC = 'IV_Trans' THEN 'Transction Entry' " +
"WHEN BCHSOURC = 'IV_Trxent' THEN 'Transfer Entry' " +
"WHEN BCHSOURC = 'ASMENT' THEN 'Assembly Entry' " +
"WHEN BCHSOURC = 'PM_Payment' THEN 'Manual Checks' " +
"WHEN BCHSOURC = 'PM_Trxent' THEN 'Payables Trx Entry' " +
"WHEN BCHSOURC = 'Rcvg Trx' THEN 'Receivings Trx Entry' " +
"WHEN BCHSOURC = 'Rcvg Trx Ivc' THEN 'Purchasing Invoice Entry' " +
"WHEN BCHSOURC = 'RM_Cash' THEN 'Cash Receipts' " +
"WHEN BCHSOURC = 'RM_Sales' THEN 'Transaction Entry' " +
"WHEN BCHSOURC = 'Sales Entry' THEN 'Sales Transaction Entry' " +
"WHEN BCHSOURC = 'XPM_Cchecks' THEN 'Computer Checks' " +
"ELSE 'Unknown' END AS 'Origin'" +
",CASE WHEN NUMOFTRX = 0 THEN 'No Transactions' " +
"ELSE CONVERT(CHAR(5),NUMOFTRX) +' Transactions' END AS 'Status'" +
",CASE WHEN BACHFREQ = 1 THEN 'Single Use' " +
"ELSE 'Unknown' END AS 'Frequency' " +
"FROM[dbo].[SY00500] " +
"WHERE SERIES = 3 AND BCHSOURC='Sales Entry' " +
"ORDER BY BACHNUMB";
int recordCount = DataAccess.ExecuteDataSet(ref dataTable, Controller.Instance.Model.GPCompanyDatabase, CommandType.Text,commandText,null);
/* MessageBox.Show("Record count : " + recordCount.ToString() + " - " + commandText); */
dgvBatches.ReadOnly = true;
dgvBatches.RowHeadersVisible = false;
dgvBatches.DataSource = dataTable;
dgvBatches.Columns[0].Width = 120;
dgvBatches.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
dgvBatches.Columns[0].DefaultCellStyle.Format = "0";
dgvBatches.Columns[0].HeaderText = "Batch ID";
dgvBatches.Columns[1].Width = 140;
dgvBatches.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
dgvBatches.Columns[1].DefaultCellStyle.Format = "0";
dgvBatches.Columns[1].HeaderText = "Origin";
dgvBatches.Columns[2].Width = 120;
dgvBatches.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
dgvBatches.Columns[2].DefaultCellStyle.Format = "0";
dgvBatches.Columns[2].HeaderText = "Status";
dgvBatches.Columns[3].Width = 100;
dgvBatches.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
dgvBatches.Columns[3].DefaultCellStyle.Format = "0";
dgvBatches.Columns[3].HeaderText = "Frequency";
dgvBatches.EditMode = DataGridViewEditMode.EditOnEnter;
dgvBatches.Focus();
}
Our community of experts have been thoroughly vetted for their expertise and industry experience.