Пример #1
0
 public CustomPage GetCustomPage(string url)
 {
     CustomPage customPage = null;
     using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
     {
         using (SqlCommand objComm = new SqlCommand("getCustomPageByUrl", objConn))
         {
             objConn.Open();
             objComm.CommandType = CommandType.StoredProcedure;
             objComm.Parameters.Add("@url", SqlDbType.NVarChar, 50).Value = url;
             using (SqlDataReader reader = objComm.ExecuteReader())
             {
                 if (reader.HasRows)
                     customPage = new CustomPage();
                 while (reader.Read())
                 {
                     customPage.CustomPageID = reader.GetInt32(10);
                     customPage.Title = reader.GetString(0);
                     customPage.Description = reader.GetString(1);
                     customPage.Url = reader.GetString(2);
                     customPage.Content = reader.GetString(3);
                     customPage.Heading = reader.GetString(4);
                     customPage.InsertDate = Common.ConvertToLocalTime(reader.GetDateTime(5));
                     customPage.UpdateDate = Common.ConvertToLocalTime(reader.GetDateTime(6));
                     customPage.Head = reader.GetString(7);
                     customPage.SortIndex = reader.GetInt32(8);
                     customPage.ImageUrl = reader.GetString(9);
                     customPage.CustomPageCategoryID = reader.GetInt32(11);
                     customPage.IsActive = reader.GetBoolean(12);
                 }
             }
         }
     }
     return customPage;
 }
Пример #2
0
 public int Save(CustomPage customPage)
 {
     CustomPageDL customPageDL=new CustomPageDL();
     if (customPage.CustomPageID > 0)
         return customPageDL.Update(customPage);
     else
         return customPageDL.Save(customPage);
 }
Пример #3
0
        public int Update(CustomPage customPage)
        {
            int status = 0;
            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
            {
                using (SqlCommand objComm = new SqlCommand("customPageUpdate", objConn))
                {
                    objConn.Open();
                    objComm.CommandType = CommandType.StoredProcedure;
                    objComm.Parameters.Add("@customPageID",SqlDbType.Int).Value=customPage.CustomPageID;
                    objComm.Parameters.Add("@title", SqlDbType.NVarChar, 50).Value = customPage.Title;
                    objComm.Parameters.Add("@description", SqlDbType.NVarChar, 500).Value = customPage.Description;
                    objComm.Parameters.Add("@url", SqlDbType.NVarChar, 50).Value = customPage.Url;
                    objComm.Parameters.Add("@content", SqlDbType.NVarChar).Value = customPage.Content;
                    objComm.Parameters.Add("@heading", SqlDbType.NVarChar, 50).Value = customPage.Heading;
                    objComm.Parameters.Add("@updateDate", SqlDbType.DateTime).Value = customPage.UpdateDate;
                    objComm.Parameters.Add("@head", SqlDbType.NVarChar).Value = customPage.Head;
                    objComm.Parameters.Add("@sortIndex", SqlDbType.Int).Value = customPage.SortIndex;
                    objComm.Parameters.Add("@imageUrl", SqlDbType.NVarChar, 50).Value = customPage.ImageUrl;
                    objComm.Parameters.Add("@customPageCategoryID", SqlDbType.Int).Value = customPage.CustomPageCategoryID;
                    objComm.Parameters.Add("@isActive", SqlDbType.Bit).Value = customPage.IsActive;

                    status = objComm.ExecuteNonQuery();
                }
            }
            return customPage.CustomPageID; ;
        }
Пример #4
0
        public int Save(CustomPage customPage)
        {
            int status = 0;
            try
            {
                using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
                {
                    using (SqlCommand objComm = new SqlCommand("customPageSave", objConn))
                    {
                        objConn.Open();
                        objComm.CommandType = CommandType.StoredProcedure;
                        objComm.Parameters.Add("@title", SqlDbType.NVarChar, 50).Value = customPage.Title;
                        objComm.Parameters.Add("@description", SqlDbType.NVarChar, 500).Value = customPage.Description;
                        objComm.Parameters.Add("@url", SqlDbType.NVarChar, 50).Value = customPage.Url;
                        objComm.Parameters.Add("@content", SqlDbType.NVarChar).Value = customPage.Content;
                        objComm.Parameters.Add("@heading", SqlDbType.NVarChar, 50).Value = customPage.Heading;
                        objComm.Parameters.Add("@insertDate", SqlDbType.DateTime).Value = customPage.InsertDate;
                        //objComm.Parameters.Add("@updateDate", SqlDbType.DateTime).Value = customPage.UpdateDate;
                        objComm.Parameters.Add("@head", SqlDbType.NVarChar).Value = customPage.Heading;
                        objComm.Parameters.Add("@sortIndex", SqlDbType.Int).Value = customPage.SortIndex;
                        objComm.Parameters.Add("@imageUrl", SqlDbType.NVarChar, 50).Value = customPage.ImageUrl;

                        SqlParameter customPageID = new SqlParameter("@customPageID", SqlDbType.Int);
                        customPageID.Direction = ParameterDirection.Output;
                        objComm.Parameters.Add(customPageID);

                        objComm.Parameters.Add("@customPageCategoryID", SqlDbType.Int).Value = customPage.CustomPageCategoryID;
                        objComm.Parameters.Add("@isActive", SqlDbType.Bit).Value = customPage.IsActive;

                        status = objComm.ExecuteNonQuery();

                        customPage.CustomPageID = int.Parse(objComm.Parameters["@customPageID"].Value.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex);
                throw new DLException("Error while saving custom page", ex);
            }
            return customPage.CustomPageID;
        }
Пример #5
0
        public List<CustomPage> GetCustomPages()
        {
            List<CustomPage> customPages = null;
            CustomPage customPage=null;
            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
            {
                using (SqlCommand objComm = new SqlCommand("getCustomPages", objConn))
                {
                    objConn.Open();
                    objComm.CommandType = CommandType.StoredProcedure;
                    using (SqlDataReader reader = objComm.ExecuteReader())
                    {
                        if (reader.HasRows)
                            customPages = new List<CustomPage>();
                        while (reader.Read())
                        {
                            customPage = new CustomPage();
                            customPage.CustomPageID = reader.GetInt32(0);
                            customPage.Title = reader.GetString(1);
                            customPage.Description = reader.GetString(2);
                            customPage.Url = reader.GetString(3);
                            customPage.Content = reader.GetString(4);
                            customPage.Head = reader.GetString(5);
                            customPage.Heading = reader.GetString(6);
                            customPage.InsertDate = Common.ConvertToLocalTime(reader.GetDateTime(7));
                            customPage.UpdateDate = Common.ConvertToLocalTime(reader.GetDateTime(8));
                            customPage.SortIndex = reader.GetInt32(9);
                            customPage.CustomPageCategoryID = reader.GetInt32(10);
                            customPage.ImageUrl = reader.GetString(11);
                            customPage.IsActive = reader.GetBoolean(12);

                            customPages.Add(customPage);
                        }
                    }
                }
            }
            return customPages;
        }
Пример #6
0
        private void save()
        {
            try
            {
                CustomPage customPage = new CustomPage();
                customPage.CustomPageID = (ViewState["customPageID"] != null) ? int.Parse(ViewState["customPageID"].ToString()) : 0;
                int customPageID = customPage.CustomPageID;
                customPage.Title = txtTitle.Text;
                customPage.Description = txtDescription.Text;
                customPage.Url = txtUrl.Text;
                customPage.Heading = txtHeading.Text;
                customPage.Head = txtHead.Text;
                customPage.InsertDate = DateTime.Now.ToUniversalTime();
                customPage.UpdateDate = DateTime.Now.ToUniversalTime();
                customPage.Content = txtContent.Text;
                customPage.SortIndex = 1;
                customPage.ImageUrl = string.Empty;
                customPage.IsActive = chkIsActive.Checked;
                customPage.CustomPageCategoryID = int.Parse(cmbCustomPageCategory.SelectedValue);

                CustomPageBL customPageBL = new CustomPageBL();
                customPage.CustomPageID = customPageBL.Save(customPage);

                //if (customPageID == 0)
                    //Common.AddUrlRewrite(customPage.Url, "customPage.aspx");

                lblTitleHeading.Text = customPage.Heading;
                ViewState.Add("customPageID", customPage.CustomPageID);
                ViewState.Add("pageTitle", customPage.Title);

                divAlert.Visible = true;
                divAlert.Attributes["class"] = "alert alert-success text-center";
                lblAlert.Text = "Custom page saved";
            }
            catch (Exception ex)
            {
                divAlert.Visible = true;
                divAlert.Attributes["class"] = "alert alert-danger text-center";
                lblAlert.Text = ex.Message;
            }
        }