protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { int SubCategoryId = Convert.ToInt32(e.CommandArgument); taSubCategory.Delete(SubCategoryId); BindData(); } if (e.CommandName == "Edit") { int SubCategoryId = Convert.ToInt32(e.CommandArgument); int CompanyId = 0; int CategoryId = 0; ylib = new ClassP.ylibWebClass(concls.connect()); CategoryId = Convert.ToInt16(ylib.GiveTableQueryValue("select CategoryId from SubCategory where SubCategoryId=" + SubCategoryId)); CompanyId = Convert.ToInt16(ylib.GiveTableQueryValue("select CompanyId from Category where CategoryId=" + CategoryId)); Response.Redirect("SubCategoryAdd.aspx?CompanyId=" + CompanyId + "&CategoryId=" + CategoryId + "&SubCategoryId=" + SubCategoryId); } }
private Boolean DoesProductExists(int SectionCode, int ProductId) { string SearchString = ""; Boolean Exists = false; ylib = new ClassP.ylibWebClass(constr.connect()); DataTable DT; int CompanyId_; int SubCategoryId_; int CategoryId_; int ProductGroupCode_; #region SetListVariables CompanyId_ = StringOperation.QueryStringInt16Value(Request.QueryString["CompanyId_"]); CategoryId_ = StringOperation.QueryStringInt16Value(Request.QueryString["CategoryId_"]); SubCategoryId_ = StringOperation.QueryStringInt16Value(Request.QueryString["SubCategoryId_"]); ProductGroupCode_ = StringOperation.QueryStringInt16Value(Request.QueryString["ProductGroupCode_"]); #endregion #region SetSelectionLabel if (CompanyId_ != 0 && CategoryId_ != 0 && SubCategoryId_ != 0 && ProductGroupCode_ != 0) SearchString = " CompanyId=" + CompanyId_ + " and CategoryId =" + CategoryId_ + " and SubCategoryId=" + SubCategoryId_ + " and ProductGroupCode=" + ProductGroupCode_; else if (CompanyId_ != 0 && CategoryId_ != 0 && SubCategoryId_ != 0) SearchString = " CompanyId=" + CompanyId_ + " and CategoryId =" + CategoryId_ + " and SubCategoryId=" + SubCategoryId_ + " and ProductGroupCode is null" ; else if (CompanyId_ != 0 && CategoryId_ != 0) SearchString = " CompanyId=" + CompanyId_ + " and CategoryId =" + CategoryId_ + " and SubCategoryId is null and ProductGroupCode is null"; else if (CompanyId_ != 0) SearchString = " CompanyId=" + CompanyId_ + " and CategoryId is null and SubCategoryId is null and ProductGroupCode is null"; ; #endregion #region SetProductCount if (SearchString != "") { SearchString = SearchString + " and sectioncode=" + SectionCode + " and ProductId=" + ProductId; SearchString = "SELECT ProductId,ProductTitle,ProductGroupDescription,SubCategoryName,CategoryName FROM [v_ProductMainPageSection] where " + SearchString; DT = ylib.GiveDataTable_BySQLStatement(SearchString); if (DT.Rows.Count > 0) { Exists = true; } } #endregion return Exists; }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; ProductGroupCode = 0; if (Request.QueryString["ID"] != null) { if (Request.QueryString["ID"] == "True") { lblMsg.Visible = true; lblMsg.Text = "Successfully Added"; } } LoadCompanies(); SelectCategories(); SelectSubCategories(); if (Request.QueryString["ProductGroupCode"] != null) { ProductGroupCode = Convert.ToInt16(Request.QueryString["ProductGroupCode"]); ylib = new ClassP.ylibWebClass(concls.connect()); txtProductGroupName.Text = ylib.GiveTableQueryValue("select ProductGroupDescription from ProductGroup where ProductGroupCode=" + ProductGroupCode); ddlSubCategory.Enabled = false; ddlCategory.Enabled = false; ddlCompany.Enabled = false; lblFormLabel.Text = "Edit Product Group"; btnAdd.Text = "Edit"; } }
private void BindData() { int SectionCode = 0; FillWebControlClass FCC = new FillWebControlClass(); ylib = new ClassP.ylibWebClass(constr.connect()); lblGroupLevel.Text = Request.QueryString["lblGroupLevel"]; int CompanyId ; int SubCategoryId ; int CategoryId; int ProductGroupCode ; #region SetListVariables SectionCode = StringOperation.QueryStringInt16Value(Request.QueryString["SectionCode"]); CompanyId = StringOperation.QueryStringInt16Value(Request.QueryString["CompanyId"]); CategoryId = StringOperation.QueryStringInt16Value(Request.QueryString["CategoryId"]); SubCategoryId = StringOperation.QueryStringInt16Value(Request.QueryString["SubCategoryId"]); ProductGroupCode = StringOperation.QueryStringInt16Value(Request.QueryString["ProductGroupCode"]); #region Write Cookies if (CompanyId != 0 && CategoryId != 0 && SubCategoryId != 0 && ProductGroupCode != 0) { Response.Cookies["ProductGroupCode"].Value=ProductGroupCode.ToString(); Response.Cookies["ProductGroupCode"].Expires=DateTime.Now.AddDays(1); } else if (CompanyId != 0 && CategoryId != 0 && SubCategoryId != 0) { Response.Cookies["SubCategoryId"].Value=SubCategoryId.ToString(); Response.Cookies["SubCategoryId"].Expires=DateTime.Now.AddDays(1); } else if (CompanyId != 0 && CategoryId != 0) { Response.Cookies["CategoryId"].Value = CategoryId.ToString(); Response.Cookies["CategoryId"].Expires = DateTime.Now.AddDays(1); } else if (CompanyId != 0) { Response.Cookies["CompanyId"].Value = CompanyId.ToString(); Response.Cookies["CompanyId"].Expires = DateTime.Now.AddDays(1); } #endregion #endregion lblSectionName.Text = ylib.giveValue("select SectionName from MainPageSection where SectionCode=" + SectionCode); #region FillDropDownLists dtCompany = taCompany.GetData(); FCC.FillDropDownList(ref ddlCompany, dtCompany, "CompanyName", "CompanyId",true,true,CompanyId.ToString()); dtCategory = taCategory.SelectCategorybyCompanyId(CompanyId); FCC.FillDropDownList(ref ddlCategory, dtCategory, "CategoryName", "CategoryId", true, true, CategoryId.ToString()); dtSubCategory = taSubCategory.GetDataByCategoryId(CategoryId); FCC.FillDropDownList(ref ddlSubCategory, dtSubCategory, "SubCategoryName", "SubCategoryId", true, true, SubCategoryId.ToString()); dtProductGroup = taProductGroup.GetDataBySubCategoryId(SubCategoryId); FCC.FillDropDownList(ref ddlProductGroupCode, dtProductGroup, "ProductGroupDescription", "ProductGroupCode", true, true, ProductGroupCode.ToString()); #endregion if (CompanyId != 0 && CategoryId != 0 && SubCategoryId != 0 && ProductGroupCode!=0) dtProduct = taProduct.GetDataByProductGroupCode(ProductGroupCode); else dtProduct = taProduct.GetDataByProductGroupCode(0); if (dtProduct.Rows.Count > 0) { GridView1.DataSourceID = null; GridView1.DataSource = dtProduct; GridView1.DataBind(); } else { GridView1.DataSourceID = null; GridView1.DataSource = dtProduct; GridView1.DataBind(); lblMsg.Text = "No record found"; return; } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; SubCategoryId = 0; if (Request.QueryString["ID"] != null) { if (Request.QueryString["ID"] == "True") { lblMsg.Visible = true; lblMsg.Text = "Successfully Added"; } } LoadCompanies(); SelectCategories(); if (Request.QueryString["SubCategoryId"] != null) { SubCategoryId = Convert.ToInt16(Request.QueryString["SubCategoryId"]); ylib = new ClassP.ylibWebClass(concls.connect()); txtSubCategory.Text = ylib.GiveTableQueryValue("select SubCategoryName from SubCategory where SubCategoryId=" + SubCategoryId); ddlCategory.Enabled = false; ddlCompany.Enabled = false; lblFormLabel.Text = "Edit Sub Category"; btnAdd.Text = "Edit"; } }