📄 gdcledit.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class Admin_GdclEdit : System.Web.UI.Page
{
public string strPic = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.QueryString["ID"] != null)
{
//显示当前的固定车辆信息
DataTable dt = new DataTable();
dt = DataControl.GetData("select * from 固定车辆信息 where 车辆代码=" + Request.QueryString["ID"] + "");
if (dt.Rows.Count > 0)
{
this.TextBox1.Text = dt.Rows[0]["车辆名称"].ToString();
this.Textbox4.Text = dt.Rows[0]["车牌号"].ToString();
this.txtID.Text = dt.Rows[0]["住户代码"].ToString();
this.txtHzxx.Text = DataControl.GetUserInfo(Convert.ToInt32(dt.Rows[0]["住户代码"]));
strPic = @"Pic\" + dt.Rows[0]["车辆图片"].ToString();
this.Textbox2.Text = dt.Rows[0]["备注"].ToString();
}
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//跳转页面
Response.Redirect("GdclList.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
{
string FileName = "";
string FileName1;
string DPath;
if (Server.MapPath("").Substring(Server.MapPath("").Length - 1, 1) == @"\")
{
DPath = Server.MapPath("");
}
else
{
DPath = Server.MapPath("") + @"\";
}
string delPath = DPath;
DPath = DPath + @"Pic\";
//上传图片文件
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 (File.Exists(delPath+ strPic))
{
File.Delete(delPath+ strPic);
}
}
//添加或修改 固定车辆信息
if (Request.QueryString["ID"] != null)
{
if (FileName != "")
{
DataControl.Execute("update 固定车辆信息 set 车辆名称='" + TextBox1.Text + "',车牌号='" + Textbox4.Text + "', " +
" 住户代码=" + txtID.Text + ",车辆图片='" + FileName + "',备注='" + Textbox2.Text + "' where 车辆代码='" + Request.QueryString["ID"] + "'");
}
else
{
DataControl.Execute("update 固定车辆信息 set 车辆名称='" + TextBox1.Text + "',车牌号='" + Textbox4.Text + "', " +
" 住户代码=" + txtID.Text + ",备注='" + Textbox2.Text + "' where 车辆代码='" + Request.QueryString["ID"] + "'");
}
}
else
{
DataControl.Execute("insert into 固定车辆信息(车辆名称,车牌号,住户代码,车辆图片,备注) values " +
" ('" + this.TextBox1.Text + "','" + Textbox4.Text + "'," + txtID.Text + ", " +
" '" + FileName + "','" + Textbox2.Text + "')");
}
Response.Redirect("GdclList.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -