aspx
body
<body>
<form id="form2" runat="server">
<div>
<div class="nbg_title2">
<span>车辆信息管理</span><a href="#" onclick="AddNew();return false;" class="add_cgq">+新增车辆</a></div>
<div class="search_qy v_middle">
<div class="txt">
车牌号码:</div>
<div class="input">
<input type="text" id="txtCarPlateNumberQuery" /></div>
<div class="txt">
车辆名称:</div>
<div class="input">
<input type="text" id="txtCarNameQuery" /></div>
<div class="submit">
<input type="button" value="查询" onclick="Query();return false;" /></div>
</div>
<div class="shop_content">
<div class="zkcurve_list">
<div id="ShowRoleInfo">
<div id="divShowRoleInfo" style="width: 200px; margin-left: 10px; display: none;">
<img src="../../Common/Image/loading.gif" /><span style="margin-left: 10px;">正在加载数据......</span>
</div>
</div>
<div id="ShowOperateInfo" style="margin-top: 3px;">
<div id="divShowOperateInfo" style="width: 200px; margin-left: 10px; display: none;">
<img src="../../Common/Image/loading.gif" /><span style="margin-left: 10px;">正在加载数据......</span>
</div>
</div>
</div>
</div>
<div>
<asp:GridView runat="server" ID="CarInfoGDV" GridLines="None"
CurrentSortField="" CurrentSortOrder="" PageSize="100" SeqNo="0" Width="100%"
SeqText="序号" ShowSeqNo="true" AutoGenerateColumns="False">
<HeaderStyle Wrap="False" BorderColor="#D7E0EA" Height="40px" ForeColor="#36AEEA">
</HeaderStyle>
<Columns>
<asp:TemplateField HeaderText="序号" InsertVisible="False" HeaderStyle-Wrap="false">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemTemplate>
<%-- gridview增加自动序号列 即使分页也会继续累积而不会重新排序 --%>
<asp:Label CssClass="InCenter" ID="lblNum" runat="server" Text='<%# this. CarInfoGDV.PageIndex*this.CarInfoGDV.PageSize + this.CarInfoGDV.Rows.Count +1%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="车辆ID" InsertVisible="False" HeaderStyle-Wrap="false">
<HeaderStyle CssClass="ItemStyleNoDisplay" />
<ItemStyle HorizontalAlign="Center" CssClass="ItemStyleNoDisplay" />
<ItemTemplate>
<asp:Label ID="lbCarID" Height="30px" runat="server" Text='<%# Bind("Car_ID")%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="车牌号码 " InsertVisible="False" HeaderStyle-Wrap="false">
<ItemStyle HorizontalAlign="Center" CssClass="InCenter" Wrap="false" />
<ItemTemplate>
<asp:Label ID="lbCarPlateNumber" runat="server" Text='<%# Bind("Car_PlateNumber")%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="车辆名称" InsertVisible="False" HeaderStyle-Wrap="false">
<ItemStyle HorizontalAlign="Center" Wrap="false" />
<ItemTemplate>
<asp:Label ID="lbCarName" runat="server" Text='<%# Bind("Car_Name")%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="车主姓名" InsertVisible="False" HeaderStyle-Wrap="false">
<ItemStyle HorizontalAlign="Center" Wrap="false" />
<ItemTemplate>
<asp:Label ID="lbCarOwnerName" runat="server" Text='<%# Bind("Car_OwnerName")%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="车籍地" InsertVisible="False" HeaderStyle-Wrap="false">
<ItemStyle HorizontalAlign="Center" Wrap="false" />
<ItemTemplate>
<asp:Label ID="lbCarCarRegisterArea" runat="server" Text='<%# Bind("Car_CarRegisterArea")%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="车辆类型" InsertVisible="False" HeaderStyle-Wrap="false">
<ItemStyle HorizontalAlign="Center" Wrap="false" />
<ItemTemplate>
<asp:Label ID="lbCarCarType" runat="server" Text='<%# Bind("Car_CarType")%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="所属单位" InsertVisible="False" HeaderStyle-Wrap="false">
<ItemStyle HorizontalAlign="Center" Wrap="false" />
<ItemTemplate>
<asp:Label ID="lbCompanyName" runat="server" Text='<%# Bind("Conpany_Name")%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="所属单位ID" InsertVisible="False" HeaderStyle-Wrap="false">
<HeaderStyle CssClass="ItemStyleNoDisplay" />
<ItemStyle HorizontalAlign="Center" CssClass="ItemStyleNoDisplay" />
<ItemTemplate>
<asp:Label ID="lbCarCompanyId" runat="server" Text='<%# Bind("Car_CompanyId")%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="修改" HeaderStyle-Wrap="false">
<ItemStyle HorizontalAlign="Center" Wrap="false" />
<ItemTemplate>
<asp:LinkButton ID="imgS" OnClientClick='ShowUpdate(this);return false;' ToolTip="修改"
runat="server" class="bt_mod"></asp:LinkButton>
</ItemTemplate>
<ItemStyle />
</asp:TemplateField>
<asp:TemplateField HeaderText="删除" HeaderStyle-Wrap="false">
<ItemStyle HorizontalAlign="Center" Wrap="false" />
<ItemTemplate>
<asp:LinkButton ID="ibtn" class="bt_del" ToolTip="删除" runat="server" OnClientClick='deleted(this);return false;'></asp:LinkButton>
</ItemTemplate>
<ItemStyle />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div id="edit" style="display: none; width: 100%">
<div class="nbg_title3">
新增车辆</div>
<div class="shop_content">
<div class="add_qybd mt40">
<div class="txt">
车牌号码:</div>
<div class="input">
<input type="text" id="txtCarPlateNumber" class="bd" /></div>
<div class="txt">
车辆名称:</div>
<div class="input">
<input type="text" id="txtCarName" class="bd" />
</div>
</div>
<div class="add_qybd">
<div class="txt">
车主姓名:</div>
<div class="input">
<input type="text" id="txtCarOwnerName" class="bd" /></div>
<div class="txt">
车籍地:</div>
<div class="input">
<input type="text" id="txtCarCarRegisterArea" class="bd" /></div>
</div>
<div class="add_qybd">
<div class="txt">
车辆类型:</div>
<div class="input">
<input type="text" id="txtCarCarType" class="bd" /></div>
<div class="txt">
所属单位:</div>
<div>
<asp:DropDownList ID="txtCompanyID" runat="server" class="easyui-combobox" Width="100%"
Style="border: 1px solid #d7e0ea; width: 300px; border-radius: 5px; height: 35px;
line-height: 35px; padding-left: 15px;">
</asp:DropDownList>
<asp:HiddenField runat="server" ID="hiddenCarID" />
</div>
</div>
<div class="add_qybd">
<div class="btncc">
<input type="button" value="取消" onclick="cancel();return false;" class="qx" /><input
type="button" value="保存" onclick="save()" class="bc" id="savebtn" /></div>
</div>
</div>
</div>
</div>
</form>
</body>
script
<style type="text/css">
.ItemStyleNoDisplay
{
display: none;
}
</style>
<script type="text/javascript" language="javascript">
var RoleCheckList = "";
var List;
$(function() {
topTip.create();
LoadPage();
LoadCompanyItem();
});
//窗体分辨率改变事件
window.onresize = function() {
var wid = document.getElementById("edit").clientWidth;
var widths = wid * 0.31 * 0.9;
$('#txtCompanyID').combobox({
width: widths,
panelWidth: widths
});
}
function LoadPage() {
//传值到后台并进行相关操作
$.ajax(
{
type: 'POST',
url: 'VCM.aspx',
dataType: 'text',
data: { Action: 'LoadInfo' },
cache: false,
beforeSend: function ShowdivShowChangeQueryInfo() {
topTip.setData({
tipText: "正在获取数据...",
tipType: "loading"
}).showTopTip();
},
success: OperateCallBack,
error: function(XMLHttpRequest, textStatus, errorThrown) {
topTip.setData({
tipText: "网络错误,请重试!",
tipType: "warn"
}).autoShowTopTip();
}
});
}
function OperateCallBack(strs) {
if (strs != "Empty") {
topTip.hideTopTip();
$("#ShowOperateInfo").html(strs);
}
else {
topTip.setData({
tipText: "没有匹配的数据!",
tipType: "error"
}).autoShowTopTip();
$("#ShowOperateInfo").html("没有匹配的数据");
}
}
function Query() {
var CarPlateNumber = $("#txtCarPlateNumberQuery").val();
var CarName = $("#txtCarNameQuery").val();
//传值到后台并进行相关操作
$.ajax(
{
type: 'POST',
url: 'VCM.aspx',
dataType: 'text',
data: { Action: 'Query', CarPlateNumber: CarPlateNumber, CarName: CarName },
cache: false,
beforeSend: function ShowdivShowChangeQueryInfo() {
topTip.setData({
tipText: "正在获取数据...",
tipType: "loading"
}).showTopTip();
},
success: OperateCallBack,
error: function(XMLHttpRequest, textStatus, errorThrown) {
topTip.setData({
tipText: "网络错误,请重试!",
tipType: "warn"
}).autoShowTopTip();
}
});
}
var SaveOrUodateState;
function ShowUpdate(obj) {
document.getElementById("edit").style.display = "";
var objImageBtn = obj;
var obj2;
obj2 = obj.id;
SaveOrUodateState = "1";
var Car = obj2.split("_imgS");
var CarID = $("#" + Car[0] + "_lbCarID").html();
var CarPlateNumber = $("#" + Car[0] + "_lbCarPlateNumber").html();
var CarName = $("#" + Car[0] + "_lbCarName").html();
var CarOwnerName = $("#" + Car[0] + "_lbCarOwnerName").html();
var CarCarRegisterArea = $("#" + Car[0] + "_lbCarCarRegisterArea").html();
var CarCarType = $("#" + Car[0] + "_lbCarCarType").html();
var Car_CompanyId = $("#" + Car[0] + "_lbCarCompanyId").html();
$("#hiddenCarID").val(CarID);
$("#txtCarPlateNumber").val(CarPlateNumber);
$("#txtCarName").val(CarName);
$("#txtCarOwnerName").val(CarOwnerName);
$("#txtCarCarRegisterArea").val(CarCarRegisterArea);
$("#txtCarCarType").val(CarCarType);
$('#txtCompanyID').combobox('setValue', Car_CompanyId);
}
function cancel() {
document.getElementById("edit").style.display = "none";
}
function save() {
//debugger;
var CarID = $("#hiddenCarID").val();
var CarPlateNumber = $("#txtCarPlateNumber").val();
var CarName = $("#txtCarName").val();
var CarOwnerName = $("#txtCarOwnerName").val();
var CarCarRegisterArea = $("#txtCarCarRegisterArea").val();
var CarCarType = $("#txtCarCarType").val();
var CarCompanyId = $("#txtCompanyID").combobox("getValue");
var PostType = "";
if (CarID == "") {
PostType = "Save";
}
else {
PostType = "Update";
}
if (CarPlateNumber == "" || CarName == "" ) {
topTip.setData({
tipText: "请将信息填写完整!",
tipType: "warn"
}).autoShowTopTip();
}
else {
// debugger;
$.ajax(
{
type: 'POST',
url: 'VCM.aspx',
dataType: 'text',
data: { Action: PostType, CarPlateNumber: CarPlateNumber, CarName: CarName, CarOwnerName: CarOwnerName, CarCarRegisterArea: CarCarRegisterArea,
CarCarType: CarCarType, CarCompanyId: CarCompanyId, CarID: CarID
},
cache: false,
beforeSend: function ShowdivShowChangeQueryInfo() {
topTip.setData({
tipText: "正在保存车辆信息...",
tipType: "loading"
}).showTopTip();
},
success: PostOK,
error: function(XMLHttpRequest, textStatus, errorThrown) {
debugger;
topTip.setData({
tipText: "网络错误,请重试!",
tipType: "warn"
}).autoShowTopTip();
}
});
}
}
function PostOK(str) {
if (str != "") {
if (str == "Success") {
topTip.setData({
tipText: "保存成功!",
tipType: "ok"
}).autoShowTopTip();
setTimeout(function() {
document.getElementById("edit").style.display = "none";
$("#hiddenCarID").val("");
$("#txtCarPlateNumber").val("");
$("#txtCarName").val("");
$("#txtCarOwnerName").val("");
$("#txtCarCarRegisterArea").val("");
$("#txtCarCarType").val("");
$('#txtCompanyID').combobox('setValue', "0");
document.getElementById("edit").style.display = "none";
}, 2000);
Query();
}
else if (str == "false") {
topTip.setData({
tipText: "保存失败!",
tipType: "warn"
}).autoShowTopTip();
}
else {
topTip.setData({
tipText: "已存在用户编号为:" + str + "的用户!",
tipType: "warn"
}).autoShowTopTip();
$("#txtCarPlateNumberQuery").val("");
}
}
}
function deleted(obj) {
if (confirm("是否确认删除该车辆信息?")) {
var objImageBtn = obj;
var obj2;
obj2 = obj.id;
var Car = obj2.split("_ibtn");
var CarID = $("#" + Car[0] + "_lbCarID").html();
$.ajax(
{
type: 'POST',
url: 'VCM.aspx',
dataType: 'text',
data: { Action: 'Delete', CarID: CarID },
cache: false,
beforeSend: function ShowdivShowChangeQueryInfo() {
topTip.setData({
tipText: "正在删除车辆信息...",
tipType: "loading"
}).showTopTip();
},
success: deletedOK,
error: function(XMLHttpRequest, textStatus, errorThrown) {
topTip.setData({
tipText: "网络错误,请重试!",
tipType: "warn"
}).autoShowTopTip();
}
});
}
}
function deletedOK(str) {
if (str != "") {
if (str == "Success") {
topTip.setData({
tipText: "删除信息成功!",
tipType: "ok"
}).autoShowTopTip();
setTimeout(function() {
LoadPage();
}, 2000);
}
else {
topTip.setData({
tipText: "删除信息失败!",
tipType: "error"
}).autoShowTopTip();
}
}
else {
topTip.setData({
tipText: "删除信息失败!",
tipType: "error"
}).autoShowTopTip();
}
}
function AddNew() {
document.getElementById("edit").style.display = "block";
var wid = document.getElementById("edit").clientWidth;
var widths = wid * 0.31 * 0.9;
$("#txtCarPlateNumber").val("");
$("#txtCarName").val("");
$("#txtCarOwnerName").val("");
$("#txtCarCarRegisterArea").val("");
$("#txtCarCarType").val("");
$('#txtCompanyID').combobox({
width: widths,
panelWidth: widths
});
$("#savebtn").focus();
}
</script>
导入
<title>车辆管理</title>
<link href="../../CommonNew/css/main.css" rel="stylesheet" type="text/css"></link>
<link href="../../CommonNew/css/drop-down.css" rel="stylesheet" type="text/css">
</link>
<script src="../../CommonNew/js/select-widget-min.js" type="text/javascript"></script>
<script src="../../CommonNew/js/jquery-ui.min.js" type="text/javascript"></script>
<script src="../../CommonNew/js/laydate.js" type="text/javascript"></script>
<script src="../../CommonNew/js/tab.js" type="text/javascript"></script>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<script src="../../Common/jquery-easyui-1.3.1/jquery-1.8.0.min.js" type="text/javascript"></script>
<%-- <script src="../../Common/jquery-easyui-1.3.1/jquery.easyui.min.js" type="text/javascript"></script>
<link href="../../Common/jquery-easyui-1.3.1/themes/default/easyui.css" rel="stylesheet"
type="text/css" />--%>
<link href="../../Common/jquery-easyui-1.5/themes/default/easyui.css" rel="stylesheet"
type="text/css" />
<link href="../../Common/jquery-easyui-1.5/themes/icon.css" rel="stylesheet" type="text/css" />
<script src="../../Common/jquery-easyui-1.5/jquery.easyui.min.js" type="text/javascript"></script>
<script src="../../Common/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="../../Common/js/topTip.js" type="text/javascript"></script>
<link href="../../Common/Style/topTip.css" rel="stylesheet" type="text/css" />
后台cs
namespace THMS.page.VehicleManagement
{
public partial class VCM : MyBasePage
{
User_InfoBLL _User_InfoBLL = new User_InfoBLL();
public override void VerifyRenderingInServerForm(Control control)
{ }
protected void Page_Load(object sender, EventArgs e)
{
if (Request["Action"] != null)
{
string returnMsg = string.Empty;
StringBuilder returngvwMsg = new StringBuilder();
switch (Request["Action"])
{
//页面加载
case "LoadInfo":
returnMsg = LoadInfo();
Response.Write(returnMsg);
break;
//车辆信息查询
case "Query":
returnMsg = QueryInfo(
Request["CarPlateNumber"].ToString(),
Request["CarName"].ToString());
Response.Write(returnMsg);
break;
case "Update"://string CarNewPlateNumber, string CarName, string CarOwnerName, string CarCarRegisterArea, string CarCarType, string CarCompanyId,string CarID
returnMsg = Update(
Request["CarPlateNumber"].ToString(),
Request["CarName"].ToString(),
Request["CarOwnerName"].ToString(),
Request["CarCarRegisterArea"].ToString(),
Request["CarCarType"].ToString(),
Request["CarCompanyId"].ToString(),
Request["CarID"].ToString());
Response.Write(returnMsg);
break;
case "Save":
returnMsg = Save(
// Request["CarID"].ToString(),
Request["CarPlateNumber"].ToString(),
Request["CarName"].ToString(),
Request["CarOwnerName"].ToString(),
Request["CarCarRegisterArea"].ToString(),
Request["CarCarType"].ToString(),
Request["CarCompanyId"].ToString());
Response.Write(returnMsg);
break;
case "Delete":
returnMsg = Delete(Request["CarID"].ToString());
Response.Write(returnMsg);
break;
}
Response.ContentType = "text/xml";
Response.Expires = 0;
Response.Flush();
Response.End();
}
if (!IsPostBack)
{
this.txtCompanyID.DataSource = _User_InfoBLL.GetCompanyList();
this.txtCompanyID.DataValueField = "Company_ID";
this.txtCompanyID.DataTextField = "Company_Name";
this.txtCompanyID.DataBind();
//将下拉列表框第一列设置为“请选择”
this.txtCompanyID.Items.Insert(0, new ListItem(Constants.Const_DropDownList_EnterItem, "0"));
}
}
protected String LoadInfo() //页面车辆加载
{
BLL.VehicleInfoManagement.CarInfoManaBLL GetCar = new BLL.VehicleInfoManagement.CarInfoManaBLL();
DataTable ds = GetCar.QueryCarInfo("", "");
if (ds != null && ds.Rows.Count > 0)
{
this.CarInfoGDV.DataSource = null;
this.CarInfoGDV.DataSource = ds;
this.CarInfoGDV.DataBind();
return PagingMethod.RenderGridView(this.CarInfoGDV);
}
else
return "Empty";
}
protected string QueryInfo(string QCarPlateNumber, string QCarName) //车辆查询
{
BLL.VehicleInfoManagement.CarInfoManaBLL GetCar = new BLL.VehicleInfoManagement.CarInfoManaBLL();
DataTable ds = GetCar.QueryCarInfo(QCarPlateNumber, QCarName);
if (ds.Rows.Count > 0)
{
this.CarInfoGDV.DataSource = null;
this.CarInfoGDV.DataSource = ds;
this.CarInfoGDV.DataBind();
return PagingMethod.RenderGridView(this.CarInfoGDV);
}
else
return "Empty";
}
//保存新加车辆
public string Save(string CarNewPlateNumber, string CarName, string CarOwnerName, string CarCarRegisterArea, string CarCarType, string CarCompanyId) //车辆信息新增
{
BLL.VehicleInfoManagement.CarInfoManaBLL VCMBLL = new BLL.VehicleInfoManagement.CarInfoManaBLL();
if (VCMBLL.GetCarInforByCarPlateNumber(CarNewPlateNumber))
{
Log_InfoBLL.AddOperateAdd("车辆信息新增失败,车牌号码 【" + CarNewPlateNumber + "】已经存在!", this.Title);
return "Exit";
}
else
{
if (VCMBLL.SaveCarInfoBLL(CarNewPlateNumber, CarName, CarOwnerName, CarCarRegisterArea, CarCarType, CarCompanyId))
{
Log_InfoBLL.AddOperateAdd("车辆信息新增成功,车牌号码 【" + CarNewPlateNumber + "】,车辆名称【" + CarName + "】", this.Title);
return "Success";
}
else
{
Log_InfoBLL.AddOperateAdd("车辆信息新增失败,车牌号码 【" + CarNewPlateNumber + "】,车辆名称【" + CarName + "】", this.Title);
return "Error";
}
}
}
public string Update( string CarNewPlateNumber, string CarName, string CarOwnerName, string CarCarRegisterArea, string CarCarType, string CarCompanyId,string CarID) //车辆信息更新
{
BLL.VehicleInfoManagement.CarInfoManaBLL VCMBLL = new BLL.VehicleInfoManagement.CarInfoManaBLL();
if (!(CarID == "" || (!VCMBLL.SearchTheCarBLL(CarID, CarNewPlateNumber))))
{
Log_InfoBLL.AddOperateEdit("车辆信息修改失败,车牌号码 【" + CarNewPlateNumber + "】已经存在!", this.Title);
return "Exit";
}
else
{
DataTable dtOld = VCMBLL.GetOldCarInfoByCarId(CarID);
string strEditContent = GetEditCarContent(dtOld, CarNewPlateNumber, CarName, CarOwnerName, CarCarRegisterArea, CarCarType, CarCompanyId);
if (VCMBLL.UpdateCarInfoBLL(CarID, CarNewPlateNumber, CarName, CarOwnerName, CarCarRegisterArea, CarCarType, CarCompanyId))
{
Log_InfoBLL.AddOperateEdit(strEditContent, this.Title);
return "Success";
}
else
{
Log_InfoBLL.AddOperateEdit("车辆信息修改失败", this.Title);
return "Error";
}
}
}
public string Delete(string CarPlateNumber)
{
BLL.VehicleInfoManagement.CarInfoManaBLL VCMBLL = new BLL.VehicleInfoManagement.CarInfoManaBLL();
if (VCMBLL.DeleteCarInfoBLL(CarPlateNumber))
{
Log_InfoBLL.AddOperateDelete("车辆信息删除成功,车牌号码 【" + CarPlateNumber + "】", this.Title);
return "Success";
}
else
{
Log_InfoBLL.AddOperateDelete("车辆信息删除失败,车牌号码 【" + CarPlateNumber + "】", this.Title);
return "";
}
}
//加载单位列表
public string LoadCompanyItem()
{
DataTable CompanyItem = _User_InfoBLL.GetCompanyList();
return CommonHelper.ToJson(CompanyItem);
}
public string GetEditCarContent(DataTable dtOld, string CarNewPlateNumber, string CarName, string CarOwnerName, string CarCarRegisterArea, string CarCarType, string CarCompanyId)
{
string strEditContent = "";
if (dtOld != null && dtOld.Rows.Count > 0)
{
strEditContent = "成功修改车辆信息";
if (dtOld.Rows[0]["Car_PlateNumber"].ToString().Trim() != CarNewPlateNumber.Trim())
strEditContent += ",车牌号码 从【" + dtOld.Rows[0]["Car_PlateNumber"].ToString().Trim() + "】变更为【" + CarNewPlateNumber.Trim() + "】";
if (dtOld.Rows[0]["Car_Name"].ToString().Trim() != CarName.Trim())
strEditContent += ",车辆名称 从【" + dtOld.Rows[0]["Car_Name"].ToString().Trim() + "】变更为【" + CarName.Trim() + "】";
if (dtOld.Rows[0]["Car_OwnerName"].ToString().Trim() != CarOwnerName.Trim())
strEditContent += ",车主姓名 从【" + dtOld.Rows[0]["Car_OwnerName"].ToString().Trim() + "】变更为【" + CarOwnerName.Trim() + "】";
if (dtOld.Rows[0]["Car_CarRegisterArea"].ToString().Trim() != CarCarRegisterArea.Trim())
strEditContent += ",车籍地 从【" + dtOld.Rows[0]["Car_CarRegisterArea"].ToString().Trim() + "】变更为【" + CarCarRegisterArea.Trim() + "】";
if (dtOld.Rows[0]["Car_CarType"].ToString().Trim() != CarCarType.Trim())
strEditContent += ",车辆类型 从【" + dtOld.Rows[0]["Car_CarType"].ToString().Trim() + "】变更为【" + CarCarType.Trim() + "】";
if (dtOld.Rows[0]["Car_CompanyId"].ToString().Trim() != CarCompanyId.Trim())
strEditContent += ",所属单位 从【" + dtOld.Rows[0]["Car_CompanyId"].ToString().Trim() + "】变更为【" + CarCompanyId.Trim() + "】";
}
return strEditContent;
}
}
}
BBL
namespace BLL.VehicleInfoManagement
{
public class CarInfoManaBLL
{
#region
/// <summary>
/// 直接加载车辆信息
/// </summary>
/// <returns>true false</returns>
public DataTable GetCarInfo()
{
Car_InforDAL GetCar = new Car_InforDAL();
User_Info user = LoginHandler.CurrentUser;
if (user.Company_ID == 0)
{
return GetCar.GetCarInfoDAL(user.User_ID.ToString(), "0");
}
else
{
return GetCar.GetCarInfoDAL(user.User_ID.ToString(), Role_InfoDAL.GetAllEneterIdsByCompanyID(user.Company_ID.ToString()));
}
}
/// <summary>
/// 根据条件获取车辆信息
/// </summary>
/// <returns>true false</returns>
public DataTable QueryCarInfo(string QueryCarPlateNumber, string QueryCarName)
{
Car_InforDAL GetCar = new Car_InforDAL();
User_Info user = LoginHandler.CurrentUser;
if (user.Company_ID == 0)
{
return GetCar.QueryCarInfoDAL(user.User_ID.ToString(), "0", QueryCarPlateNumber, QueryCarName);
}
else
{
return GetCar.QueryCarInfoDAL(user.User_ID.ToString(), Role_InfoDAL.GetAllEneterIdsByCompanyID(user.Company_ID.ToString()), QueryCarPlateNumber, QueryCarName);
}
}
/// <summary>
/// 当前用户下的下属车辆
/// </summary>
/// <returns>true false</returns>
public DataTable GetAllCompanyInfoByUserBLL()
{
Car_InforDAL GetCarInfo = new Car_InforDAL();
User_Info user = LoginHandler.CurrentUser;
if (user.Company_ID == 0)
{
return GetCarInfo.GetCarInfoByUserDAL(user.User_ID.ToString(), "0");
}
else
{
return GetCarInfo.GetCarInfoByUserDAL(user.User_ID.ToString(), Role_InfoDAL.GetAllEneterIdsByUserID(user.User_ID.ToString()));
}
}
/// <summary>
/// 查询该车辆是否存在
/// </summary>
/// <returns>true false</returns>
public bool SearchTheCarBLL(string CarID, string CarNewPlateNumber)
{
Car_InforDAL SearchTheCar = new Car_InforDAL();
return SearchTheCar.SearchTheCarDAL(CarID, CarNewPlateNumber);
}
/// <summary>
/// 保存新增车辆信息
/// </summary>
/// <returns>true false</returns>
public bool SaveCarInfoBLL(string CarPlateNumber, string CarName, string CarOwnerName, string CarCarRegisterArea, string CarCarType, string CarCompanyId)
{
Car_InforDAL SaveCarInfo = new Car_InforDAL();
User_Info user = LoginHandler.CurrentUser;
return SaveCarInfo.SaveCarInfoDAL(user.User_ID.ToString(), CarPlateNumber, CarName, CarOwnerName, CarCarRegisterArea, CarCarType, CarCompanyId);
}
/// <summary>
/// 更新车辆信息
/// </summary>
/// <returns>true false</returns>
public bool UpdateCarInfoBLL(string CarID, string CarPlateNumber, string CarName, string CarOwnerName, string CarCarRegisterArea, string CarCarType, string CarCompanyId)
{
Car_InforDAL SaveCarInfo = new Car_InforDAL();
User_Info user = LoginHandler.CurrentUser;
return SaveCarInfo.UpdateCarInfoDAL(user.User_ID.ToString(), CarID, CarPlateNumber, CarName, CarOwnerName, CarCarRegisterArea, CarCarType, CarCompanyId);
}
/// <summary>
/// 删除车辆信息
/// </summary>
/// <returns>true false</returns>
public bool DeleteCarInfoBLL(string CarPlateNumber)
{
Car_InforDAL DeleteCarInfo = new Car_InforDAL();
return DeleteCarInfo.DeleteCarInfoDAL(CarPlateNumber);
}
public bool VilCarOfUser()
{
User_Info user = LoginHandler.CurrentUser;
if (Role_InfoDAL.ExitSupper(user.User_ID.ToString()))
{
return true;
}
else if (Role_InfoDAL.ExitBusiness(user.User_ID.ToString()) || Role_InfoDAL.ExitMaintenance(user.User_ID.ToString()))
{
return true;
}
if (user.Company_ID != 0)
return true;
else return false;
}
public DataTable GetOldCarInfoByCarId(string CarID)
{
Car_InforDAL _Car_InfoDAL = new Car_InforDAL();
return _Car_InfoDAL.GetOldCarInfoByCarId(CarID);
}
public bool GetCarInforByCarPlateNumber(string Car_PlateNumber)
{
Car_InforDAL _Car_InfoDAL = new Car_InforDAL();
return _Car_InfoDAL.GetCarInforByCarPlateNumber(Car_PlateNumber);
}
#endregion
}
}
DAL
namespace DAL
{
public class Car_InforDAL
{
#region
/// <summary>
/// 直接加载车辆信息
/// </summary>
/// <returns>true false</returns>
public DataTable GetCarInfoDAL(string strUserId, string strCarIDs)
{
try
{
string strAddSql = "";
if (Role_InfoDAL.ExitSupper(strUserId))
{
strAddSql = " select a.*,b.Company_Name as Conpany_Name from dbo.Car_Infor a left join Company_Info b on a.Car_CompanyId=b.Company_ID order by UPDATED_DATE desc, CREATED_DATE DESC";
return DBCommon.GetDataTable(strAddSql);
}
else
{
if (strCarIDs == "0")
{
DataTable ds = new DataTable();
return ds;
}
else
{
strAddSql = " select a.*,b.Company_Name as Conpany_Name from dbo.Car_Infor a left join Company_Info b on a.Car_CompanyId=b.Company_ID where a.Car_ID in ('" + strCarIDs + "') order by UPDATED_DATE desc, CREATED_DATE DESC";
return DBCommon.GetDataTable(strAddSql);
}
}
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}
}
/// <summary>
/// 根据条件获取车辆信息
/// </summary>
/// <returns>true false</returns>
public DataTable QueryCarInfoDAL(string strUserId, string strCarIDs, string QueryCarPlateNumber, string QueryCarName)
{
try
{
StringBuilder sb = new StringBuilder();
sb.Append(" select a.*,b.Company_Name as Conpany_Name from dbo.Car_Infor a left join Company_Info b on a.Car_CompanyId=b.Company_ID");
sb.Append(" where 1=1 ");
if (QueryCarPlateNumber != "")
sb.Append(" and a.Car_PlateNumber like '%" + QueryCarPlateNumber + "%'");
if (QueryCarName != "")
sb.Append(" and a.Car_Name like '%" + QueryCarName + "%'");
if (Role_InfoDAL.ExitSupper(strUserId))
{
}
else if (Role_InfoDAL.ExitBusiness(strUserId) || Role_InfoDAL.ExitMaintenance(strUserId))
{
}
else
{
if (strCarIDs == "0")
{
DataTable ds = new DataTable();
return ds;
}
else
{
sb.Append(" and a.Company_ID in ('" + strCarIDs + "')");
}
}
return DBCommon.GetDataTable(sb.ToString());
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}
}
#region
/// <summary>
/// 当前用户下的下属车辆
/// </summary>
/// <returns>true false</returns>
public DataTable GetCarInfoByUserDAL(string strUserId, string strConpanyIDBystrUserId)
{
try
{
string strAddSql = "";
if (Role_InfoDAL.ExitSupper(strUserId))
{
strAddSql = " select Car_ID,Car_Name from Car_Infor order by Car_Name";
return DBCommon.GetDataTable(strAddSql);
}
else if (Role_InfoDAL.ExitBusiness(strUserId) || Role_InfoDAL.ExitMaintenance(strUserId))
{
strAddSql = " select Car_ID,Car_Name from Car_Infor order by Car_Name";
return DBCommon.GetDataTable(strAddSql);
}
else
{
if (strConpanyIDBystrUserId == "0")
{
DataTable ds = new DataTable();
return ds;
}
else
{
strAddSql = "select Car_ID,Car_Name from Car_Infor where Car_ID in ('" + strConpanyIDBystrUserId + "') order by Car_Name";
return DBCommon.GetDataTable(strAddSql);
}
}
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}
}
#endregion
/// <summary>
/// 查询该车辆是否存在
/// </summary>
/// <returns>true false</returns>
public bool SearchTheCarDAL(string CarID, string CarNewPlateNumber)
{
string sql = "select * from Car_Infor where Car_ID<>'" + CarID + "' and Car_PlateNumber='" + CarNewPlateNumber + "'";
return DBCommon.ExecuteNumber(sql) > 0;
}
/// <summary>
/// 保存新增车辆信息
/// </summary>
/// <returns>true false</returns>
public bool SaveCarInfoDAL(string strUserId, string CarPlateNumber, string CarName, string CarOwnerName, string CarCarRegisterArea, string CarCarType, string CarCompanyId)
{
try
{
string ddTime = DateTime.Now.ToString();
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into dbo.Car_Infor (Car_PlateNumber,Car_Name,Car_OwnerName,Car_CarRegisterArea,");
strSql.Append("Car_CarType,Car_CompanyId) values ( ");
strSql.Append("'" + CarPlateNumber + "','" + CarName + "','" + CarOwnerName + "',");
strSql.Append("'" + CarCarRegisterArea + "','" + CarCarType + "','" + CarCompanyId + "')");
string sql = strSql.ToString();
return DBCommon.ExecuteNonQuery(sql);
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}
}
/// <summary>
/// 更新车辆信息
/// </summary>
/// <returns>true false</returns>
public bool UpdateCarInfoDAL(string strUserId, string CarID, string CarPlateNumber, string CarName, string CarOwnerName, string CarCarRegisterArea, string CarCarType, string CarCompanyId)
{
try
{
string ddTime = DateTime.Now.ToString();
StringBuilder strSql = new StringBuilder();
strSql.Append("update dbo.Car_Infor set Car_PlateNumber='" + CarPlateNumber + "',Car_OwnerName='" + CarOwnerName + "',Car_Name='" + CarName + "', ");
strSql.Append("Car_CarRegisterArea='" + CarCarRegisterArea + "',Car_CarType='" + CarCarType + "',Car_CompanyId='" + CarCompanyId + "' ");
strSql.Append("where Car_ID='" + CarID + "'");
string sql = strSql.ToString();
return DBCommon.ExecuteNonQuery(sql);
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}
}
/// <summary>
/// 删除车辆信息
/// </summary>
/// <returns>true false</returns>
public bool DeleteCarInfoDAL(string CarID)
{
string sql = "delete from Car_Infor where Car_ID='" + CarID + "'";
return DBCommon.ExecuteNonQuery(sql);
}
#endregion
public DataTable GetCarInfoList(string CarIDS)
{
string strSql = "select Car_ID,Car_Name from Car_Infor where Car_ID in ('" + CarIDS + "') order by Car_Name";
return DBCommon.GetDataTable(strSql);
}
public DataTable GetCarInfoById(string CarID)
{
string strSql = "select * from Car_Infor where Car_ID = '" + CarID + "'";
return DBCommon.GetDataTable(strSql);
}
public DataTable GetCarInfoList()
{
string strSql = "select Car_ID,Car_Name from Car_Infor order by Car_Name";
return DBCommon.GetDataTable(strSql);
}
public DataTable GetOldCarInfoByCarId(string CarID)
{
string strSql = "select * from Car_Infor where Car_ID = '" + CarID + "'";
return DBCommon.GetDataTable(strSql);
}
public bool GetCarInforByCarPlateNumber(string Car_PlateNumber)
{
string strSql = "select count(0) from Car_Infor where Car_PlateNumber='" + Car_PlateNumber + "'";
string strCount= DBCommon.GetFirstRowCol(strSql);
if (strCount == "0")
return false;
else
return true;
}
public DataTable GetCompanyInfoListByBusinessMaintenance(string strUserIDsandCarIDs)
{
string strSql = "select Car_ID,Car_Name from Car_Infor where 1=1 ";
if (strUserIDsandCarIDs != "")
{
string[] UserIDandCarIDs = strUserIDsandCarIDs.Split('|');
if (UserIDandCarIDs[1] != null && UserIDandCarIDs[1] != "")
{
strSql += " and Car_ID in ('" + UserIDandCarIDs[1] + "')";
}
}
strSql += " order by Car_Name";
return DBCommon.GetDataTable(strSql);
}
}
}
网友评论