protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { fillSiteddl(); if (Convert.ToString(HttpContext.Current.Request.Params["catId"]) != null && Convert.ToString(HttpContext.Current.Request.Params["SiteId"]) != null) { //string strSQL = " SELECT DISTINCT " + // " rgcards_gti24x7.ItemCategoryRelation_Web_Server.Product_Id," + // " rgcards_gti24x7.ItemMaster_Server.Item_Name," + // " rgcards_gti24x7.ItemMaster_Server.Item_Price," + // " rgcards_gti24x7.ItemCategory_Web_Server.Category_Name," + // " rgcards_gti24x7.ItemCategory_Web_Server.Category_Id," + // " 'http://www.giftstoindia24x7.com/Gifts.aspx?proid='+rgcards_gti24x7.ItemMaster_Server.Product_Id+'&CatId='+convert(varchar(250),rgcards_gti24x7.ItemCategory_Web_Server.Category_Id) as url" + // " FROM " + // " rgcards_gti24x7.ItemCategoryRelation_Web_Server " + // " INNER JOIN rgcards_gti24x7.ItemMaster_Server ON (rgcards_gti24x7.ItemCategoryRelation_Web_Server.Product_Id = rgcards_gti24x7.ItemMaster_Server.Product_Id)" + // " INNER JOIN rgcards_gti24x7.ItemCategory_Web_Server ON (rgcards_gti24x7.ItemCategoryRelation_Web_Server.Category_Id = rgcards_gti24x7.ItemCategory_Web_Server.Category_Id)" + // " INNER JOIN rgcards_gti24x7.SiteCatgory_Web_Server ON (rgcards_gti24x7.ItemCategoryRelation_Web_Server.Category_Id = rgcards_gti24x7.SiteCatgory_Web_Server.Category_Id)" + // " WHERE " + // " (rgcards_gti24x7.ItemCategoryRelation_Web_Server.Category_Id = '" + Convert.ToString(HttpContext.Current.Request.Params["catId"]) + "') AND " + // " (rgcards_gti24x7.ItemCategoryRelation_Web_Server.Record_Status = '1') AND " + // " ((rgcards_gti24x7.ItemMaster_Server.Item_colour IS NULL) OR " + // " (rgcards_gti24x7.ItemMaster_Server.Item_colour = '0') OR " + // " (rgcards_gti24x7.ItemMaster_Server.Item_colour = '1'))" + // " and rgcards_gti24x7.SiteCatgory_Web_Server.Site_Id='" + Convert.ToString(HttpContext.Current.Request.Params["SiteId"]) + "'"; // string strSQL = "SELECT DISTINCT " + // "" + strSchema + ".ItemCategoryRelation_Web_Server.Product_Id, " + // "" + strSchema + ".ItemMaster_Server.Item_Name, " + // "" + strSchema + ".ItemMaster_Server.Item_Price, " + // "" + strSchema + ".ItemCategory_Web_Server.Category_Name," + // " " + strSchema + ".SiteCatgory_Web_Server.Category_Id," + // " 'http://www.giftstoindia24x7.com/Gifts.aspx?proid='+rgcards_gti24x7.ItemMaster_Server.Product_Id+'&CatId='+convert(varchar(250),rgcards_gti24x7.ItemCategory_Web_Server.Category_Id) as url" + //" FROM " + // "" + strSchema + ".ItemCategoryRelation_Web_Server " + // "INNER JOIN " + strSchema + ".ItemMaster_Server ON (" + strSchema + ".ItemCategoryRelation_Web_Server.Product_Id = " + strSchema + ".ItemMaster_Server.Product_Id) " + // "INNER JOIN " + strSchema + ".SiteCatgory_Web_Server ON (" + strSchema + ".ItemCategoryRelation_Web_Server.Category_Id = " + strSchema + ".SiteCatgory_Web_Server.Category_Id) " + // "INNER JOIN " + strSchema + ".Category_Category_Relation ON (" + strSchema + ".SiteCatgory_Web_Server.Category_Id = " + strSchema + ".Category_Category_Relation.FetchCategoryId)" + // "INNER JOIN rgcards_gti24x7.ItemCategory_Web_Server ON (" + strSchema + ".ItemCategoryRelation_Web_Server.Category_Id = " + strSchema + ".ItemCategory_Web_Server.Category_Id) " + //"WHERE " + // "(" + strSchema + ".Category_Category_Relation.BaseCategoryId =" + Convert.ToString(HttpContext.Current.Request.Params["catId"]) + ") AND " + // "(" + strSchema + ".SiteCatgory_Web_Server.Site_Id =" + Convert.ToString(HttpContext.Current.Request.Params["SiteId"]) + ") AND " + // "((" + strSchema + ".ItemMaster_Server.Item_colour IS NULL) OR " + // "(" + strSchema + ".ItemMaster_Server.Item_colour = '0') OR " + // "(" + strSchema + ".ItemMaster_Server.Item_colour = '1')) " + // " and (rgcards_gti24x7.ItemMaster_Server.Record_Status = '1')" + //"ORDER BY " + // " " + strSchema + ".ItemMaster_Server.Item_Price DESC "; string strSQL = "SELECT DISTINCT " + "" + strSchema + ".ItemCategoryRelation_Web_Server.Product_Id, " + "" + strSchema + ".ItemMaster_Server.Item_Name, " + "" + strSchema + ".ItemMaster_Server.Item_Price, " + "" + strSchema + ".ItemCategory_Web_Server.Category_Name," + " " + Convert.ToString(HttpContext.Current.Request.Params["catId"]) + "," + "'http://www.'+LOWER(rgcards_gti24x7.POS_BothWay.POS_OName)+'/Gifts.aspx?proid='+rgcards_gti24x7.ItemMaster_Server.Product_Id+'&CatId=" + Convert.ToString(HttpContext.Current.Request.Params["catId"]) + "' as url " + " FROM " + "" + strSchema + ".ItemCategoryRelation_Web_Server " + "INNER JOIN " + strSchema + ".ItemMaster_Server ON (" + strSchema + ".ItemCategoryRelation_Web_Server.Product_Id = " + strSchema + ".ItemMaster_Server.Product_Id) " + "INNER JOIN " + strSchema + ".SiteCatgory_Web_Server ON (" + strSchema + ".ItemCategoryRelation_Web_Server.Category_Id = " + strSchema + ".SiteCatgory_Web_Server.Category_Id) " + "INNER JOIN " + strSchema + ".Category_Category_Relation ON (" + strSchema + ".SiteCatgory_Web_Server.Category_Id = " + strSchema + ".Category_Category_Relation.FetchCategoryId)" + "INNER JOIN rgcards_gti24x7.ItemCategory_Web_Server ON (" + strSchema + ".ItemCategoryRelation_Web_Server.Category_Id = " + strSchema + ".ItemCategory_Web_Server.Category_Id) " + " INNER JOIN rgcards_gti24x7.POS_BothWay ON (rgcards_gti24x7.SiteCatgory_Web_Server.Site_Id = rgcards_gti24x7.POS_BothWay.POS_Id) " + "WHERE " + "(" + strSchema + ".Category_Category_Relation.BaseCategoryId =" + Convert.ToString(HttpContext.Current.Request.Params["catId"]) + ") AND " + "(" + strSchema + ".SiteCatgory_Web_Server.Site_Id =" + Convert.ToString(HttpContext.Current.Request.Params["SiteId"]) + ") AND " + "((" + strSchema + ".ItemMaster_Server.Item_colour IS NULL) OR " + "(" + strSchema + ".ItemMaster_Server.Item_colour = '0') OR " + "(" + strSchema + ".ItemMaster_Server.Item_colour = '1')) " + " and (rgcards_gti24x7.ItemMaster_Server.Record_Status = '1')" + "ORDER BY " + " " + strSchema + ".ItemMaster_Server.Item_Price DESC "; string strError = ""; DataTable dtProd = new DataTable(); // Admin_Module_Works_Select objSelect = new Admin_Module_Works_Select(dtProd, strSQL, strSchema, ref strError); Admin_Module_Works_Select objSelect = null; if (strError == null) { if (dtProd.Rows.Count > 0) { string strFile = Convert.ToString(dtProd.Rows[0]["Category_Name"]) + ".xls"; int[] iColumns = null; string[] sHeaders = { "Product Id", "Item Name", "Item Price", "Category Name", "Category Id", "URL" }; iColumns = new int[sHeaders.Length]; for (int k = 0; sHeaders.Length > k; k++) { iColumns[k] = k; } Export objExport = new Export(); objExport.ExportDetails(dtProd, iColumns, sHeaders, Export.ExportFormat.Excel, strFile); } else { Response.Write("No Record found"); } } else { Response.Write("Error:<br>" + strError); } } } }
private string getProductId(string strUrlName) { string strErr = ""; string strProductId = ""; try { //SqlCommand cmd = conn.CreateCommand(); //cmd.CommandType = CommandType.StoredProcedure; //cmd.CommandText = "rgcards_gti24x7.getProductIdAccordingToUrlName"; //cmd.Parameters.Add(new SqlParameter("@UrlName", SqlDbType.VarChar, 8000)); //cmd.Parameters["@UrlName"].Value = strUrlName; //cmd.Parameters["@UrlName"].Direction = ParameterDirection.Input; //if (conn.State == ConnectionState.Closed) //{ // conn.Open(); //} //strProductId = Convert.ToString(cmd.ExecuteScalar()); Admin_Module_Works_Select myobj = new Admin_Module_Works_Select(); DataTable dtproductid = new DataTable(); if (strUrlName != null) { string sql = " SELECT rgcards_gti24x7.ItemMaster_Server.Product_Id FROM rgcards_gti24x7.ItemMaster_Server WHERE rgcards_gti24x7.ItemMaster_Server.UrlName='" + strUrlName + "' or rgcards_gti24x7.ItemMaster_Server.UrlName='" + strUrlName + "_'"; myobj.GetDataTable(dtproductid, sql, strSchema, ref strErr); if (strErr == null) { if (dtproductid.Rows.Count > 0) { strProductId = Convert.ToString(dtproductid.Rows[0]["Product_Id"]); } } } //else //{ // string sql = " SELECT rgcards_gti24x7.ItemMaster_Server.Product_Id FROM rgcards_gti24x7.ItemMaster_Server WHERE rgcards_gti24x7.ItemMaster_Server.item_name='" + strUrlName.Replace("_", " ") + "'"; // myobj.GetDataTable(dtproductid, sql, strSchema, ref strErr); // if (strErr == null) // { // if (dtproductid.Rows.Count > 0) // { // strProductId = Convert.ToString(dtproductid.Rows[0]["Product_Id"]); // } // } //} } catch (Exception ex) { strErr = "Error!<br/>" + ex.Message; } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } return(strProductId); }
//protected void btnGo_ServerClick(object sender, EventArgs e) //{ // if (ddlSite.SelectedValue != "") // { // string strError = ""; // generateServerControlCategoryTree(1, ref tvCategory, ref strError); // if (strError != null) // { // lblError.Text = strError; // } // } // else // { // lblError.Text = "Please select a Site"; // } //} public void generateServerControlCategoryTree(int intCheckBox, ref TreeView objTreeView, ref string strTreeviewError) { DataTable dtCategory = new DataTable(); SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["DBCON"].ToString()); string strSchema = Convert.ToString(ConfigurationManager.AppSettings["SCHEMA"]); //string strSql = "SELECT " + // " [" + strSchema + "].[ItemCategory_Web_Server].[Category_Id]," + // " [" + strSchema + "].[ItemCategory_Web_Server].[Category_Name]," + // " [" + strSchema + "].[ItemCategory_Web_Server].[Category_Lavel]," + // " [" + strSchema + "].[ItemCategory_Web_Server].[Category_Page]," + // " [" + strSchema + "].[ItemCategory_Web_Server].[Category_ParentID] " + // "FROM " + // " [" + strSchema + "].[ItemCategory_Web_Server] " + // "WHERE" + // " ([" + strSchema + "].[ItemCategory_Web_Server].[Record_Status]=1)" + // "AND " + // " ([" + strSchema + "].[ItemCategory_Web_Server].[Category_Id]!=0)" + // "AND " + // " ([" + strSchema + "].[ItemCategory_Web_Server].[Category_Name]!='')" + // "AND " + // " ([" + strSchema + "].[ItemCategory_Web_Server].[Category_Name] IS NOT NULL)" + // " ORDER BY " + // "[" + strSchema + "].[ItemCategory_Web_Server].[Category_Name];"; string strSql = "SELECT " + " [" + strSchema + "].[ItemCategory_Web_Server].[Category_Id]," + " [" + strSchema + "].[ItemCategory_Web_Server].[Category_Name]," + " [" + strSchema + "].[ItemCategory_Web_Server].[Category_Lavel]," + " [" + strSchema + "].[ItemCategory_Web_Server].[Category_ParentID], " + " [" + strSchema + "].[ItemCategory_Web_Server].[Category_Page] " + "FROM " + " [" + strSchema + "].[ItemCategory_Web_Server] " + "INNER JOIN " + "[" + strSchema + "].[SiteCatgory_Web_Server] " + "ON " + "[" + strSchema + "].[ItemCategory_Web_Server].[Category_Id]=[" + strSchema + "].[SiteCatgory_Web_Server].[Category_Id]" + "WHERE" + " ([" + strSchema + "].[ItemCategory_Web_Server].[Record_Status]=1)" + "AND " + " ([" + strSchema + "].[SiteCatgory_Web_Server].[Record_Status]=1)" + "AND " + " ([" + strSchema + "].[ItemCategory_Web_Server].[Category_Id]!=0)" + "AND " + " ([" + strSchema + "].[SiteCatgory_Web_Server].[Site_Id]='" + Convert.ToString(ddlSite.SelectedValue) + "')" + "AND " + " ([" + strSchema + "].[ItemCategory_Web_Server].[Category_Name] IS NOT NULL)" + " ORDER BY " + "[" + strSchema + "].[ItemCategory_Web_Server].[Category_Name];"; string strError = ""; //Admin_Module_Works_Select objSelect = new Admin_Module_Works_Select(dtCategory, strSql, strSchema, ref strError); Admin_Module_Works_Select objSelect = null; if (strError != null) { strTreeviewError = "There is some error on load...Please press refresh.<br>" + strError; } else { switch (intCheckBox) { case 1: // fill the dropdown with all checkbox strError = ""; CreateServerControlCategoryTreeWithAllCheckBox(dtCategory, ref objTreeView, ref strError); if (strError != null) { strTreeviewError = "There is some error on loading of the tree..Please press refresh.<br>" + strError; } else { strError = ""; } break; default: strTreeviewError = "Invalid parameter"; break; } } }
public string getReWritePath(String strCurrentPath) { int flag = 0; String strCustomPath = ""; string strLastCharWithAspx; string strLastCharWithoutAspx = ""; string withoutaspx = ""; string[] arrCatOrProdIdWithAspx = strCurrentPath.Split(new char[] { '/' }); //if (arrCatOrProdIdWithAspx.Length == 5) //{ // strLastCharWithoutAspx = arrCatOrProdIdWithAspx[2] + "/" + arrCatOrProdIdWithAspx[3]; //} //else if (arrCatOrProdIdWithAspx.Length == 8) //{ // strLastCharWithoutAspx = arrCatOrProdIdWithAspx[2] + "/" + arrCatOrProdIdWithAspx[3] + "/" + arrCatOrProdIdWithAspx[4] + "/" + arrCatOrProdIdWithAspx[5] + "/" + arrCatOrProdIdWithAspx[6]; //} //else //{ // //strLastCharWithAspx = arrCatOrProdIdWithAspx[arrCatOrProdIdWithAspx.Length - 2]; // strLastCharWithoutAspx = arrCatOrProdIdWithAspx[arrCatOrProdIdWithAspx.Length - 2]; //} for (int k = 2; k < arrCatOrProdIdWithAspx.Length - 1; k++) { withoutaspx += arrCatOrProdIdWithAspx[k] + "/"; } //string strLastCharWithAspx = arrCatOrProdIdWithAspx[arrCatOrProdIdWithAspx.Length - 1]; //string[] arrCatOrProdIdWithoutAspx = strLastCharWithAspx.Split(new char[] { '.' }); //strLastCharWithoutAspx = arrCatOrProdIdWithoutAspx[0]; try { //HttpContext.Current.Response.Write("hi"); if (Convert.ToInt32(strLastCharWithoutAspx) >= 1) { flag = 1; string strCategoryId = getCategoryId(arrCatOrProdIdWithAspx); string strCalculatedFolder = getCalculatedFolder(arrCatOrProdIdWithAspx); strCustomPath = "" + strCalculatedFolder + "category.aspx?cat=" + strCategoryId + "&pageno=" + strLastCharWithoutAspx + ""; } else { string strCalculatedFolder = getCalculatedFolder(arrCatOrProdIdWithAspx); strCustomPath = "" + strCalculatedFolder + "DefaultErrorPage.aspx"; } } catch (Exception ex) { if (flag == 0) { try { //string strCategoryId = getCategoryId(arrCatOrProdIdWithAspx); string strCategoryId = getCategoryId_New(withoutaspx); // Console.WriteLine(strCategoryId); // HttpContext.Current.Response.Write("Category id:"+strCategoryId+"<br/>"); // string strProductId = getProductId(strLastCharWithoutAspx); string strCalculatedFolder = getCalculatedFolder(arrCatOrProdIdWithAspx); //strCustomPath = "" + strCalculatedFolder + "mainProduct.aspx?cat=" + strCategoryId + "&pid=" + strProductId + ""; if (strCategoryId != "") { string sql = "SELECT " + " rgcards_gti24x7.SiteCatgory_Web_Server.CategoryPage" + " FROM " + " rgcards_gti24x7.ItemCategory_Web_Server" + " INNER JOIN rgcards_gti24x7.SiteCatgory_Web_Server ON (rgcards_gti24x7.ItemCategory_Web_Server.Category_Id = rgcards_gti24x7.SiteCatgory_Web_Server.Category_Id)" + " where rgcards_gti24x7.ItemCategory_Web_Server.Category_Id=" + strCategoryId + "" + " and rgcards_gti24x7.SiteCatgory_Web_Server.site_Id=" + Convert.ToInt32(HttpContext.Current.Application["SiteId"]) + ""; DataTable dtpage = new DataTable(); string strerror = ""; string StaticPage = ""; Admin_Module_Works_Select myobj = new Admin_Module_Works_Select(); //try //{ myobj.GetDataTable(dtpage, sql, strSchema, ref strerror); if (strerror == null) { if (dtpage.Rows.Count > 0) { StaticPage = Convert.ToString(dtpage.Rows[0]["CategoryPage"]); } } //} //catch (Exception ex) //{ // strerror = "Error!<br/>" + ex.Message; //} if (StaticPage == "") { //strCustomPath = "" + strCalculatedFolder + "category.aspx?cat=" + strCategoryId + "&pid=" + strProductId + ""; strCustomPath = "" + strCalculatedFolder + "category.aspx?cat=" + strCategoryId + "&pageno=1"; //strCustomPath = "category.aspx?cat=" + strCategoryId + "&pageno=1"; } else { strCustomPath = "" + strCalculatedFolder + "" + StaticPage + "?cat=" + strCategoryId + "&pageno=1"; } } } catch { string strCalculatedFolder = getCalculatedFolder(arrCatOrProdIdWithAspx); strCustomPath = "" + strCalculatedFolder + "DefaultErrorPage.aspx"; } } else if (flag == 1) { string strCalculatedFolder = getCalculatedFolder(arrCatOrProdIdWithAspx); strCustomPath = "" + strCalculatedFolder + "DefaultErrorPage.aspx"; } } return(strCustomPath); }