public static List <ATTInvItemSubCategory> GetItemSubCategoryList(int?itemCategoryID, string active) { List <ATTInvItemSubCategory> lstItemSubcategoryList = new List <ATTInvItemSubCategory>(); try { foreach (DataRow row in DLLInvItemSubCategory.GetItemSubCategoryTable(itemCategoryID, active).Rows) { ATTInvItemSubCategory obj = new ATTInvItemSubCategory(); obj.ItemsCategoryID = int.Parse(row["items_category_id"].ToString()); obj.ItemsSubCategoryID = int.Parse(row["items_sub_category_id"].ToString()); obj.ItemsSubCategoryName = row["items_sub_category_name"].ToString(); obj.Active = row["active"].ToString(); lstItemSubcategoryList.Add(obj); } return(lstItemSubcategoryList); } catch (Exception ex) { throw new Exception("Error occur while selecting ItemsSubCategory:" + ex.Message); } }
public static List <ATTInvItemSubCategory> GetItemSubCategory(int?itemCategoryID, string active, bool ContainsDefault) { List <ATTInvItemSubCategory> lst = new List <ATTInvItemSubCategory>(); try { foreach (DataRow row in DLLInvItemSubCategory.GetItemsSubCategory(itemCategoryID, active).Rows) { ATTInvItemSubCategory objItemSubCategory = new ATTInvItemSubCategory( int.Parse(row["items_category_id"].ToString()), int.Parse(row["items_sub_category_id"].ToString()), row["items_sub_category_name"].ToString(), row["active"].ToString()); lst.Add(objItemSubCategory); } if (lst.Count > 0 && ContainsDefault == true) { ATTInvItemSubCategory def = new ATTInvItemSubCategory(); def.ItemsSubCategoryID = -1; def.ItemsSubCategoryName = "----छान्नुहोस----"; lst.Insert(0, def); } return(lst); } catch (Exception ex) { throw ex; } }
protected void btnAddItemSubCategory_Click(object sender, EventArgs e) { if (this.txSubCategory_Rqd.Text == "") { return; } ////////// ATTInvItemsCategory itemsCategory = (ATTInvItemsCategory)Session["ItemCategory"]; List <ATTInvItemsCategory> lstall = (List <ATTInvItemsCategory>)Session["ItemCategory_List"]; if (lstItemCategory.SelectedIndex == -1) { foreach (ATTInvItemsCategory var in lstall) { int index = var.LstItemSubCategory.FindIndex( delegate(ATTInvItemSubCategory ob) { return(ob.ItemsSubCategoryName == txSubCategory_Rqd.Text); } ); if (index >= 0) { this.lblStatusMessage.Text = "Item SubCategory Already Exists"; this.programmaticModalPopup.Show(); return; } else { if (grdItemSubCategory.SelectedIndex < 0) { if (itemsCategory.LstItemSubCategory.Exists( delegate(ATTInvItemSubCategory ob) { return(ob.ItemsSubCategoryName == txSubCategory_Rqd.Text); } )) { this.lblStatusMessage.Text = "Item SubCategory Already Exists"; this.programmaticModalPopup.Show(); return; } } else { int ind = itemsCategory.LstItemSubCategory.FindIndex( delegate(ATTInvItemSubCategory ob) { return(ob.ItemsSubCategoryName == txSubCategory_Rqd.Text); } ); if (ind >= 0) { if (ind != grdItemSubCategory.SelectedIndex) { this.lblStatusMessage.Text = "Item SubCategory Already Exists"; this.programmaticModalPopup.Show(); return; } } } } } } else { int index = -1; for (int i = 0; i < lstall.Count; i++) { if (i != lstItemCategory.SelectedIndex) { index = lstall[i].LstItemSubCategory.FindIndex( delegate(ATTInvItemSubCategory ob) { return(ob.ItemsSubCategoryName == txSubCategory_Rqd.Text); } ); } if (index >= 0) { this.lblStatusMessage.Text = "Item SubCategory Already Exists"; this.programmaticModalPopup.Show(); return; } else { if (grdItemSubCategory.SelectedIndex < 0) { if (itemsCategory.LstItemSubCategory.Exists( delegate(ATTInvItemSubCategory ob) { return(ob.ItemsSubCategoryName == txSubCategory_Rqd.Text); } )) { this.lblStatusMessage.Text = "Item SubCategory Already Exists"; this.programmaticModalPopup.Show(); return; } } else { int ind = itemsCategory.LstItemSubCategory.FindIndex( delegate(ATTInvItemSubCategory ob) { return(ob.ItemsSubCategoryName == txSubCategory_Rqd.Text); } ); if (ind >= 0) { if (ind != grdItemSubCategory.SelectedIndex) { this.lblStatusMessage.Text = "Item SubCategory Already Exists"; this.programmaticModalPopup.Show(); return; } } } } } } ////////// ATTInvItemsCategory obj = (ATTInvItemsCategory)Session["ItemCategory"]; if (grdItemSubCategory.SelectedIndex > -1) { obj.LstItemSubCategory[grdItemSubCategory.SelectedIndex].ItemsSubCategoryName = txSubCategory_Rqd.Text; obj.LstItemSubCategory[grdItemSubCategory.SelectedIndex].Active = (chkISCActive.Checked == true ? "Y" : "N"); obj.LstItemSubCategory[grdItemSubCategory.SelectedIndex].Action = (obj.LstItemSubCategory[grdItemSubCategory.SelectedIndex].Action == "A" ? "A" : "E"); obj.LstItemSubCategory[grdItemSubCategory.SelectedIndex].EntryBy = ((ATTUserLogin)Session["Login_User_Detail"]).UserName; } else { ATTInvItemSubCategory ob = new ATTInvItemSubCategory(); ob.ItemsSubCategoryName = txSubCategory_Rqd.Text; ob.Active = chkISCActive.Checked == true ? "Y" : "N"; ob.EntryBy = ((ATTUserLogin)Session["Login_User_Detail"]).UserName; ob.Action = "A"; obj.LstItemSubCategory.Add(ob); this.grdItemSubCategory.SelectedIndex = -1; this.txSubCategory_Rqd.Text = ""; this.chkISCActive.Checked = true; } grdItemSubCategory.DataSource = obj.LstItemSubCategory; grdItemSubCategory.DataBind(); grdItemSubCategory.SelectedIndex = -1; txSubCategory_Rqd.Text = ""; this.chkISCActive.Checked = true; }