|
|
@@ -4,6 +4,7 @@ using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using MySql.Data.MySqlClient;
|
|
|
+using parkMonitor.DB;
|
|
|
|
|
|
namespace parkMonitor.DBLocation
|
|
|
{
|
|
|
@@ -198,10 +199,10 @@ namespace parkMonitor.DBLocation
|
|
|
}
|
|
|
|
|
|
//车库有无此车
|
|
|
- public bool IsNumberPlate(string numberPlate)
|
|
|
+ public bool IsNumberPlate(string numberPlate,int garageID)
|
|
|
{
|
|
|
bool isNumberPlate = true;
|
|
|
- string sql = "select * from parkingrecords where numberPlate = '" + numberPlate + "' and parkingRecordsState = 3";
|
|
|
+ string sql = "select * from parkingrecords where numberPlate = '" + numberPlate + "' and parkingRecordsState = 3 and garageID = '"+garageID+"'";
|
|
|
con = oper.getConn();
|
|
|
try
|
|
|
{
|
|
|
@@ -230,9 +231,9 @@ namespace parkMonitor.DBLocation
|
|
|
}
|
|
|
|
|
|
//数据插入记录表,并返回停车记录id
|
|
|
- public int InsertToParkingRecords(int parkingStatus, int userID, string numberPlate, int parkingSpaceID, int garageID, int parkingRecordsState, string realParkTime)
|
|
|
+ public int InsertToParkingRecords(int parkingStatus, int userID, string numberPlate, int parkingSpaceID, int garageID, int parkingRecordsState, string realParkTime, int frontWheelbase, int rearWheelbase)
|
|
|
{
|
|
|
- string sql = "insert into parkingrecords(parkingStatus,userID,numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime) values('" + parkingStatus + "','" + userID + "','" + numberPlate + "','" + parkingSpaceID + "','" + garageID + "','" + parkingRecordsState + "','" + realParkTime + "')";
|
|
|
+ string sql = "insert into parkingrecords(parkingStatus,userID,numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime,frontWheelbase,rearWheelbase) values('" + parkingStatus + "','" + userID + "','" + numberPlate + "','" + parkingSpaceID + "','" + garageID + "','" + parkingRecordsState + "','" + realParkTime + "','" + frontWheelbase + "','" + rearWheelbase + "')";
|
|
|
con = oper.getConn();
|
|
|
int parkingRecordsID = 0;
|
|
|
try
|
|
|
@@ -339,7 +340,7 @@ namespace parkMonitor.DBLocation
|
|
|
//更新停车记录表
|
|
|
public void UpdateParkingRecords(int parkingStatus, int parkingRecordsState, string realGetTime, int parkingRecordsID)
|
|
|
{
|
|
|
- string sql = "update parkingrecords set parkingRecordsState = '" + parkingRecordsState + "',realGetTime = '" + realGetTime + "'where parkingRecordsID = '" + parkingRecordsID + "'";
|
|
|
+ string sql = "update parkingrecords set parkingStatus = '"+parkingStatus+"', parkingRecordsState = '" + parkingRecordsState + "',realGetTime = '" + realGetTime + "'where parkingRecordsID = '" + parkingRecordsID + "'";
|
|
|
con = oper.getConn();
|
|
|
try
|
|
|
{
|
|
|
@@ -447,7 +448,7 @@ namespace parkMonitor.DBLocation
|
|
|
}
|
|
|
|
|
|
//查询手动停车的车位ID
|
|
|
- public int[] GetParkingSpaceID()
|
|
|
+ public int[] GetAllParkingSpaceID()
|
|
|
{
|
|
|
int parkingSpaceID = 0;
|
|
|
List<int> listID = new List<int>();
|
|
|
@@ -487,5 +488,111 @@ namespace parkMonitor.DBLocation
|
|
|
listID.Add(parkingSpaceID);
|
|
|
return listID.ToArray();
|
|
|
}
|
|
|
+
|
|
|
+ //查询车位位置及状态,返回list
|
|
|
+ public List<Parking_Space> GetParkingSpace()
|
|
|
+ {
|
|
|
+ List<Parking_Space> lps = new List<Parking_Space>();
|
|
|
+ MySqlDataReader reader = null;
|
|
|
+ string sql = "select * from parkingspace where parkingSpaceState = 0 ";
|
|
|
+ con = oper.getConn();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ con.Open();
|
|
|
+ cmd = oper.getComm(sql, con);
|
|
|
+ reader = oper.getResultSet(cmd);
|
|
|
+ while (reader.Read())
|
|
|
+ {
|
|
|
+ if (reader.HasRows)
|
|
|
+ {
|
|
|
+ int parkingSpaceID = reader.GetInt32("parkingSpaceID");
|
|
|
+ //float parkingSpaceWeight = reader.GetFloat("parkingSpaceWeight");
|
|
|
+ //int parkingSpaceStatement = reader.GetInt32("parkingSpaceState");
|
|
|
+ int garageID = reader.GetInt32("garageID");
|
|
|
+ int parkingSpaceX = reader.GetInt32("parkingSpaceX");
|
|
|
+ int parkingSpaceY = reader.GetInt32("parkingSpaceY");
|
|
|
+ int parkingSpaceZ = reader.GetInt32("parkingSpaceZ");
|
|
|
+ Parking_Space ps = new Parking_Space();
|
|
|
+ ps.parkingSpaceID = parkingSpaceID;
|
|
|
+ ps.garageID = garageID;
|
|
|
+ //ps.parkingSpaceWeight = parkingSpaceWeight;
|
|
|
+ //ps.parkingSpaceStatement = parkingSpaceStatement;
|
|
|
+ ps.parkingSpaceX = parkingSpaceX;
|
|
|
+ ps.parkingSpaceY = parkingSpaceY;
|
|
|
+ ps.parkingSpaceZ = parkingSpaceZ;
|
|
|
+
|
|
|
+ lps.Add(ps);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (reader != null)
|
|
|
+ {
|
|
|
+ reader.Close();
|
|
|
+ reader.Dispose();
|
|
|
+ }
|
|
|
+ if (cmd != null)
|
|
|
+ {
|
|
|
+ cmd.Dispose();
|
|
|
+ }
|
|
|
+ if (con != null)
|
|
|
+ {
|
|
|
+ con.Close();
|
|
|
+ con.Dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine(ex.ToString());
|
|
|
+ }
|
|
|
+ return lps;
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据车牌查询得到车库id和车位id以及轮距
|
|
|
+ public Vehicle GetVehicle(string numberPlate, int garageID)
|
|
|
+ {
|
|
|
+ // List<Vehicle> lVehicle = new List<Vehicle>();
|
|
|
+ Vehicle v = new Vehicle();
|
|
|
+ MySqlDataReader reader = null;
|
|
|
+ string sql = "select * from parkingrecords where numberPlate = '" + numberPlate + "' and parkingRecordsState = 3 and garageID = '" + garageID + "'";
|
|
|
+ con = oper.getConn();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ con.Open();
|
|
|
+ cmd = oper.getComm(sql, con);
|
|
|
+ reader = oper.getResultSet(cmd);
|
|
|
+ while (reader.Read())
|
|
|
+ {
|
|
|
+ if (reader.HasRows)
|
|
|
+ {
|
|
|
+ int parkingSpaceID = reader.GetInt32("parkingSpaceID");
|
|
|
+ int frontwheelbase = reader.GetInt32("frontwheelbase");
|
|
|
+ int rearwheelbase = reader.GetInt32("rearwheelbase");
|
|
|
+ v.parkingSpaceID = parkingSpaceID;
|
|
|
+ v.garageID = garageID;
|
|
|
+ v.frontwheelbase = frontwheelbase;
|
|
|
+ v.rearwheelbase = rearwheelbase;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (reader != null)
|
|
|
+ {
|
|
|
+ reader.Close();
|
|
|
+ reader.Dispose();
|
|
|
+ }
|
|
|
+ if (cmd != null)
|
|
|
+ {
|
|
|
+ cmd.Dispose();
|
|
|
+ }
|
|
|
+ if (con != null)
|
|
|
+ {
|
|
|
+ con.Close();
|
|
|
+ con.Dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine(ex.ToString());
|
|
|
+ }
|
|
|
+ return v;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|