private void PurchaseOrder_Load(object sender, EventArgs e) { dtpDate.Value = DateTime.Now; panel2.Visible = false; SqlConnection con = dbMainClass.openConnection(); string stlect = "select Orderid from VendorOrderDetails"; DataTable dt = dbMainClass.getDetailByQuery(stlect); string id = ""; foreach (DataRow dr in dt.Rows) { id = dr[0].ToString(); } //txtSrNo.Text = id; if (id == "") { //int txt = Convert.ToInt32(id); //int txt1 = txt + 1; id = "1"; txtSrNo.Text = id; } else { int txt = Convert.ToInt32(id); int txt1 = txt + 1; txtSrNo.Text = txt1.ToString(); } Purchase.PurchaseDetails purChaseDetailObj = new Purchase.PurchaseDetails(); vendorDetails = purChaseDetailObj.GetVendorDetaisInDataTable(); ItemDetails = purChaseDetailObj.GetItemPriceAndNameDetaisInDataTable(); setAutoCompleteMode(txtProductName, "ItemName", ItemDetails); setAddToCraftTable(); //setAutoCompleteMode(txtVendorName, "Name", vendorDetails); }