public void LoadMaterialCategory() { try { Session["MaterialCategoryList"] = BLLMaterialCategory.GetMaterialCategory(); this.lstCategoryName.DataSource = (List <ATTMaterialCategory>)Session["MaterialCategoryList"]; this.lstCategoryName.DataTextField = "CategoryName"; this.lstCategoryName.DataValueField = "CategoryID"; this.lstCategoryName.DataBind(); } catch (Exception ex) { throw (ex); } }
void LoadCategory() { try { List <ATTMaterialCategory> l = BLLMaterialCategory.GetMaterialCategory(); l.Insert(0, new ATTMaterialCategory(0, "--- Select Category ---", "", "")); this.ddlCategory_Rqd.DataSource = l; this.ddlCategory_Rqd.DataTextField = "CategoryName"; this.ddlCategory_Rqd.DataValueField = "CategoryID"; this.ddlCategory_Rqd.DataBind(); } catch (Exception ex) { throw ex; } }
protected void btnAdd_Click(object sender, EventArgs e) { ATTMaterialCategory objMC; if (lstCategoryName.SelectedIndex == -1) { objMC = new ATTMaterialCategory(0, txtCategoryName_rqd.Text, ((ATTUserLogin)Session["Login_User_Detail"]).UserName, txtCategoryDescription.Text); } else { objMC = new ATTMaterialCategory(int.Parse(lstCategoryName.SelectedValue), txtCategoryName_rqd.Text, ((ATTUserLogin)Session["Login_User_Detail"]).UserName, txtCategoryDescription.Text); } ObjectValidation OV = BLLMaterialCategory.Validate(objMC); if (OV.IsValid == false) { this.lblStatus.Text = OV.ErrorMessage; return; } List <ATTMaterialCategory> ltMaterialCategory = (List <ATTMaterialCategory>)Session["MaterialCategoryList"]; ATTUserLogin user = ((ATTUserLogin)Session["Login_User_Detail"]); try { if (lstCategoryName.SelectedIndex == -1) { if (user.MenuList["4,2,1"] == null || user.MenuList["4,2,1"].PAdd == "N") { this.lblStatus.Text = Utilities.PreviledgeMsg + " add Material Category."; return; } Previlege pobj = new Previlege(user.UserName, "4,2,1", int.Parse(((HiddenField)this.Master.FindControl("hdnApplicationID")).Value), Previlege.PrevilegeType.P_ADD); if (BLLMaterialCategory.AddMaterialCategory(objMC, pobj)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "ProgressBar", "javascript:callProgressbar();", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "ClearForm", "javascript:clearForm();", true); ltMaterialCategory.Add(objMC); lblStatus.Text = "New Record Added Successfully !!!"; } } else { List <ATTMaterialCategory> lst = (List <ATTMaterialCategory>)Session["MaterialCategoryList"]; ATTMaterialCategory MaterialCategory = lst.Find( delegate(ATTMaterialCategory MC) { return(MC.CategoryID == int.Parse(this.lstCategoryName.SelectedValue)); } ); if ((txtCategoryName_rqd.Text == MaterialCategory.CategoryName) && (txtCategoryDescription.Text == MaterialCategory.CategoryDescription)) { lblStatus.Text = "Please Change Data to Update !!!"; ScriptManager.RegisterStartupScript(this, this.GetType(), "ProgressBar", "javascript:callProgressbar();", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "ClearForm", "javascript:clearForm();", true); } else { if (user.MenuList["4,2,1"] == null || user.MenuList[Session["List_Menuname"].ToString()].PEdit == "N") { this.lblStatus.Text = Utilities.PreviledgeMsg + " update Material Category."; return; } Previlege pobj = new Previlege(user.UserName, "4,2,1", int.Parse(((HiddenField)this.Master.FindControl("hdnApplicationID")).Value), Previlege.PrevilegeType.P_EDIT); if (BLLMaterialCategory.UpdateMaterialCategory(objMC, pobj)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "ProgressBar", "javascript:callProgressbar();", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "ClearForm", "javascript:clearForm();", true); ltMaterialCategory[this.lstCategoryName.SelectedIndex] = objMC; lblStatus.Text = "Existing Record Updated Successfully !!!"; } } } this.lstCategoryName.DataSource = ltMaterialCategory; this.lstCategoryName.DataTextField = "CategoryName"; this.lstCategoryName.DataValueField = "CategoryID"; this.lstCategoryName.DataBind(); //this.lstCategoryName.SelectedIndex = -1; } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "ProgressBar", "javascript:callProgressbar();", true); this.lblStatus.Text = ex.Message; } }