Ejemplo n.º 1
0
    protected void Btn_save_Click(object sender, System.EventArgs e)
    {
        int                 i      = 0;
        LinkButton          obj    = sender as LinkButton;
        NameValueCollection nvc    = new NameValueCollection();
        string              strsql = "";

        if (Btn_save.CommandArgument == "copy" || Btn_save.CommandArgument == "add")
        {
            strsql = "insert into tbl_productdata (viewcount) values (@viewcount ) ";
            nvc.Add("viewcount", "0");
            i      = DbControl.Data_add(strsql, nvc);
            strsql = "select max(p_id ) from tbl_productdata  where p_id >@p_id ";
            nvc.Clear();
            nvc.Add("p_id", "0");
            DataTable dt = DbControl.Data_Get(strsql, nvc);
            p_id.Text = dt.Rows[0][0].ToString();
        }
        else
        {
            ProductData    = productController.GetProduct(Selected_id.Value);
            stringArray[1] = ProductData.Pic1;
            stringArray[2] = ProductData.Pic2;
            stringArray[3] = ProductData.Pic3;
            stringArray[0] = ProductData.Logo;
        }

        string img_path = "../upload/";
        string picname  = DateTime.Now.ToString("yyyyMMddhhmmssfff");

        if (FileUpload1.FileName != "")
        {
            FileUpload1.SaveAs(Server.MapPath(img_path + picname + "-1.jpg"));
            stringArray[1] = picname + "-1.jpg";
        }
        if (FileUpload2.FileName != "")
        {
            FileUpload2.SaveAs(Server.MapPath(img_path + picname + "-2.jpg"));
            stringArray[2] = picname + "-2.jpg";
        }
        if (FileUpload3.FileName != "")
        {
            FileUpload3.SaveAs(Server.MapPath(img_path + picname + "-3.jpg"));
            stringArray[3] = picname + "-3.jpg";
        }
        if (FileUploadlogo.FileName != "")
        {
            FileUploadlogo.SaveAs(Server.MapPath(img_path + picname + "-logo.jpg"));
            stringArray[0] = picname + "-logo.jpg";
        }
        if (sort.Text == "")
        {
            sort.Text = "0";
        }

        strsql = @"UPDATE  tbl_productdata  SET productname=@productname,price=@price
                ,productcode=@productcode,videourl=@videourl
                ,description = @description, storage = @storage, pic1 = @pic1, pic2 = @pic2
                , pic3 = @pic3 ,keyword = @keyword,memo=@memo,
                categoryid = @categoryid,  status = @status,sort=@sort,logo=@logo
              ,kindid=@kindid, supplierid=@supplierid,spec=@spec where p_id=@id ";
        nvc.Clear();
        nvc.Add("productname", productname.Text);
        nvc.Add("price", price.Text);
        nvc.Add("productcode", productcode.Text);
        nvc.Add("videourl", videourl.Text);
        nvc.Add("storage", storage.Text);
        nvc.Add("description", Server.HtmlDecode(description.Text));
        nvc.Add("status", status.SelectedValue);
        nvc.Add("categoryid", categoryid.SelectedValue);
        nvc.Add("logo", stringArray[0] == null ? "" : stringArray[0]);
        nvc.Add("pic1", stringArray[1] == null ? "" : stringArray[1]);
        nvc.Add("pic2", stringArray[2] == null ? "" : stringArray[2]);
        nvc.Add("pic3", stringArray[3] == null ? "" : stringArray[3]);
        nvc.Add("keyword", Request["keywords"]);
        nvc.Add("memo", memo.Text);
        nvc.Add("spec", spec.Text);
        nvc.Add("sort", sort.Text);
        nvc.Add("supplierid", supplierid.SelectedValue);
        nvc.Add("kindid", "1");

        i = DbControl.Data_Update(strsql, nvc, p_id.Text);
        selectSQL();
        MultiView1.ActiveViewIndex = 0;
    }
Ejemplo n.º 2
0
    protected void Btn_save_Click(object sender, System.EventArgs e)
    {
        int                 i      = 0;
        LinkButton          obj    = sender as LinkButton;
        NameValueCollection nvc    = new NameValueCollection();
        string              strsql = "";

        if (Btn_save.CommandArgument == "copy" || Btn_save.CommandArgument == "add")
        {
            strsql = "insert into Tbl_package (viewcount) values (@viewcount ) ";
            nvc.Add("viewcount", "0");
            i      = DbControl.Data_add(strsql, nvc);
            strsql = "select max(packageid ) from Tbl_package  ";
            nvc.Clear();

            DataTable dt = DbControl.Data_Get(strsql, nvc);
            packageid.Text = dt.Rows[0][0].ToString();
        }


        if (sort.Text == "")
        {
            sort.Text = "0";
        }

        strsql = @"UPDATE  Tbl_package  SET packagename=@packagename,
                status = @status,sort=@sort,shippingfee=@shippingfee
                ,shippingKind=@shippingKind,freeship=@freeship
               ,supplierid=@supplierid ,description=@description
                ,ReMark=@ReMark,Refunds=@Refunds
                where packageid=@packageid ";
        nvc.Clear();
        nvc.Add("packageid", packageid.Text);
        nvc.Add("packagename", packagename.Text);
        nvc.Add("description", Server.HtmlDecode(description.Text));
        nvc.Add("status", status.SelectedValue);
        nvc.Add("sort", sort.Text);
        nvc.Add("shippingfee", shippingfee.Text);
        nvc.Add("freeship", freeship.Text);
        nvc.Add("shippingKind", shippingKind.Text);
        nvc.Add("supplierid", supplierid.SelectedValue);
        nvc.Add("ReMark", ReMark.Text);
        nvc.Add("Refunds", Refunds.Text);
        i = DbControl.Data_add(strsql, nvc);

        strsql = @"delete from tbl_package_product where packageid =@packageid";
        i      = DbControl.Data_Update(strsql, nvc, packageid.Text);
        foreach (RepeaterItem r in Repeater1.Items)
        {
            CheckBox cb = (CheckBox)r.FindControl("CheckBox1");
            if (cb.Checked)
            {
                HiddenField v1 = (HiddenField)r.FindControl("HiddenField1");
                TextBox     t1 = (TextBox)r.FindControl("price");
                TextBox     t2 = (TextBox)r.FindControl("storage");
                strsql = @"insert into tbl_package_product (packageid,p_id,price,storage)
                values (@packageid,@p_id,@price,@storage) ";
                nvc.Clear();
                nvc.Add("packageid", packageid.Text);
                nvc.Add("p_id", v1.Value);
                nvc.Add("price", t1.Text);
                nvc.Add("storage", t2.Text);
                i = DbControl.Data_add(strsql, nvc);
            }
        }

        selectSQL();
        MultiView1.ActiveViewIndex = 0;
    }
Ejemplo n.º 3
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);
        }