private void btnViewItems_Click(object sender, EventArgs e) { if (salesOrderGridView.SelectedRows.Count > 0) { DataGridViewRow dataRow = salesOrderGridView.SelectedRows[0]; int.TryParse(dataRow.Cells["id"].Value.ToString(), out int id); if (id < 0) { return; } DataTable dt = SalesOrderItemDataAccess.GetSalesItems(id); if (dt != null && dt.Rows.Count > 0) { var frmSalesItems = new frmSalesItems(this, userId, id, dt); frmSalesItems.ShowDialog(); } else { MessageBox.Show("Order doesn't have any item to view"); return; } } else { MessageBox.Show("Please select an order to view items"); } }
public void frmSalesItems_Load(object sender, EventArgs e) { //if (salesItemTable == null || salesItemTable.Rows.Count < 0) //{ // salesItemTable = .GetOrderItems(orderId); //} salesItemTable = SalesOrderItemDataAccess.GetSalesItems(orderId); this.salesItemGridView.DataSource = salesItemTable; FormatGrid(ref this.salesItemGridView); }