上传本地文件

protected void btnUpline_Click(object sender, EventArgs e)
        {
            string savaPath = Server.MapPath("~/Software/");//目的位置
            string softName = FileUpload1.FileName;

            
            try
            {
                if (FileUpload1.HasFile)
                {
                    if (softName != (txtsofwareName.Text + ".zip"))
                    {
                        MessageBox.Show(this.Page, "请将文件名称设为“软件名称.zip的格式”");
                        return;
                    }
                    FileUpload1.PostedFile.SaveAs(savaPath+FileUpload1.FileName );
                    MessageBox.Show(this.Page, "恭喜,上传成功!");
                }
                else 
                {
                    MessageBox.Show(this.Page, "请选择文件!");
                    
                }
            }
            catch
            {
                MessageBox .Show(this.Page ,"上传失败,请检查文件名!");
            }

        }

 

 

保存

 

/// <summary>
        /// 保存按钮的单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            //判断各个输入框是否正确
            if (this.txtsofwareName.Text.Trim().Length == 0)
            {
                strErr += "软件名称不能为空!\\n";
            }
            if (this.txtsofwareIntroduction.Text.Trim().Length == 0)
            {
                strErr += "简介不能为空!\\n";
            }
            if (this.txtcomputerID.Text.Trim().Length == 0)
            {
                strErr += "可供下载此软件的连接不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }

            string sofwareName = this.txtsofwareName.Text;
            string sofwareIntroduction = this.txtsofwareIntroduction.Text;
            string computerID = this.txtcomputerID.Text;

            Entity.CommomSoftwareInfoEntity model = new Entity.CommomSoftwareInfoEntity();

            model.sofwareName = sofwareName;
            model.sofwareIntroduction = sofwareIntroduction;
            model.computerID = computerID;

            //进行判断是否已经有软件的记录
            BLL.CommomSoftwareInfoBLL bll = new BLL.CommomSoftwareInfoBLL();
            if (bll.ExistSoftwareName(model) == true)
            {
                Common.MessageBox.ShowAndRedirect(this, "对不起,此软件已有记录,不能添加!", "AddCommonSoftware.aspx");
                return;
            }
            bll.Add(model);
            Common.MessageBox.ShowAndRedirect(this, "保存成功!", "AddCommonSoftware.aspx");

        }

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值