ASP.NET农作物病虫害智能查询系统(7)

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

计算机毕业设计植物信息维护功能介绍:

5.2 植物信息
此模块主要是对植物信息的管理,可以添加、编辑、删除植物信息,可上传植物图片。

以下是引用片段:

核心代码如下:
  //判断信息是否正确
        if (this.txtZWMC.Text.Trim() == "")
        {
            Page.ClientScript.('植物名称不能为空!'>");
            return;
        }
        //将相关的图片上传到@"Image\"路径下
        string FileName = "";
        string FileName1;
        string DPath;
        DPath = Server.MapPath("") + @"\";
        DPath = DPath + @"file\";
        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.Execute("UPDATE [植物] set [植物名称] = '" + this.txtZWMC.Text + "',[植物介绍] = '" + txtZWJS.Text + "' WHERE 植物代码=" + Request.QueryString["ID"]);
            }
            else
            {
                Database.Execute("UPDATE [植物] set [植物名称] = '" + this.txtZWMC.Text + "',[植物介绍] = '" + txtZWJS.Text + "', 植物图片='" + FileName + "'  WHERE 植物代码=" + Request.QueryString["ID"]);
            }
        }
        else
        {
            Database.Execute("INSERT INTO [植物] ( [植物名称] ,[植物介绍] ,[植物图片] ) VALUES ('"+ txtZWMC.Text +"','"+ txtZWJS.Text +"','"+ FileName +"')");

        }
        Page.ClientScript.RegisterSt'保存成功!');window.location..aspx'>");

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

第8页为计算机毕业论文虫害信息介绍......

【联系方式】

【本站信誉】

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