void FillListBox() { dataGridView1.Rows.Clear(); try { PurchaseOrderDL objPurchaseOrderDL = new PurchaseOrderDL(); List <PurchaseOrderEL> lstPurchaseOrderEL = objPurchaseOrderDL.GetPurchasesOrderByComId(companyEL.Company_id); List <int> lstCompletePurchaseOrder = objPurchaseOrderDL.GetCompletePurchasesOrder(companyEL.Company_id); ListPurchaseOrder.SelectionChanged -= ListPurchaseOrder_SelectedIndexChanged; for (int i = 0; i < lstPurchaseOrderEL.Count; i++) { ListPurchaseOrder.Rows.Add(); ListPurchaseOrder.Rows[i].Cells["Purchases_Order_Id"].Value = lstPurchaseOrderEL[i].Purchases_Order_Id; ListPurchaseOrder.Rows[i].Cells["Company_id"].Value = lstPurchaseOrderEL[i].Company_id; ListPurchaseOrder.Rows[i].Cells["Date"].Value = lstPurchaseOrderEL[i].Date.ToString("dd-MM-yyyy"); ListPurchaseOrder.Rows[i].Cells["Purchases_Order_No"].Value = lstPurchaseOrderEL[i].Purchases_Order_No; if (lstCompletePurchaseOrder.Exists(r => lstPurchaseOrderEL[i].Purchases_Order_Id == r)) { ListPurchaseOrder.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.Green; ListPurchaseOrder.Rows[i].DefaultCellStyle.ForeColor = System.Drawing.Color.White; } } //GridBind(); ListPurchaseOrder.SelectionChanged += ListPurchaseOrder_SelectedIndexChanged; } catch { } }
void FillListBox() { try { PurchaseOrderDL objPurchasesOrderDL = new PurchaseOrderDL(); ListPurchaseOrder.SelectedIndexChanged -= ListPurchaseOrder_SelectedIndexChanged; ListPurchaseOrder.DataSource = objPurchasesOrderDL.GetPurchasesOrderByComId(companyEL.Company_id); ListPurchaseOrder.DisplayMember = "Purchases_Order_No"; ListPurchaseOrder.ValueMember = "Purchases_Order_Id"; ListPurchaseOrder.SelectedIndexChanged += ListPurchaseOrder_SelectedIndexChanged; } catch { } }