示例#1
0
    protected void btn_del_Click(object sender, System.EventArgs e)
    {
        string strsql = "delete from tbl_banner  where bannerid = @id";
        int    i      = DbControl.Data_delete(strsql, Selected_id.Value);

        ListView1.DataBind();
    }
示例#2
0
        public static int Article_item_Update(List <article.ItemData> itemData)
        {
            string strsql           = "delete from tbl_article_item where articleId =@id";
            NameValueCollection nvc = new NameValueCollection();
            int i = 0;

            foreach (article.ItemData idx in itemData)

            {
                if (i == 0)
                {
                    i = DbControl.Data_delete(strsql, idx.Id.ToString());
                }
                i++;
                nvc.Clear();
                strsql = @"insert into tbl_article_item (articleId,secno,subject,contents)
                    values (@articleId,@secno,@subject,@contents)";
                nvc.Add("articleId", idx.Id.ToString());
                nvc.Add("secno", idx.Secno.ToString());
                nvc.Add("subject", idx.Title);
                nvc.Add("contents", idx.Contents);
                i = DbControl.Data_add(strsql, nvc);
            }

            return(i);
        }
示例#3
0
    //刪除
    protected void link_delete(object sender, System.EventArgs e)
    {
        LinkButton obj = sender as LinkButton;

        Selected_id.Value = obj.CommandArgument;
        string strsql = "update tbl_banner set status='D'  where bannerid = @id";
        int    i      = DbControl.Data_delete(strsql, Selected_id.Value);

        selectSQL();
    }
示例#4
0
    protected void Btn_save_Click(object sender, System.EventArgs e)
    {
        LinkButton obj = sender as LinkButton;


        //-----------------------------------------------------------------------
        string uploadPath = Server.MapPath("~/webimages/banner/");
        string Filename   = "";

        string[] allowedExtensions = { ".jpg", ".jpeg", ".png", ".gif" };

        string fileExtension;

        if (FileUpload1.HasFile)
        {
            fileExtension = Path.GetExtension(FileUpload1.FileName.ToLower());
            if (Array.IndexOf(allowedExtensions, fileExtension) >= 0)
            {
                Filename = DateTime.Now.ToString("yyyyMMddhhmmssfff") + fileExtension;
                FileUpload1.PostedFile.SaveAs(uploadPath + Filename);
                HiddenField1.Value = Filename;
            }
            else
            {
                Response.Write("檔案格式有誤");
            }
        }

        NameValueCollection nvc = new NameValueCollection();
        string strsql           = "";


        if (Btn_save.CommandArgument == "add")
        {
            strsql = @"INSERT  INTO tbl_banner(filename, path, url, targetblank, sort, enabledate, disabledate, 
                status, title, createdate, createuserid,  classId,viewcount,contents,categoryid,articleId
                ) VALUES (@filename, @path, @url, @targetblank,
                @sort, @enabledate, @disabledate, @status, @title, @createdate
                , @createuserid,  @classId,0,@contents, @categoryid, @articleId) ";
            nvc.Add("createdate", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
            nvc.Add("createuserid", Session["userid"].ToString());
        }
        else
        {
            strsql = "delete from tbl_recommend where bannerid=@id";
            DbControl.Data_delete(strsql, Selected_id.Value);

            strsql = @"UPDATE  tbl_banner SET filename =@filename, path =@path, url =@url, targetblank =@targetblank, 
            sort =@sort, enabledate =@enabledate, disabledate =@disabledate, status =@status, title =@title, 
             classId =@classId ,contents=@contents,categoryid=@categoryid,articleId=@articleId where bannerid=@bannerid";
            nvc.Add("bannerid", Selected_id.Value);
        }
        nvc.Add("filename", HiddenField1.Value);
        nvc.Add("path", "webimages/banner/");
        nvc.Add("url", t_url.Text);
        nvc.Add("targetblank", t_targetblank.Text);
        nvc.Add("sort", t_sort.Text);
        nvc.Add("enabledate", sdate.Text + " " + stime.SelectedValue + ":00:00");
        nvc.Add("status", t_status.SelectedValue);
        nvc.Add("title", t_title.Text);
        nvc.Add("classId", classid.SelectedValue);
        nvc.Add("categoryid", DropDownList2.SelectedValue);
        nvc.Add("articleId", DropDownList3.SelectedValue);
        if (edate.Text != "")
        {
            nvc.Add("disabledate", edate.Text + " " + etime.SelectedValue + ":00:00");
        }
        else
        {
            nvc.Add("disabledate", "DBNull");
        }
        nvc.Add("contents", contents.Text);
        int i = DbControl.Data_add(strsql, nvc);

        if (Btn_save.CommandArgument == "add")
        {
            strsql = "select max(bannerid ) from tbl_banner ";
            DataTable dt = DbControl.Data_Get(strsql, nvc);
            Selected_id.Value = dt.Rows[0][0].ToString();
            dt.Dispose();
        }

        for (i = 0; i < classid.Items.Count; i++)
        {
            if (classid.Items[i].Selected)
            {
                nvc.Clear();
                strsql = "insert into tbl_recommend (bannerid,classid) values (@bannerid,@classid) ";
                nvc.Add("bannerid", Selected_id.Value);
                nvc.Add("classid", classid.Items[i].Value);
                DbControl.Data_add(strsql, nvc);
            }
        }
        selectSQL();
        MultiView1.ActiveViewIndex = 0;
        cleaninput();
    }
示例#5
0
        public static int Article_Update(article.MainData ad)
        {
            article.Lesson Lesson = ad.Lesson;

            string strsql           = @"update  tbl_article set 
                    subject =@subject,pic=@pic,subtitle=@subtitle,postday=@postday,contents=@contents ,
                    keywords=@keywords,status=@status,author=@author,recommend=@recommend
                    ,kind=@kind,YoutubeUrl=@YoutubeUrl,NextRead=@NextRead,ViewCount=@ViewCount,
                    flag=@flag
                    where articleId =@id ";
            NameValueCollection nvc = new NameValueCollection
            {
                { "subject", ad.Subject },
                { "pic", ad.Pic },
                { "subtitle", ad.SubTitle },
                { "postday", ad.PostDay.ToString("yyyy/MM/dd") },
                { "contents", ad.Contents },
                { "keywords", ad.Keywords },
                { "author", ad.Author },
                { "status", ad.Status },
                { "recommend", ad.Recommend },
                { "kind", ad.kind == "L" ? "Y":"N" },
                { "YoutubeUrl", ad.YoutubeUrl },
                { "NextRead", ad.NextRead },
                { "flag", ad.Flag },
                { "ViewCount", ad.Viewcount.ToString() }
                //{ "startday",ad.StartDay.ToString("yyyy/MM/dd")  },
                //{ "endday",ad.EndDay.ToString("yyyy/MM/dd") },
            };
            int i = DbControl.Data_Update(strsql, nvc, ad.Id.ToString());

            nvc.Clear();
            strsql = "delete from tbl_article_tag where articleId =@id and unitid =13 ";
            i      = DbControl.Data_delete(strsql, ad.Id.ToString());

            string[] tags = ad.Tags;
            foreach (string s in tags)
            {
                nvc.Clear();
                strsql = @"insert into tbl_article_tag (articleId,tagid,unitid)
                    values (@articleId,@tagid,@unitid)";
                nvc.Add("articleId", ad.Id.ToString());
                nvc.Add("tagid", s);
                nvc.Add("unitid", "13");
                i = DbControl.Data_add(strsql, nvc);
            }
            strsql = "delete from Tbl_article_category where articleId =@id";
            i      = DbControl.Data_delete(strsql, ad.Id.ToString());


            List <Category> categoryid = ad.Category;

            foreach (var s in categoryid)
            {
                nvc.Clear();
                strsql = @"insert into Tbl_article_category (articleId,categoryid)
                    values (@articleId,@categoryid)";
                nvc.Add("articleId", ad.Id.ToString());
                nvc.Add("categoryid", s.CategoryId.ToString());
                i = DbControl.Data_add(strsql, nvc);
            }
            nvc.Clear();

            //  bool exists = Lesson.Exists(p => p.Id == ad.Id);
            if (Lesson.Id > 0)
            {
                //  var L = Lesson.Find(p => p.Id == ad.Id);
                strsql = "delete from tbl_lesson  where articleId =@id ";
                DbControl.Data_delete(strsql, ad.Id.ToString());
                nvc.Clear();
                strsql = @"insert into tbl_lesson (articleId,address,startday,endday,lessontime) values 
                     (@id,@address,@startday,@endday,@lessontime) ";
                nvc.Add("id", ad.Id.ToString());
                nvc.Add("address", Lesson.Address);
                nvc.Add("lessontime", Lesson.Lessontime);
                nvc.Add("startday", Lesson.StartDay.ToShortDateString());
                nvc.Add("endday", Lesson.EndDay.ToShortDateString());
                i = DbControl.Data_add(strsql, nvc);
                nvc.Clear();
                strsql = "delete from tbl_article_tag  where articleId =@id and unitid =14";
                i      = DbControl.Data_delete(strsql, ad.Id.ToString());

                string[] lecturer = Lesson.Lecturer;
                foreach (string s in lecturer)
                {
                    nvc.Clear();
                    strsql = @"insert into tbl_article_tag (articleId,tagid,unitid)
                        values (@articleId,@tagid,@unitid)";
                    nvc.Add("articleId", ad.Id.ToString());
                    nvc.Add("tagid", s);
                    nvc.Add("unitid", "14");
                    i = DbControl.Data_add(strsql, nvc);
                }
                nvc.Clear();

                //strsql = "delete from  tbl_lesson_class where   articleId =@id";
                //i = DbControl.Data_delete(strsql, ad.Id.ToString());
                List <article.LessonDetail> detail = Lesson.LessonDetail;
                foreach (var v in detail)
                {
                    nvc.Clear();
                    string lessonId = v.LessonId.ToString();
                    if (lessonId == "0" || lessonId == "")
                    {
                        strsql = @"insert into tbl_lesson_class
                        (articleId, price, sellprice,limitnum,description,sort,strdat,enddat,flag)
                        values (@articleId,  @price, @sellprice,@limitnum,@description,@sort
                        ,@strdat,@enddat,@flag)";
                    }
                    else
                    {
                        strsql = @"update  tbl_lesson_class set articleId=@articleId, 
                        price=@price, sellprice=@sellprice,limitnum=@limitnum,
                        description=@description,sort=@sort 
                        ,strdat=@strdat,enddat=@enddat,flag=@flag where lessonId=@lessonId ";
                    }
                    nvc.Add("lessonId", lessonId);
                    nvc.Add("articleId", ad.Id.ToString());
                    nvc.Add("description", v.Description);
                    nvc.Add("limitnum", v.Limitnum.ToString());
                    nvc.Add("price", v.Price.ToString());
                    nvc.Add("sellprice", v.Sellprice.ToString());
                    nvc.Add("sort", v.LessonId.ToString());
                    nvc.Add("strdat", v.Strdat.ToString("yyyy/MM/dd"));
                    nvc.Add("enddat", v.Enddat.ToString("yyyy/MM/dd"));
                    nvc.Add("flag", v.Flag);
                    i = DbControl.Data_add(strsql, nvc);
                }
            }
            nvc.Clear();
            strsql = "update  tbl_article_file set articleid =@articleid  where (articleId =@tempid or tempid=@tempid)";
            nvc.Add("articleId", ad.Id.ToString());
            nvc.Add("tempid", ad.Tempid);
            i = DbControl.Data_add(strsql, nvc);

            return(i);
        }