private HyperLink renderProductImage(CoverFlowItem coverFlowItem)
 {
     HyperLink imgLink = new HyperLink();
     imgLink.NavigateUrl = coverFlowItem.NavUrl;
     imgLink.Target = "_blank";
     Image img = new Image();
     img.ImageUrl = coverFlowItem.ImageUrl;
     imgLink.Controls.Add(img);
     return imgLink;
 }
        public static void Add(CoverFlowItem newCoverFlowItem)
        {
            string connectionString = WebConfigurationManager.ConnectionStrings["defaultConnectionString"].ToString();
            SqlConnection sqlConn = new SqlConnection(connectionString);
            sqlConn.Open();

            string cmdString = "INSERT INTO [CoverFlow] (ImageUrl, NavUrl, Pos) VALUES (@imageUrl, @navUrl, @pos)";
            SqlCommand sqlCmd = new SqlCommand(cmdString, sqlConn);
            sqlCmd.Parameters.Add(new SqlParameter("imageUrl", newCoverFlowItem.ImageUrl));
            sqlCmd.Parameters.Add(new SqlParameter("navUrl", newCoverFlowItem.NavUrl));
            sqlCmd.Parameters.Add(new SqlParameter("pos", newCoverFlowItem.Pos));

            sqlCmd.ExecuteNonQuery();

            sqlConn.Close();
        }
        protected void ButtonAdd_Click(object sender, EventArgs e)
        {
            if(FileUploadImg.HasFile == false) return;
            if (TextBoxUrl.Text == "") return;

            string fileName = System.Guid.NewGuid().ToString() + FileUploadImg.FileName.Substring(FileUploadImg.FileName.LastIndexOf("."), FileUploadImg.FileName.Length - FileUploadImg.FileName.LastIndexOf("."));
            string imageUrl = @"~\Image\Gallery\";
            string realUrl = Server.MapPath(@"~\Image\Gallery\");
            imageUrl += fileName;
            realUrl += fileName;
            FileUploadImg.SaveAs(realUrl);

            CoverFlowItem newItem = new CoverFlowItem();
            newItem.ImageUrl = imageUrl;
            newItem.NavUrl = TextBoxUrl.Text;

            CoverFlowService.Add(newItem);

            Response.Redirect(Request.Url.ToString());
        }
Exemple #4
0
 public static void Add(CoverFlowItem newCoverFlowItem)
 {
     newCoverFlowItem.Pos = CoverFlowRepository.AllocateNewPos();
     CoverFlowRepository.Add(newCoverFlowItem);
 }
        public static List<CoverFlowItem> GetAll()
        {
            List<CoverFlowItem> result = new List<CoverFlowItem>();

            string connectionString = WebConfigurationManager.ConnectionStrings["defaultConnectionString"].ToString();
            SqlConnection sqlConn = new SqlConnection(connectionString);
            sqlConn.Open();

            string cmdString = "SELECT * FROM [CoverFlow] ORDER BY Pos";
            SqlCommand sqlCmd = new SqlCommand(cmdString, sqlConn);

            SqlDataReader sqlDataReader = sqlCmd.ExecuteReader();
            if (sqlDataReader.HasRows)
            {
                while (sqlDataReader.Read())
                {
                    CoverFlowItem newCoverFlowItem = new CoverFlowItem();
                    FillCoverFlowItem(sqlDataReader, newCoverFlowItem);
                    result.Add(newCoverFlowItem);
                }
                sqlDataReader.Close();
            }

            return result;
        }
 static void FillCoverFlowItem(SqlDataReader sqlDataReader, CoverFlowItem newCoverFlowItem)
 {
     newCoverFlowItem.ImageUrl = (string)sqlDataReader["ImageUrl"];
     newCoverFlowItem.NavUrl = (string)sqlDataReader["NavUrl"];
     newCoverFlowItem.Pos = (int)sqlDataReader["Pos"];
 }