コード例 #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 productdata (viewcount) values (@viewcount ) ";
            nvc.Add("viewcount", "0");
            i      = admin_contrl.Data_add(strsql, nvc);
            strsql = "select max(p_id ) from productdata  where p_id >@p_id ";
            nvc.Clear();
            nvc.Add("p_id", "0");
            DataTable dt = admin_contrl.Data_Get(strsql, nvc);
            p_id.Text = dt.Rows[0][0].ToString();
        }

        string img_path = "../upload/";

        if (Image1.ImageUrl != "")
        {
            stringArray[1] = p_id.Text + "-1.jpg";
        }
        if (Image2.ImageUrl != "")
        {
            stringArray[2] = p_id.Text + "-2.jpg";
        }
        if (Image3.ImageUrl != "")
        {
            stringArray[3] = p_id.Text + "-3.jpg";
        }
        if (Imagelogo.ImageUrl != "")
        {
            stringArray[0] = p_id.Text + "-logo.jpg";
        }
        if (Imagebanner.ImageUrl != "")
        {
            stringArray[4] = p_id.Text + "-banner.jpg";
        }


        if (FileUpload1.FileName != "")
        {
            FileUpload1.SaveAs(Server.MapPath(img_path + p_id.Text + "-1.jpg"));
            stringArray[1] = p_id.Text + "-1.jpg";
        }
        if (FileUpload2.FileName != "")
        {
            FileUpload2.SaveAs(Server.MapPath(img_path + p_id.Text + "-2.jpg"));
            stringArray[2] = p_id.Text + "-2.jpg";
        }
        if (FileUpload3.FileName != "")
        {
            FileUpload3.SaveAs(Server.MapPath(img_path + p_id.Text + "-3.jpg"));
            stringArray[3] = p_id.Text + "-3.jpg";
        }
        if (FileUploadlogo.FileName != "")
        {
            FileUploadlogo.SaveAs(Server.MapPath(img_path + p_id.Text + "-logo.jpg"));
            stringArray[0] = p_id.Text + "-logo.jpg";
        }
        if (FileUploadbanner.FileName != "")
        {
            FileUploadbanner.SaveAs(Server.MapPath(img_path + p_id.Text + "-banner.jpg"));
            stringArray[4] = p_id.Text + "-banner.jpg";
        }
        if (sort.Text == "")
        {
            sort.Text = "0";
        }
        strsql = @"UPDATE  productdata  SET productname=@productname,price=@price, banner=@banner,logo=@logo
                ,description = @description, storage = @storage, pic1 = @pic1, pic2 = @pic2,pic3 = @pic3,memo=@memo,
                c_Id = @c_Id,  status = @status,sort=@sort,Pricing=@Pricing,Savetxt=@Savetxt,selltxt=@selltxt where p_id=@id ";
        nvc.Clear();
        nvc.Add("price", price1.Text);
        nvc.Add("productname", productname.Text);
        nvc.Add("storage", storage.Text);
        nvc.Add("description", description.Text);
        nvc.Add("status", status.SelectedValue);

        nvc.Add("c_Id", c_id.SelectedValue);
        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("logo", stringArray[0] == null ? "" : stringArray[0]);
        nvc.Add("banner", stringArray[4] == null ? "" : stringArray[4]);
        nvc.Add("memo", memo.Text);
        nvc.Add("sort", sort.Text);
        nvc.Add("Pricing", Pricing.Text);
        nvc.Add("Savetxt", Savetxt.Text);
        nvc.Add("selltxt", selltxt.Text);
        i = admin_contrl.Data_update(strsql, nvc, p_id.Text);

        strsql = @"delete   productprice   where p_id=@id ";
        nvc.Clear();
        nvc.Add("p_id", p_id.Text);
        i = admin_contrl.Data_update(strsql, nvc, p_id.Text);
        for (i = 1; i <= 10; i++)
        {
            strsql = @"insert into   productprice  (secno,p_id,num,price) values (@i,@p_id,@num,@price)  ";
            nvc.Clear();
            nvc.Add("@i", i.ToString());
            nvc.Add("p_id", p_id.Text);
            ContentPlaceHolder mp;
            mp = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
            MultiView mu1;
            mu1 = (MultiView)mp.FindControl("MultiView1");
            View vi2 = (View)mu1.FindControl("view2");
            nvc.Add("i", i.ToString());
            TextBox num  = (TextBox)vi2.FindControl("TextBox" + i.ToString());
            TextBox temp = (TextBox)vi2.FindControl("price" + i.ToString());
            nvc.Add("num", num.Text);
            nvc.Add("price", temp.Text);
            admin_contrl.Data_add(strsql, nvc);
        }
        selectSQL();
        MultiView1.ActiveViewIndex = 0;
    }
コード例 #2
0
ファイル: product.aspx.cs プロジェクト: kuan0904/x-cms
    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;
    }