首页 技术 正文
技术 2022年11月12日
0 收藏 317 点赞 2,860 浏览 2545 个字
 <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;
}
}
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,965
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,486
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,331
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,114
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,747
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,781