protected void fillGrid(String catId) { if (catId != null && !catId.Equals("") && !catId.Equals("_")) { DataTable dt = new DataTable(); dt.Columns.Add("ProdCatId"); dt.Columns.Add("ProdName"); dt.Columns.Add("Stock"); dt.Columns.Add("msrmnt"); dt.Columns.Add("srcPrice"); dt.Columns.Add("listPrice"); dt.Columns.Add("curr"); Dictionary <String, ShopChildProdsInventory> chilDict = ShopChildProdsInventory. getAllShopChildProdObjsbyEntId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); Dictionary <String, Currency> allCurrList = (Dictionary <String, Currency>)Session[SessionFactory.CURRENCY_LIST]; int counter = 0; foreach (KeyValuePair <String, ShopChildProdsInventory> kvp in chilDict) { ShopChildProdsInventory childObj = (ShopChildProdsInventory)kvp.Value; if (childObj.getProdCatId().Equals(catId.Trim()) || BackEndObjects.ProductCategory.getRootLevelParentCategoryDB(childObj.getProdCatId()).ContainsKey(catId.Trim())) { dt.Rows.Add(); dt.Rows[counter]["ProdCatId"] = childObj.getProdCatId(); dt.Rows[counter]["ProdName"] = childObj.getProdName(); dt.Rows[counter]["Stock"] = childObj.getQnty(); dt.Rows[counter]["msrmnt"] = childObj.getMsrmntUnit(); dt.Rows[counter]["srcPrice"] = childObj.getUnitSrcPrice(); dt.Rows[counter]["listPrice"] = childObj.getUnitListPrice(); dt.Rows[counter]["curr"] = dt.Rows[counter]["curr"] = childObj.getCurrency() != null && allCurrList.ContainsKey(childObj.getCurrency()) ? allCurrList[childObj.getCurrency()].getCurrencyName() : ""; counter++; } } Button_Audit_Prod.Enabled = false; Button_Notes_Prod.Enabled = false; GridView1.DataSource = dt; GridView1.DataBind(); GridView1.Visible = true; GridView1.Columns[2].Visible = false; GridView1.SelectedIndex = -1; Dictionary <String, bool> accessList = (Dictionary <String, bool>)Session[SessionFactory.ACCESSLIST_FOR_USER]; if (!accessList[BackEndObjects.EntityAccessListRecord.ENTITY_ACCESS_LIST_RECORD_ACCESS_EDIT_PRODUCT] && !accessList[BackEndObjects.EntityAccessListRecord.ENTITY_ACCESS_LIST_RECORD_ACCESS_OWNER_ACCESS]) { GridView1.Columns[1].Visible = false; } Session[SessionFactory.ALL_PRODUCT_PROD_DATA_GRID] = dt; } else { fillGrid(); } }
protected void fillGrid() { DataTable dt = new DataTable(); dt.Columns.Add("ProdCatId"); dt.Columns.Add("ProdName"); dt.Columns.Add("Stock"); dt.Columns.Add("msrmnt"); dt.Columns.Add("srcPrice"); dt.Columns.Add("listPrice"); dt.Columns.Add("curr"); Dictionary <String, ShopChildProdsInventory> chilDict = ShopChildProdsInventory. getAllShopChildProdObjsbyEntId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()); Dictionary <String, Currency> allCurrList = (Dictionary <String, Currency>)Session[SessionFactory.CURRENCY_LIST]; //This dictionary will be used by created product screen for duplicacy check Dictionary <String, String> allExistingProdDict = new Dictionary <String, String>(); int counter = 0; foreach (KeyValuePair <String, ShopChildProdsInventory> kvp in chilDict) { dt.Rows.Add(); ShopChildProdsInventory childObj = (ShopChildProdsInventory)kvp.Value; dt.Rows[counter]["ProdCatId"] = childObj.getProdCatId(); dt.Rows[counter]["ProdName"] = childObj.getProdName(); dt.Rows[counter]["Stock"] = childObj.getQnty(); dt.Rows[counter]["msrmnt"] = childObj.getMsrmntUnit(); dt.Rows[counter]["srcPrice"] = childObj.getUnitSrcPrice(); dt.Rows[counter]["listPrice"] = childObj.getUnitListPrice(); dt.Rows[counter]["curr"] = childObj.getCurrency() != null && allCurrList.ContainsKey(childObj.getCurrency()) ? allCurrList[childObj.getCurrency()].getCurrencyName() : ""; if (!allExistingProdDict.ContainsKey(childObj.getProdName()) && !childObj.getProdName().Equals("")) { allExistingProdDict.Add(childObj.getProdName(), childObj.getProdName()); } counter++; } dt.DefaultView.Sort = "ProdName" + " " + "ASC"; Button_Audit_Prod.Enabled = false; Button_Notes_Prod.Enabled = false; GridView1.DataSource = dt.DefaultView.ToTable(); GridView1.DataBind(); GridView1.Visible = true; GridView1.Columns[2].Visible = false; GridView1.SelectedIndex = -1; Dictionary <String, bool> accessList = (Dictionary <String, bool>)Session[SessionFactory.ACCESSLIST_FOR_USER]; if (!accessList[BackEndObjects.EntityAccessListRecord.ENTITY_ACCESS_LIST_RECORD_ACCESS_EDIT_PRODUCT] && !accessList[BackEndObjects.EntityAccessListRecord.ENTITY_ACCESS_LIST_RECORD_ACCESS_OWNER_ACCESS]) { GridView1.Columns[1].Visible = false; } Session[SessionFactory.ALL_PRODUCT_CREATE_PRODUCT_EXISTING_NAMES] = allExistingProdDict; Session[SessionFactory.ALL_PRODUCT_PROD_DATA_GRID] = dt.DefaultView.ToTable(); }