ASP.NET在线购物网站的设计(7)

来源:xiaoniu168.com 作者:本站原创 添加时间:2011-12-14 点击数:27490

计算机毕业设计商品维护功能介绍:

5.2  商品信息维护界面
此模块主要是对商品信息的维护。展示商品信息列表,可以添加 修改 和删除商品信息。

以下是引用片段:

核心代码如下:
    protected void Button1_Click(object sender, EventArgs e)
    {
        //判断信息是否正确
        if (this.TextBox1.Text.Trim() == "")
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "");           
            return;
        }

        //将相关的图片上传到@"Image\"路径下
        string FileName = "";
        string FileName1;
        string DPath;
        DPath = Server.MapPath("..") + @"\";
        DPath = DPath + @"Image\";
        if (this.File1.PostedFile.FileName != "")
        {
            string[] temp = this.File1.PostedFile.FileName.Split('.');
            string strHzm = "." + temp[temp.Length - 1];

            Guid tmp = Guid.NewGuid();
            FileName = tmp.ToString() + strHzm;
            FileName1 = DPath + tmp.ToString() + strHzm;
            this.File1.PostedFile.SaveAs(FileName1);
            if (Session["imgname"] != null)
            {
                if (File.Exists(DPath + Session["imgname"].ToString()))
                {
                    File.Delete(DPath + Session["imgname"].ToString());
                }
            }
        }

        //根据标志判断是添加还是修改的操作 保存商品信息
        if (Request.QueryString["ID"] != null)
        {
            if (FileName == "")
            {
                DataBase.ExecSql("update spxx set spmc='" + TextBox1.Text + "', spjg=" + this.Textbox2.Text.Trim() + ",spjs='" + this.Textbox3.Text.Trim() + "',sccj='" + this.Textbox4.Text.Trim() + "',spflbh=" + this.Dropdownlist2.SelectedValue + " where spbh=" + Request.QueryString["ID"]);
            }
            else
            {
                DataBase.ExecSql("update spxx set spmc='" + TextBox1.Text + "',spjg=" + this.Textbox2.Text.Trim() + ",spjs='" + this.Textbox3.Text.Trim() + "',sccj='" + this.Textbox4.Text.Trim() + "',spflbh=" + this.Dropdownlist2.SelectedValue + ",sptpwjm='" + FileName + "' where spbh=" + Request.QueryString["ID"]);
            }
        }
        else
        {
            DataBase.ExecSql("insert into spxx(spmc,sptpwjm,spjs,sccj,spflbh,spjg) values('" + this.TextBox1.Text.Trim() + "','" + FileName + "','" + this.Textbox3.Text.Trim() + "','" + this.Textbox4.Text.Trim() + "'," + this.Dropdownlist2.SelectedValue + "," + Textbox2.Text + ")");

〖资料来源:计算机毕业论文 www.xiaoniu168.com

第8页为计算机毕业论文订单审核功能介绍......

【联系方式】

【本站信誉】

用心做计算机毕业设计论文网