当前位置: 移动技术网 > IT编程>开发语言>.net > asp:FileUpload 上次图片

asp:FileUpload 上次图片

2018年11月02日  | 移动技术网IT编程  | 我要评论

鲸鱼夫妇120107,仙神记,生活大爆炸第二季mp4

 <asp:fileupload id="fileupload附件" runat="server" width="200px" />

protected void btnedit_click(object sender, eventargs e)
        {
            if (txtcarplatenumber.text.trim() == "")
            {
                clientscript.registerstartupscript(gettype(), "", "alert('请输入车牌号!');", true);
                return;
            }
            int id = 0;
            if (string.isnullorempty(request.params["id"]) == false)
            {
                id = int.parse(request.params["id"]);
            }
            modelblackwhitelist model = new modelblackwhitelist();
            model.id = id;
            model.carplatetype = ddlcarplatetype.selecteditem.text;
            model.carplatenumber = txtcarplatenumber.text.trim();
            model.company = txtcompany.text.trim();
            model.bwflag = ddlbwflag.selecteditem.value;
            model.operatorname = this.userlogin;
            model.createdatetime = datetime.now;

            string commandname = request.params["commandname"].tostring();
            switch (commandname)
            {
                case "upd":
                    {
                        if (fileupload附件.postedfile.filename.trim().length != 0)
                        {
                            string savepath;
                            string filename = datetime.now.tostring("yyyymmddhhmmssms");
                            if (fileupload附件.hasfile && fileupload附件.postedfile.filename.contains(".jpg"))
                            {
                                savepath = server.mappath("~/upload/");//指定上传文件在服务器上的保存路径
                                                                       //检查服务器上是否存在这个物理路径,如果不存在则创建
                                if (!system.io.directory.exists(savepath))
                                {
                                    system.io.directory.createdirectory(savepath);
                                }
                                savepath = savepath + filename + ".jpg";
                                fileupload附件.saveas(savepath);
                                model.carpicpath = "/upload /" + filename + ".jpg";
                            }
                            else
                            {
                                clientscript.registerstartupscript(gettype(), "", "alert('请选择jpg图片文件!');", true);
                                return;
                            }
                        }
                        int result = sqlsugarclienthelper.sqldbconnection.updateable<modelblackwhitelist>(model).executecommand();
                        if (result > 0)
                        {
                            clientscript.registerstartupscript(gettype(), "", "alert('保存成功!');window.location = 'blackwhitelistmanage.aspx';", true);
                        }
                        else
                        {
                            clientscript.registerstartupscript(gettype(), "", "alert('保存失败!');", true);
                        }
                        break;
                    }
                case "new":
                    {
                        if (fileupload附件.postedfile.filename.trim().length != 0)
                        {
                            string savepath;
                            string filename = datetime.now.tostring("yyyymmddhhmmssms");
                            if (fileupload附件.hasfile && fileupload附件.postedfile.filename.contains(".jpg"))
                            {
                                savepath = server.mappath("~/upload/bwflag/");//指定上传文件在服务器上的保存路径
                                                                              //检查服务器上是否存在这个物理路径,如果不存在则创建
                                if (!system.io.directory.exists(savepath))
                                {
                                    system.io.directory.createdirectory(savepath);
                                }
                                savepath = savepath + filename + ".jpg";
                                fileupload附件.saveas(savepath);
                                model.carpicpath = "/upload/bwflag/" + filename + ".jpg";
                            }
                            else
                            {
                                clientscript.registerstartupscript(gettype(), "", "alert('请选择jpg图片文件!');", true);
                                return;
                            }
                        }
                        int result = sqlsugarclienthelper.sqldbconnection.insertable<modelblackwhitelist>(model).executecommand();
                        if (result > 0)
                        {
                            clientscript.registerstartupscript(gettype(), "", "alert('保存成功!');window.location = 'blackwhitelistmanage.aspx';", true);
                        }
                        else
                        {
                            clientscript.registerstartupscript(gettype(), "", "alert('保存失败!');", true);
                        }
                        break;
                    }
            }
        }

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网