コード例 #1
0
        public slideshowInfo GetInfo(int id)
        {
            slideshowInfo info = null;

            SqlParameter[] param =
            {
                new SqlParameter("@id", id)
            };
            var r = DataHelper.ExecuteReader(Config.ConnectString, "usp_slideshow_GetById", param);

            if (r != null)
            {
                info = new slideshowInfo();
                while (r.Read())
                {
                    info.id    = Int32.Parse(r["id"].ToString());
                    info.name  = r["name"].ToString();
                    info.image = r["image"].ToString();
                    info.alt   = r["alt"].ToString();
                    info.link  = r["link"].ToString();
                }
                r.Close();
                r.Dispose();
            }
            return(info);
        }
コード例 #2
0
        private void save()
        {
            string sImage = UploadImage(HD_Image.Value);

            if (sImage != "")
            {
                HD_Image.Value = sImage;
            }

            int           id   = UntilityFunction.IntegerForNull(HD_ID.Value);
            slideshowInfo info = new slideshowInfo();

            info.id    = id;
            info.name  = TB_Name.Text;
            info.image = HD_Image.Value;
            info.alt   = TB_Alt.Text;
            info.link  = TB_Link.Text;
            if (id > 0)
            {
                ServiceFactory.GetInstanceslideshow().Update(info);
                MessageBox.Show("Cập nhật thành công");
            }
            else
            {
                HD_ID.Value = ServiceFactory.GetInstanceslideshow().Add(info).ToString();
                MessageBox.Show("Thêm mới thành công");
                LB_Messenger.Text = "Sửa thông tin slideshow";
            }

            Image1.ImageUrl = info.image != ""
                                      ? Config.GetPathSlideshow + info.image
                                      : Config.GetPathNoImage;
        }
コード例 #3
0
 public int Add(slideshowInfo info)
 {
     SqlParameter[] param =
     {
         new SqlParameter("@name",  info.name),
         new SqlParameter("@image", info.image),
         new SqlParameter("@alt",   info.alt),
         new SqlParameter("@link",  info.link)
     };
     return(int.Parse(DataHelper.ExecuteScalar(Config.ConnectString, "usp_slideshow_Add", param).ToString()));
 }
コード例 #4
0
 public int Update(slideshowInfo info)
 {
     SqlParameter[] param =
     {
         new SqlParameter("@id",    info.id)
         ,                          new SqlParameter("@name",info.name),
         new SqlParameter("@image", info.image),
         new SqlParameter("@alt",   info.alt),
         new SqlParameter("@link",  info.link)
     };
     return(DataHelper.ExecuteNonQuery(Config.ConnectString, "usp_slideshow_Update", param));
 }
コード例 #5
0
        public List <slideshowInfo> GetList(int pageIndex, int pageSize, out int total)
        {
            List <slideshowInfo> list = null;
            var t = 0;

            SqlParameter[] param =
            {
                new SqlParameter("@pageIndex", pageIndex),
                new SqlParameter("@pageSize",  pageSize),
                new SqlParameter("@totalrow",  DbType.Int32)
                {
                    Direction = ParameterDirection.Output
                }
            };
            SqlCommand comx;
            var        r = DataHelper.ExecuteReader(Config.ConnectString, "usp_slideshow_GetList", param, out comx);

            if (r != null)
            {
                list = new List <slideshowInfo>();
                while (r.Read())
                {
                    var info = new slideshowInfo();
                    info.id    = Int32.Parse(r["id"].ToString());
                    info.name  = r["name"].ToString();
                    info.image = r["image"].ToString();
                    info.alt   = r["alt"].ToString();
                    info.link  = r["link"].ToString();


                    list.Add(info);
                }
                r.Close();
                r.Dispose();
                t = int.Parse(comx.Parameters[2].Value.ToString());
            }

            total = t;
            return(list);
        }
コード例 #6
0
        public List <slideshowInfo> GetAll()
        {
            List <slideshowInfo> list = null;
            var r = DataHelper.ExecuteReader(Config.ConnectString, "usp_slideshow_GetAll", null);

            if (r != null)
            {
                list = new List <slideshowInfo>();
                while (r.Read())
                {
                    var info = new slideshowInfo();
                    info.id    = Int32.Parse(r["id"].ToString());
                    info.name  = r["name"].ToString();
                    info.image = r["image"].ToString();
                    info.alt   = r["alt"].ToString();
                    info.link  = r["link"].ToString();

                    list.Add(info);
                }
                r.Close();
                r.Dispose();
            }
            return(list);
        }