using System;
using System.Data;
using System.Data.SqlClient; namespace Stalberg.TMS
{ //*******************************************************
//
// LocationDetails Class
//
// A simple data class that encapsulates details about a particular loc
//
//******************************************************* public partial class LocationDetails
{
public Int32 SZIntNo;
public Int32 RdTIntNo;
public Int32 ACIntNo;
public string LocCameraCode;
public string LocCode;
public string LocStreetCode;
public string LocStreetName;
public string LocTravelDirection;
public string LocDescr;
public int LocOffenceSpeedStart;
public string Province;
public string City;
public string Suburb;
public string StreetA;
public string StreetB;
public string Route;
public string From;
public string To;
public string GpsX;
public string GpsY;
public string LocBranchCode;
public int LoSuIntNo;
public string LocType;
public string LocRegion;
//2013-12-12 Heidi added IsRailwayCrossing for check Railway Crossing on Location Maintenance page(5149)
public bool IsRailwayCrossing;
} //*******************************************************
//
// LocationDB Class
//
// Business/Data Logic Class that encapsulates all data
// logic necessary to add/login/query Locs within
// the Commerce Starter Kit Customer database.
//
//******************************************************* public partial class LocationDB
{ string mConstr = ""; public LocationDB(string vConstr)
{
mConstr = vConstr;
} //*******************************************************
//
// LocDB.GetLocationDetails() Method <a name="GetLocationDetails"></a>
//
// The GetLocationDetails method returns a LocationDetails
// struct that contains information about a specific
// customer (name, password, etc).
//
//******************************************************* public LocationDetails GetLocationDetails(int locIntNo)
{
// Create Instance of Connection and Command Object
SqlConnection con = new SqlConnection(mConstr);
SqlCommand cmd = new SqlCommand("LocationDetail", con); // Mark the Command as a SPROC
cmd.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC
SqlParameter parameterLocIntNo = new SqlParameter("@LocIntNo", SqlDbType.Int, );
parameterLocIntNo.Value = locIntNo;
cmd.Parameters.Add(parameterLocIntNo); con.Open();
SqlDataReader result = cmd.ExecuteReader(CommandBehavior.CloseConnection); // Create CustomerDetails Struct
LocationDetails details = new LocationDetails(); while (result.Read())
{
// Populate Struct using Output Params from SPROC
details.ACIntNo = Convert.ToInt32(result["ACIntNo"]);
details.RdTIntNo = Convert.ToInt32(result["RdTIntNo"]);
details.SZIntNo = Convert.ToInt32(result["SZIntNo"]);
details.LocOffenceSpeedStart = Convert.ToInt32(result["LocOffenceSpeedStart"]);
details.LocCameraCode = result["LocCameraCode"].ToString();
details.LocCode = result["LocCode"].ToString();
details.LocDescr = result["LocDescr"].ToString();
details.LocStreetCode = result["LocStreetCode"].ToString();
details.LocStreetName = result["LocStreetName"].ToString();
details.LocTravelDirection = result["LocTravelDirection"].ToString();
details.Province = result["Province"].ToString();
details.City = result["City"].ToString();
details.Suburb = result["Suburb"].ToString();
details.StreetA = result["StreetA"].ToString();
details.StreetB = result["StreetB"].ToString();
details.Route = result["Route"].ToString();
details.From = result["From"].ToString();
details.To = result["To"].ToString();
details.GpsX = result["GpsX"].ToString();
details.GpsY = result["GpsY"].ToString();
details.LocBranchCode = result["LocBranchCode"].ToString();
details.LoSuIntNo = Convert.ToInt32(result["LoSuIntNo"]);
details.LocType = result["LocType"].ToString();
details.LocRegion = result["LocRegion"].ToString();
//2013-12-12 Heidi added for check Railway Crossing on Location Maintenance page(5149)
details.IsRailwayCrossing = string.IsNullOrEmpty(result["IsRailwayCrossing"].ToString()) ? false : Convert.ToBoolean(result["IsRailwayCrossing"]);
}
result.Close();
return details;
} //*******************************************************
//
// LocDB.AddLoc() Method <a name="AddLoc"></a>
//
// The AddLoc method inserts a new loc record
// into the locs database. A unique "LocId"
// key is then returned from the method.
//
//******************************************************* public int AddLocation(int acIntNo, int szIntNo, int rdtIntNo,
string locCameraCode, string locCode, string locDescr,
string locStreetCode, string locStreetName, string locTravelDirection,
int locOffenceSpeedStart, string province, string city, string suburb,
string streetA, string streetB, string route, string from, string to, string gpsX, string gpsY,
string locBranchCode, string lastUser, int LoSuIntNo, string locType, string locRegion, bool isRailwayCrossing)
{
// Create Instance of Connection and Command Object
SqlConnection con = new SqlConnection(mConstr);
SqlCommand cmd = new SqlCommand("LocationAdd", con); // Mark the Command as a SPROC
cmd.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC
SqlParameter parameterACIntNo = new SqlParameter("@ACIntNo", SqlDbType.Int, );
parameterACIntNo.Value = acIntNo;
cmd.Parameters.Add(parameterACIntNo); SqlParameter parameterRdTIntNo = new SqlParameter("@RdTIntNo", SqlDbType.Int, );
parameterRdTIntNo.Value = rdtIntNo;
cmd.Parameters.Add(parameterRdTIntNo); SqlParameter parameterSZIntNo = new SqlParameter("@SZIntNo", SqlDbType.Int, );
parameterSZIntNo.Value = szIntNo;
cmd.Parameters.Add(parameterSZIntNo); SqlParameter parameterLocCameraCode = new SqlParameter("@LocCameraCode", SqlDbType.VarChar, );
parameterLocCameraCode.Value = locCameraCode;
cmd.Parameters.Add(parameterLocCameraCode); SqlParameter parameterLocCode = new SqlParameter("@LocCode", SqlDbType.VarChar, );
parameterLocCode.Value = locCode;
cmd.Parameters.Add(parameterLocCode); SqlParameter parameterLocDescr = new SqlParameter("@LocDescr", SqlDbType.VarChar, );
parameterLocDescr.Value = locDescr;
cmd.Parameters.Add(parameterLocDescr); SqlParameter parameterLocStreetCode = new SqlParameter("@LocStreetCode", SqlDbType.VarChar, );
parameterLocStreetCode.Value = locStreetCode;
cmd.Parameters.Add(parameterLocStreetCode); SqlParameter parameterLocStreetName = new SqlParameter("@LocStreetName", SqlDbType.VarChar, );
parameterLocStreetName.Value = locStreetName;
cmd.Parameters.Add(parameterLocStreetName); SqlParameter parameterLocOffenceSpeedStart = new SqlParameter("@LocOffenceSpeedStart", SqlDbType.Int);
parameterLocOffenceSpeedStart.Value = locOffenceSpeedStart;
cmd.Parameters.Add(parameterLocOffenceSpeedStart); SqlParameter parameterLocTravelDirection = new SqlParameter("@LocTravelDirection", SqlDbType.Char, );
parameterLocTravelDirection.Value = locTravelDirection;
cmd.Parameters.Add(parameterLocTravelDirection); SqlParameter parameterLoSuIntNo = new SqlParameter("@LoSuIntNo", SqlDbType.Int, );
parameterLoSuIntNo.Value = LoSuIntNo;
cmd.Parameters.Add(parameterLoSuIntNo); cmd.Parameters.Add("Province", SqlDbType.VarChar, ).Value = province;
cmd.Parameters.Add("City", SqlDbType.VarChar, ).Value = city;
cmd.Parameters.Add("Suburb", SqlDbType.VarChar, ).Value = suburb;
cmd.Parameters.Add("StreetA", SqlDbType.VarChar, ).Value = streetA;
cmd.Parameters.Add("StreetB", SqlDbType.VarChar, ).Value = streetB;
cmd.Parameters.Add("Route", SqlDbType.VarChar, ).Value = route;
cmd.Parameters.Add("From", SqlDbType.VarChar, ).Value = from;
cmd.Parameters.Add("To", SqlDbType.VarChar, ).Value = to;
cmd.Parameters.Add("GpsX", SqlDbType.VarChar, ).Value = gpsX;
cmd.Parameters.Add("GpsY", SqlDbType.VarChar, ).Value = gpsY;
cmd.Parameters.Add("LocBranchCode", SqlDbType.Char, ).Value = locBranchCode;
cmd.Parameters.Add("LastUser", SqlDbType.VarChar, ).Value = lastUser;
cmd.Parameters.Add("LocType", SqlDbType.Char, ).Value = locType;
cmd.Parameters.Add("LocRegion", SqlDbType.NVarChar, ).Value = locRegion;
//2013-12-12 Heidi added for check Railway Crossing on Location Maintenance page(5149)
cmd.Parameters.Add("IsRailwayCrossing", SqlDbType.Bit).Value = isRailwayCrossing; SqlParameter parameterLocIntNo = new SqlParameter("@LocIntNo", SqlDbType.Int, );
parameterLocIntNo.Direction = ParameterDirection.Output;
cmd.Parameters.Add(parameterLocIntNo); try
{
con.Open();
cmd.ExecuteNonQuery(); // Calculate the CustomerID using Output Param from SPROC
int locIntNo = Convert.ToInt32(parameterLocIntNo.Value); return locIntNo;
}
catch (Exception e)
{
string msg = e.Message;
return ;
}
finally
{
con.Dispose();
}
} public SqlDataReader GetLocationList(int autIntNo, string search, string orderBy)
{
// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(mConstr);
SqlCommand myCommand = new SqlCommand("LocationList", myConnection); // Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure; SqlParameter parameterAutIntNo = new SqlParameter("@AutIntNo", SqlDbType.Int, );
parameterAutIntNo.Value = autIntNo;
myCommand.Parameters.Add(parameterAutIntNo); SqlParameter parameterSearch = new SqlParameter("@Search", SqlDbType.VarChar, );
parameterSearch.Value = search;
myCommand.Parameters.Add(parameterSearch); SqlParameter parameterOrderBy = new SqlParameter("@OrderBy", SqlDbType.VarChar, );
parameterOrderBy.Value = orderBy;
myCommand.Parameters.Add(parameterOrderBy); // Execute the command
myConnection.Open();
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // Return the datareader result
return result;
} public DataSet GetLocationListDS(int autIntNo, string search, string orderBy)
{
int totalCount;
return GetLocationListDS(autIntNo, search, orderBy, out totalCount);
} public DataSet GetLocationListDS(int autIntNo, string search, string orderBy, out int totalCount, int pageSize = , int pageIndex = )
{
SqlDataAdapter sqlDALocs = new SqlDataAdapter();
DataSet dsLocs = new DataSet(); // Create Instance of Connection and Command Object
sqlDALocs.SelectCommand = new SqlCommand();
sqlDALocs.SelectCommand.Connection = new SqlConnection(mConstr);
sqlDALocs.SelectCommand.CommandText = "LocationList"; // Mark the Command as a SPROC
sqlDALocs.SelectCommand.CommandType = CommandType.StoredProcedure; SqlParameter parameterAutIntNo = new SqlParameter("@AutIntNo", SqlDbType.Int, );
parameterAutIntNo.Value = autIntNo;
sqlDALocs.SelectCommand.Parameters.Add(parameterAutIntNo); SqlParameter parameterSearch = new SqlParameter("@Search", SqlDbType.VarChar, );
parameterSearch.Value = search;
sqlDALocs.SelectCommand.Parameters.Add(parameterSearch); SqlParameter parameterOrderBy = new SqlParameter("@OrderBy", SqlDbType.VarChar, );
parameterOrderBy.Value = orderBy;
sqlDALocs.SelectCommand.Parameters.Add(parameterOrderBy); SqlParameter parameterPageSize = new SqlParameter("@PageSize", SqlDbType.Int);
parameterPageSize.Value = pageSize;
sqlDALocs.SelectCommand.Parameters.Add(parameterPageSize); SqlParameter parameterPageIndex = new SqlParameter("@PageIndex", SqlDbType.Int);
parameterPageIndex.Value = pageIndex;
sqlDALocs.SelectCommand.Parameters.Add(parameterPageIndex); SqlParameter parameterTotalCount = new SqlParameter("@TotalCount", SqlDbType.Int);
parameterTotalCount.Direction = ParameterDirection.Output;
sqlDALocs.SelectCommand.Parameters.Add(parameterTotalCount); // Execute the command and close the connection
sqlDALocs.Fill(dsLocs);
sqlDALocs.SelectCommand.Connection.Dispose(); totalCount = (int)(parameterTotalCount.Value == DBNull.Value ? : parameterTotalCount.Value); // Return the dataset result
return dsLocs;
} public int UpdateLocation(int locIntNo, int acIntNo, int szIntNo, int rdtIntNo,
string locCameraCode, string locCode, string locDescr,
string locStreetCode, string locStreetName, string locTravelDirection,
int locOffenceSpeedStart, string province, string city, string suburb,
string streetA, string streetB, string route, string from, string to, string gpsX, string gpsY,
string locBranchCode, string lastUser, int LoSuIntNo, string locType, string locRegion, bool isRailwayCrossing)
{
// Create Instance of Connection and Command Object
SqlConnection con = new SqlConnection(mConstr);
SqlCommand cmd = new SqlCommand("LocationUpdate", con); // Mark the Command as a SPROC
cmd.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC
SqlParameter parameterACIntNo = new SqlParameter("@ACIntNo", SqlDbType.Int, );
parameterACIntNo.Value = acIntNo;
cmd.Parameters.Add(parameterACIntNo); SqlParameter parameterRdTIntNo = new SqlParameter("@RdTIntNo", SqlDbType.Int, );
parameterRdTIntNo.Value = rdtIntNo;
cmd.Parameters.Add(parameterRdTIntNo); SqlParameter parameterSZIntNo = new SqlParameter("@SZIntNo", SqlDbType.Int, );
parameterSZIntNo.Value = szIntNo;
cmd.Parameters.Add(parameterSZIntNo); SqlParameter parameterLocCameraCode = new SqlParameter("@LocCameraCode", SqlDbType.VarChar, );
parameterLocCameraCode.Value = locCameraCode;
cmd.Parameters.Add(parameterLocCameraCode); SqlParameter parameterLocCode = new SqlParameter("@LocCode", SqlDbType.VarChar, );
parameterLocCode.Value = locCode;
cmd.Parameters.Add(parameterLocCode); SqlParameter parameterLocDescr = new SqlParameter("@LocDescr", SqlDbType.VarChar, );
parameterLocDescr.Value = locDescr;
cmd.Parameters.Add(parameterLocDescr); SqlParameter parameterLocStreetCode = new SqlParameter("@LocStreetCode", SqlDbType.VarChar, );
parameterLocStreetCode.Value = locStreetCode;
cmd.Parameters.Add(parameterLocStreetCode); SqlParameter parameterLocStreetName = new SqlParameter("@LocStreetName", SqlDbType.VarChar, );
parameterLocStreetName.Value = locStreetName;
cmd.Parameters.Add(parameterLocStreetName); SqlParameter parameterLocTravelDirection = new SqlParameter("@LocTravelDirection", SqlDbType.Char, );
parameterLocTravelDirection.Value = locTravelDirection;
cmd.Parameters.Add(parameterLocTravelDirection); SqlParameter parameterLocOffenceSpeedStart = new SqlParameter("@LocOffenceSpeedStart", SqlDbType.Int);
parameterLocOffenceSpeedStart.Value = locOffenceSpeedStart;
cmd.Parameters.Add(parameterLocOffenceSpeedStart); SqlParameter parameterLoSuIntNo = new SqlParameter("@LoSuIntNo", SqlDbType.Int, );
parameterLoSuIntNo.Value = LoSuIntNo;
cmd.Parameters.Add(parameterLoSuIntNo); cmd.Parameters.Add("Province", SqlDbType.VarChar, ).Value = province;
cmd.Parameters.Add("City", SqlDbType.VarChar, ).Value = city;
cmd.Parameters.Add("Suburb", SqlDbType.VarChar, ).Value = suburb;
cmd.Parameters.Add("StreetA", SqlDbType.VarChar, ).Value = streetA;
cmd.Parameters.Add("StreetB", SqlDbType.VarChar, ).Value = streetB;
cmd.Parameters.Add("Route", SqlDbType.VarChar, ).Value = route;
cmd.Parameters.Add("From", SqlDbType.VarChar, ).Value = from;
cmd.Parameters.Add("To", SqlDbType.VarChar, ).Value = to;
cmd.Parameters.Add("GpsX", SqlDbType.VarChar, ).Value = gpsX;
cmd.Parameters.Add("GpsY", SqlDbType.VarChar, ).Value = gpsY;
cmd.Parameters.Add("LocBranchCode", SqlDbType.Char, ).Value = locBranchCode;
cmd.Parameters.Add("LastUser", SqlDbType.VarChar, ).Value = lastUser;
cmd.Parameters.Add("LocType", SqlDbType.Char, ).Value = locType;
cmd.Parameters.Add("LocRegion", SqlDbType.NVarChar, ).Value = locRegion; //2013-12-12 Heidi added for check Railway Crossing on Location Maintenance page(5149)
cmd.Parameters.Add("IsRailwayCrossing", SqlDbType.Bit).Value = isRailwayCrossing; SqlParameter parameterLocIntNo = new SqlParameter("@LocIntNo", SqlDbType.Int);
parameterLocIntNo.Direction = ParameterDirection.InputOutput;
parameterLocIntNo.Value = locIntNo;
cmd.Parameters.Add(parameterLocIntNo); try
{
con.Open();
cmd.ExecuteNonQuery();
con.Dispose(); // Calculate the CustomerID using Output Param from SPROC
int LocIntNo = (int)cmd.Parameters["@LocIntNo"].Value;
//int locId = (int)parameterLocIntNo.Value; return LocIntNo;
}
catch (Exception e)
{
con.Dispose();
string msg = e.Message;
return ;
}
} public int DeleteLocation(int locIntNo, ref string errMessage)
{ // Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(mConstr);
SqlCommand myCommand = new SqlCommand("LocationDelete", myConnection); // Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure; // Add Parameters to SPROC
SqlParameter parameterLocIntNo = new SqlParameter("@LocIntNo", SqlDbType.Int, );
parameterLocIntNo.Value = locIntNo;
parameterLocIntNo.Direction = ParameterDirection.InputOutput;
myCommand.Parameters.Add(parameterLocIntNo); try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Dispose(); // Calculate the CustomerID using Output Param from SPROC
int LocIntNo = (int)parameterLocIntNo.Value; return LocIntNo;
}
catch (Exception ex)
{
errMessage = ex.Message;
return ;
}
finally
{
myConnection.Dispose();
}
} /// <summary>
/// Gets the auth_Location list by auth DS.
/// </summary>
/// <param name="autIntNo">The aut int no.</param>
/// <returns></returns>
public DataSet GetValueTextListByLocationTable(int autIntNo)
{
SqlDataAdapter sqlDALocations = new SqlDataAdapter();
DataSet dsLocations = new DataSet(); // Create Instance of Connection and Command Object
sqlDALocations.SelectCommand = new SqlCommand();
sqlDALocations.SelectCommand.Connection = new SqlConnection(mConstr);
sqlDALocations.SelectCommand.CommandText = "GetValueTextListByLocationTable"; // Mark the Command as a SPROC
sqlDALocations.SelectCommand.CommandType = CommandType.StoredProcedure; SqlParameter parameterAutIntNo = new SqlParameter("@AutIntNo", SqlDbType.Int, );
parameterAutIntNo.Value = autIntNo;
sqlDALocations.SelectCommand.Parameters.Add(parameterAutIntNo); // Execute the command and close the connection
sqlDALocations.Fill(dsLocations);
sqlDALocations.SelectCommand.Connection.Dispose(); // Return the dataset result
return dsLocations;
} /// <summary>
/// Heidi 2013-12-12 Get Railway Locations DDL by AutIntNo
/// </summary>
/// <param name="autIntNo">The aut int no.</param>
/// <returns></returns>
public DataSet GetRailwayLocationsByAutIntNo(int autIntNo,int locIntNo,bool IsAll)
{
SqlDataAdapter sqlDALocations = new SqlDataAdapter();
DataSet dsLocations = new DataSet(); // Create Instance of Connection and Command Object
sqlDALocations.SelectCommand = new SqlCommand();
sqlDALocations.SelectCommand.Connection = new SqlConnection(mConstr);
sqlDALocations.SelectCommand.CommandText = "GetRailwayLocationsByAutIntNo"; // Mark the Command as a SPROC
sqlDALocations.SelectCommand.CommandType = CommandType.StoredProcedure; SqlParameter parameterAutIntNo = new SqlParameter("@AutIntNo", SqlDbType.Int, );
parameterAutIntNo.Value = autIntNo;
sqlDALocations.SelectCommand.Parameters.Add(parameterAutIntNo); SqlParameter parameterLocIntNo = new SqlParameter("@LocIntNo", SqlDbType.Int, );
parameterLocIntNo.Value = locIntNo;
sqlDALocations.SelectCommand.Parameters.Add(parameterLocIntNo); SqlParameter parameterISALL = new SqlParameter("@ISALL", SqlDbType.Bit);
parameterISALL.Value = IsAll;
sqlDALocations.SelectCommand.Parameters.Add(parameterISALL); // Execute the command and close the connection
sqlDALocations.Fill(dsLocations);
sqlDALocations.SelectCommand.Connection.Dispose(); // Return the dataset result
return dsLocations;
} /// <summary>
/// Heidi 2013-12-16 Get Railway Locations by AutIntNo and LocIntNo
/// </summary>
/// <param name="autIntNo">The aut int no.</param>
/// <returns></returns>
public DataSet GetLocationByLocIntNoAndIsRailwayCrossing(int autIntNo, int locIntNo)
{
SqlDataAdapter sqlDALocations = new SqlDataAdapter();
DataSet dsLocations = new DataSet(); // Create Instance of Connection and Command Object
sqlDALocations.SelectCommand = new SqlCommand();
sqlDALocations.SelectCommand.Connection = new SqlConnection(mConstr);
sqlDALocations.SelectCommand.CommandText = "GetLocationByLocIntNoAndIsRailwayCrossing"; // Mark the Command as a SPROC
sqlDALocations.SelectCommand.CommandType = CommandType.StoredProcedure; SqlParameter parameterAutIntNo = new SqlParameter("@AutIntNo", SqlDbType.Int, );
parameterAutIntNo.Value = autIntNo;
sqlDALocations.SelectCommand.Parameters.Add(parameterAutIntNo); SqlParameter parameterLocIntNo= new SqlParameter("@LocIntNo", SqlDbType.Int, );
parameterLocIntNo.Value = locIntNo;
sqlDALocations.SelectCommand.Parameters.Add(parameterLocIntNo); // Execute the command and close the connection
sqlDALocations.Fill(dsLocations);
sqlDALocations.SelectCommand.Connection.Dispose(); // Return the dataset result
return dsLocations;
}
}
}

最新文章

  1. java ---- 面试题
  2. js获取url信息
  3. 【Java每日一题】20161013
  4. VBS使用Scripting.Dictionary字典对象
  5. BACKBONE源代码解析
  6. Apache Thrift - 可伸缩的跨语言服务开发框架
  7. CodeIgniter 3.0+ 部署linux环境 session报错
  8. Java Web连接各种数据库方式汇总
  9. PHP递归
  10. C#泛型比较大小
  11. 注释玩转webapi
  12. RNTools
  13. 微软build 2015
  14. 201521123025 《Java程序设计》第1周学习总结
  15. Python基础(函数-递归)
  16. [ExtJS5学习笔记]第二十三节 Extjs5中表格gridpanel的列格式设置
  17. 面向对象___str__和__repr__
  18. Oracle定时任务Job笔记
  19. Perl中的自增、自减
  20. yii2优化 - 开启 Schema 缓存

热门文章

  1. HTML列表标签
  2. Pacemaker+ISCSI实现Apache高可用-环境准备
  3. go基础_定时器
  4. vue 无法热替换/热更新
  5. Go包
  6. BFSDFS模板
  7. Python环境搭建后,多种方式的使用进行程序的执行。
  8. datatable自动增加序号
  9. 题解 CF546B Soldier and Badges
  10. spring boot 配置logback日志之jdbcTemplate打印sql语句配置