1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4.  
  5. namespace Stalberg.TMS
  6. {
  7.  
  8. //*******************************************************
  9. //
  10. // LocationDetails Class
  11. //
  12. // A simple data class that encapsulates details about a particular loc
  13. //
  14. //*******************************************************
  15.  
  16. public partial class LocationDetails
  17. {
  18. public Int32 SZIntNo;
  19. public Int32 RdTIntNo;
  20. public Int32 ACIntNo;
  21. public string LocCameraCode;
  22. public string LocCode;
  23. public string LocStreetCode;
  24. public string LocStreetName;
  25. public string LocTravelDirection;
  26. public string LocDescr;
  27. public int LocOffenceSpeedStart;
  28. public string Province;
  29. public string City;
  30. public string Suburb;
  31. public string StreetA;
  32. public string StreetB;
  33. public string Route;
  34. public string From;
  35. public string To;
  36. public string GpsX;
  37. public string GpsY;
  38. public string LocBranchCode;
  39. public int LoSuIntNo;
  40. public string LocType;
  41. public string LocRegion;
  42. //2013-12-12 Heidi added IsRailwayCrossing for check Railway Crossing on Location Maintenance page(5149)
  43. public bool IsRailwayCrossing;
  44. }
  45.  
  46. //*******************************************************
  47. //
  48. // LocationDB Class
  49. //
  50. // Business/Data Logic Class that encapsulates all data
  51. // logic necessary to add/login/query Locs within
  52. // the Commerce Starter Kit Customer database.
  53. //
  54. //*******************************************************
  55.  
  56. public partial class LocationDB
  57. {
  58.  
  59. string mConstr = "";
  60.  
  61. public LocationDB(string vConstr)
  62. {
  63. mConstr = vConstr;
  64. }
  65.  
  66. //*******************************************************
  67. //
  68. // LocDB.GetLocationDetails() Method <a name="GetLocationDetails"></a>
  69. //
  70. // The GetLocationDetails method returns a LocationDetails
  71. // struct that contains information about a specific
  72. // customer (name, password, etc).
  73. //
  74. //*******************************************************
  75.  
  76. public LocationDetails GetLocationDetails(int locIntNo)
  77. {
  78. // Create Instance of Connection and Command Object
  79. SqlConnection con = new SqlConnection(mConstr);
  80. SqlCommand cmd = new SqlCommand("LocationDetail", con);
  81.  
  82. // Mark the Command as a SPROC
  83. cmd.CommandType = CommandType.StoredProcedure;
  84.  
  85. // Add Parameters to SPROC
  86. SqlParameter parameterLocIntNo = new SqlParameter("@LocIntNo", SqlDbType.Int, );
  87. parameterLocIntNo.Value = locIntNo;
  88. cmd.Parameters.Add(parameterLocIntNo);
  89.  
  90. con.Open();
  91. SqlDataReader result = cmd.ExecuteReader(CommandBehavior.CloseConnection);
  92.  
  93. // Create CustomerDetails Struct
  94. LocationDetails details = new LocationDetails();
  95.  
  96. while (result.Read())
  97. {
  98. // Populate Struct using Output Params from SPROC
  99. details.ACIntNo = Convert.ToInt32(result["ACIntNo"]);
  100. details.RdTIntNo = Convert.ToInt32(result["RdTIntNo"]);
  101. details.SZIntNo = Convert.ToInt32(result["SZIntNo"]);
  102. details.LocOffenceSpeedStart = Convert.ToInt32(result["LocOffenceSpeedStart"]);
  103. details.LocCameraCode = result["LocCameraCode"].ToString();
  104. details.LocCode = result["LocCode"].ToString();
  105. details.LocDescr = result["LocDescr"].ToString();
  106. details.LocStreetCode = result["LocStreetCode"].ToString();
  107. details.LocStreetName = result["LocStreetName"].ToString();
  108. details.LocTravelDirection = result["LocTravelDirection"].ToString();
  109. details.Province = result["Province"].ToString();
  110. details.City = result["City"].ToString();
  111. details.Suburb = result["Suburb"].ToString();
  112. details.StreetA = result["StreetA"].ToString();
  113. details.StreetB = result["StreetB"].ToString();
  114. details.Route = result["Route"].ToString();
  115. details.From = result["From"].ToString();
  116. details.To = result["To"].ToString();
  117. details.GpsX = result["GpsX"].ToString();
  118. details.GpsY = result["GpsY"].ToString();
  119. details.LocBranchCode = result["LocBranchCode"].ToString();
  120. details.LoSuIntNo = Convert.ToInt32(result["LoSuIntNo"]);
  121. details.LocType = result["LocType"].ToString();
  122. details.LocRegion = result["LocRegion"].ToString();
  123. //2013-12-12 Heidi added for check Railway Crossing on Location Maintenance page(5149)
  124. details.IsRailwayCrossing = string.IsNullOrEmpty(result["IsRailwayCrossing"].ToString()) ? false : Convert.ToBoolean(result["IsRailwayCrossing"]);
  125. }
  126. result.Close();
  127. return details;
  128. }
  129.  
  130. //*******************************************************
  131. //
  132. // LocDB.AddLoc() Method <a name="AddLoc"></a>
  133. //
  134. // The AddLoc method inserts a new loc record
  135. // into the locs database. A unique "LocId"
  136. // key is then returned from the method.
  137. //
  138. //*******************************************************
  139.  
  140. public int AddLocation(int acIntNo, int szIntNo, int rdtIntNo,
  141. string locCameraCode, string locCode, string locDescr,
  142. string locStreetCode, string locStreetName, string locTravelDirection,
  143. int locOffenceSpeedStart, string province, string city, string suburb,
  144. string streetA, string streetB, string route, string from, string to, string gpsX, string gpsY,
  145. string locBranchCode, string lastUser, int LoSuIntNo, string locType, string locRegion, bool isRailwayCrossing)
  146. {
  147. // Create Instance of Connection and Command Object
  148. SqlConnection con = new SqlConnection(mConstr);
  149. SqlCommand cmd = new SqlCommand("LocationAdd", con);
  150.  
  151. // Mark the Command as a SPROC
  152. cmd.CommandType = CommandType.StoredProcedure;
  153.  
  154. // Add Parameters to SPROC
  155. SqlParameter parameterACIntNo = new SqlParameter("@ACIntNo", SqlDbType.Int, );
  156. parameterACIntNo.Value = acIntNo;
  157. cmd.Parameters.Add(parameterACIntNo);
  158.  
  159. SqlParameter parameterRdTIntNo = new SqlParameter("@RdTIntNo", SqlDbType.Int, );
  160. parameterRdTIntNo.Value = rdtIntNo;
  161. cmd.Parameters.Add(parameterRdTIntNo);
  162.  
  163. SqlParameter parameterSZIntNo = new SqlParameter("@SZIntNo", SqlDbType.Int, );
  164. parameterSZIntNo.Value = szIntNo;
  165. cmd.Parameters.Add(parameterSZIntNo);
  166.  
  167. SqlParameter parameterLocCameraCode = new SqlParameter("@LocCameraCode", SqlDbType.VarChar, );
  168. parameterLocCameraCode.Value = locCameraCode;
  169. cmd.Parameters.Add(parameterLocCameraCode);
  170.  
  171. SqlParameter parameterLocCode = new SqlParameter("@LocCode", SqlDbType.VarChar, );
  172. parameterLocCode.Value = locCode;
  173. cmd.Parameters.Add(parameterLocCode);
  174.  
  175. SqlParameter parameterLocDescr = new SqlParameter("@LocDescr", SqlDbType.VarChar, );
  176. parameterLocDescr.Value = locDescr;
  177. cmd.Parameters.Add(parameterLocDescr);
  178.  
  179. SqlParameter parameterLocStreetCode = new SqlParameter("@LocStreetCode", SqlDbType.VarChar, );
  180. parameterLocStreetCode.Value = locStreetCode;
  181. cmd.Parameters.Add(parameterLocStreetCode);
  182.  
  183. SqlParameter parameterLocStreetName = new SqlParameter("@LocStreetName", SqlDbType.VarChar, );
  184. parameterLocStreetName.Value = locStreetName;
  185. cmd.Parameters.Add(parameterLocStreetName);
  186.  
  187. SqlParameter parameterLocOffenceSpeedStart = new SqlParameter("@LocOffenceSpeedStart", SqlDbType.Int);
  188. parameterLocOffenceSpeedStart.Value = locOffenceSpeedStart;
  189. cmd.Parameters.Add(parameterLocOffenceSpeedStart);
  190.  
  191. SqlParameter parameterLocTravelDirection = new SqlParameter("@LocTravelDirection", SqlDbType.Char, );
  192. parameterLocTravelDirection.Value = locTravelDirection;
  193. cmd.Parameters.Add(parameterLocTravelDirection);
  194.  
  195. SqlParameter parameterLoSuIntNo = new SqlParameter("@LoSuIntNo", SqlDbType.Int, );
  196. parameterLoSuIntNo.Value = LoSuIntNo;
  197. cmd.Parameters.Add(parameterLoSuIntNo);
  198.  
  199. cmd.Parameters.Add("Province", SqlDbType.VarChar, ).Value = province;
  200. cmd.Parameters.Add("City", SqlDbType.VarChar, ).Value = city;
  201. cmd.Parameters.Add("Suburb", SqlDbType.VarChar, ).Value = suburb;
  202. cmd.Parameters.Add("StreetA", SqlDbType.VarChar, ).Value = streetA;
  203. cmd.Parameters.Add("StreetB", SqlDbType.VarChar, ).Value = streetB;
  204. cmd.Parameters.Add("Route", SqlDbType.VarChar, ).Value = route;
  205. cmd.Parameters.Add("From", SqlDbType.VarChar, ).Value = from;
  206. cmd.Parameters.Add("To", SqlDbType.VarChar, ).Value = to;
  207. cmd.Parameters.Add("GpsX", SqlDbType.VarChar, ).Value = gpsX;
  208. cmd.Parameters.Add("GpsY", SqlDbType.VarChar, ).Value = gpsY;
  209. cmd.Parameters.Add("LocBranchCode", SqlDbType.Char, ).Value = locBranchCode;
  210. cmd.Parameters.Add("LastUser", SqlDbType.VarChar, ).Value = lastUser;
  211. cmd.Parameters.Add("LocType", SqlDbType.Char, ).Value = locType;
  212. cmd.Parameters.Add("LocRegion", SqlDbType.NVarChar, ).Value = locRegion;
  213. //2013-12-12 Heidi added for check Railway Crossing on Location Maintenance page(5149)
  214. cmd.Parameters.Add("IsRailwayCrossing", SqlDbType.Bit).Value = isRailwayCrossing;
  215.  
  216. SqlParameter parameterLocIntNo = new SqlParameter("@LocIntNo", SqlDbType.Int, );
  217. parameterLocIntNo.Direction = ParameterDirection.Output;
  218. cmd.Parameters.Add(parameterLocIntNo);
  219.  
  220. try
  221. {
  222. con.Open();
  223. cmd.ExecuteNonQuery();
  224.  
  225. // Calculate the CustomerID using Output Param from SPROC
  226. int locIntNo = Convert.ToInt32(parameterLocIntNo.Value);
  227.  
  228. return locIntNo;
  229. }
  230. catch (Exception e)
  231. {
  232. string msg = e.Message;
  233. return ;
  234. }
  235. finally
  236. {
  237. con.Dispose();
  238. }
  239. }
  240.  
  241. public SqlDataReader GetLocationList(int autIntNo, string search, string orderBy)
  242. {
  243. // Create Instance of Connection and Command Object
  244. SqlConnection myConnection = new SqlConnection(mConstr);
  245. SqlCommand myCommand = new SqlCommand("LocationList", myConnection);
  246.  
  247. // Mark the Command as a SPROC
  248. myCommand.CommandType = CommandType.StoredProcedure;
  249.  
  250. SqlParameter parameterAutIntNo = new SqlParameter("@AutIntNo", SqlDbType.Int, );
  251. parameterAutIntNo.Value = autIntNo;
  252. myCommand.Parameters.Add(parameterAutIntNo);
  253.  
  254. SqlParameter parameterSearch = new SqlParameter("@Search", SqlDbType.VarChar, );
  255. parameterSearch.Value = search;
  256. myCommand.Parameters.Add(parameterSearch);
  257.  
  258. SqlParameter parameterOrderBy = new SqlParameter("@OrderBy", SqlDbType.VarChar, );
  259. parameterOrderBy.Value = orderBy;
  260. myCommand.Parameters.Add(parameterOrderBy);
  261.  
  262. // Execute the command
  263. myConnection.Open();
  264. SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
  265.  
  266. // Return the datareader result
  267. return result;
  268. }
  269.  
  270. public DataSet GetLocationListDS(int autIntNo, string search, string orderBy)
  271. {
  272. int totalCount;
  273. return GetLocationListDS(autIntNo, search, orderBy, out totalCount);
  274. }
  275.  
  276. public DataSet GetLocationListDS(int autIntNo, string search, string orderBy, out int totalCount, int pageSize = , int pageIndex = )
  277. {
  278. SqlDataAdapter sqlDALocs = new SqlDataAdapter();
  279. DataSet dsLocs = new DataSet();
  280.  
  281. // Create Instance of Connection and Command Object
  282. sqlDALocs.SelectCommand = new SqlCommand();
  283. sqlDALocs.SelectCommand.Connection = new SqlConnection(mConstr);
  284. sqlDALocs.SelectCommand.CommandText = "LocationList";
  285.  
  286. // Mark the Command as a SPROC
  287. sqlDALocs.SelectCommand.CommandType = CommandType.StoredProcedure;
  288.  
  289. SqlParameter parameterAutIntNo = new SqlParameter("@AutIntNo", SqlDbType.Int, );
  290. parameterAutIntNo.Value = autIntNo;
  291. sqlDALocs.SelectCommand.Parameters.Add(parameterAutIntNo);
  292.  
  293. SqlParameter parameterSearch = new SqlParameter("@Search", SqlDbType.VarChar, );
  294. parameterSearch.Value = search;
  295. sqlDALocs.SelectCommand.Parameters.Add(parameterSearch);
  296.  
  297. SqlParameter parameterOrderBy = new SqlParameter("@OrderBy", SqlDbType.VarChar, );
  298. parameterOrderBy.Value = orderBy;
  299. sqlDALocs.SelectCommand.Parameters.Add(parameterOrderBy);
  300.  
  301. SqlParameter parameterPageSize = new SqlParameter("@PageSize", SqlDbType.Int);
  302. parameterPageSize.Value = pageSize;
  303. sqlDALocs.SelectCommand.Parameters.Add(parameterPageSize);
  304.  
  305. SqlParameter parameterPageIndex = new SqlParameter("@PageIndex", SqlDbType.Int);
  306. parameterPageIndex.Value = pageIndex;
  307. sqlDALocs.SelectCommand.Parameters.Add(parameterPageIndex);
  308.  
  309. SqlParameter parameterTotalCount = new SqlParameter("@TotalCount", SqlDbType.Int);
  310. parameterTotalCount.Direction = ParameterDirection.Output;
  311. sqlDALocs.SelectCommand.Parameters.Add(parameterTotalCount);
  312.  
  313. // Execute the command and close the connection
  314. sqlDALocs.Fill(dsLocs);
  315. sqlDALocs.SelectCommand.Connection.Dispose();
  316.  
  317. totalCount = (int)(parameterTotalCount.Value == DBNull.Value ? : parameterTotalCount.Value);
  318.  
  319. // Return the dataset result
  320. return dsLocs;
  321. }
  322.  
  323. public int UpdateLocation(int locIntNo, int acIntNo, int szIntNo, int rdtIntNo,
  324. string locCameraCode, string locCode, string locDescr,
  325. string locStreetCode, string locStreetName, string locTravelDirection,
  326. int locOffenceSpeedStart, string province, string city, string suburb,
  327. string streetA, string streetB, string route, string from, string to, string gpsX, string gpsY,
  328. string locBranchCode, string lastUser, int LoSuIntNo, string locType, string locRegion, bool isRailwayCrossing)
  329. {
  330. // Create Instance of Connection and Command Object
  331. SqlConnection con = new SqlConnection(mConstr);
  332. SqlCommand cmd = new SqlCommand("LocationUpdate", con);
  333.  
  334. // Mark the Command as a SPROC
  335. cmd.CommandType = CommandType.StoredProcedure;
  336.  
  337. // Add Parameters to SPROC
  338. SqlParameter parameterACIntNo = new SqlParameter("@ACIntNo", SqlDbType.Int, );
  339. parameterACIntNo.Value = acIntNo;
  340. cmd.Parameters.Add(parameterACIntNo);
  341.  
  342. SqlParameter parameterRdTIntNo = new SqlParameter("@RdTIntNo", SqlDbType.Int, );
  343. parameterRdTIntNo.Value = rdtIntNo;
  344. cmd.Parameters.Add(parameterRdTIntNo);
  345.  
  346. SqlParameter parameterSZIntNo = new SqlParameter("@SZIntNo", SqlDbType.Int, );
  347. parameterSZIntNo.Value = szIntNo;
  348. cmd.Parameters.Add(parameterSZIntNo);
  349.  
  350. SqlParameter parameterLocCameraCode = new SqlParameter("@LocCameraCode", SqlDbType.VarChar, );
  351. parameterLocCameraCode.Value = locCameraCode;
  352. cmd.Parameters.Add(parameterLocCameraCode);
  353.  
  354. SqlParameter parameterLocCode = new SqlParameter("@LocCode", SqlDbType.VarChar, );
  355. parameterLocCode.Value = locCode;
  356. cmd.Parameters.Add(parameterLocCode);
  357.  
  358. SqlParameter parameterLocDescr = new SqlParameter("@LocDescr", SqlDbType.VarChar, );
  359. parameterLocDescr.Value = locDescr;
  360. cmd.Parameters.Add(parameterLocDescr);
  361.  
  362. SqlParameter parameterLocStreetCode = new SqlParameter("@LocStreetCode", SqlDbType.VarChar, );
  363. parameterLocStreetCode.Value = locStreetCode;
  364. cmd.Parameters.Add(parameterLocStreetCode);
  365.  
  366. SqlParameter parameterLocStreetName = new SqlParameter("@LocStreetName", SqlDbType.VarChar, );
  367. parameterLocStreetName.Value = locStreetName;
  368. cmd.Parameters.Add(parameterLocStreetName);
  369.  
  370. SqlParameter parameterLocTravelDirection = new SqlParameter("@LocTravelDirection", SqlDbType.Char, );
  371. parameterLocTravelDirection.Value = locTravelDirection;
  372. cmd.Parameters.Add(parameterLocTravelDirection);
  373.  
  374. SqlParameter parameterLocOffenceSpeedStart = new SqlParameter("@LocOffenceSpeedStart", SqlDbType.Int);
  375. parameterLocOffenceSpeedStart.Value = locOffenceSpeedStart;
  376. cmd.Parameters.Add(parameterLocOffenceSpeedStart);
  377.  
  378. SqlParameter parameterLoSuIntNo = new SqlParameter("@LoSuIntNo", SqlDbType.Int, );
  379. parameterLoSuIntNo.Value = LoSuIntNo;
  380. cmd.Parameters.Add(parameterLoSuIntNo);
  381.  
  382. cmd.Parameters.Add("Province", SqlDbType.VarChar, ).Value = province;
  383. cmd.Parameters.Add("City", SqlDbType.VarChar, ).Value = city;
  384. cmd.Parameters.Add("Suburb", SqlDbType.VarChar, ).Value = suburb;
  385. cmd.Parameters.Add("StreetA", SqlDbType.VarChar, ).Value = streetA;
  386. cmd.Parameters.Add("StreetB", SqlDbType.VarChar, ).Value = streetB;
  387. cmd.Parameters.Add("Route", SqlDbType.VarChar, ).Value = route;
  388. cmd.Parameters.Add("From", SqlDbType.VarChar, ).Value = from;
  389. cmd.Parameters.Add("To", SqlDbType.VarChar, ).Value = to;
  390. cmd.Parameters.Add("GpsX", SqlDbType.VarChar, ).Value = gpsX;
  391. cmd.Parameters.Add("GpsY", SqlDbType.VarChar, ).Value = gpsY;
  392. cmd.Parameters.Add("LocBranchCode", SqlDbType.Char, ).Value = locBranchCode;
  393. cmd.Parameters.Add("LastUser", SqlDbType.VarChar, ).Value = lastUser;
  394. cmd.Parameters.Add("LocType", SqlDbType.Char, ).Value = locType;
  395. cmd.Parameters.Add("LocRegion", SqlDbType.NVarChar, ).Value = locRegion;
  396.  
  397. //2013-12-12 Heidi added for check Railway Crossing on Location Maintenance page(5149)
  398. cmd.Parameters.Add("IsRailwayCrossing", SqlDbType.Bit).Value = isRailwayCrossing;
  399.  
  400. SqlParameter parameterLocIntNo = new SqlParameter("@LocIntNo", SqlDbType.Int);
  401. parameterLocIntNo.Direction = ParameterDirection.InputOutput;
  402. parameterLocIntNo.Value = locIntNo;
  403. cmd.Parameters.Add(parameterLocIntNo);
  404.  
  405. try
  406. {
  407. con.Open();
  408. cmd.ExecuteNonQuery();
  409. con.Dispose();
  410.  
  411. // Calculate the CustomerID using Output Param from SPROC
  412. int LocIntNo = (int)cmd.Parameters["@LocIntNo"].Value;
  413. //int locId = (int)parameterLocIntNo.Value;
  414.  
  415. return LocIntNo;
  416. }
  417. catch (Exception e)
  418. {
  419. con.Dispose();
  420. string msg = e.Message;
  421. return ;
  422. }
  423. }
  424.  
  425. public int DeleteLocation(int locIntNo, ref string errMessage)
  426. {
  427.  
  428. // Create Instance of Connection and Command Object
  429. SqlConnection myConnection = new SqlConnection(mConstr);
  430. SqlCommand myCommand = new SqlCommand("LocationDelete", myConnection);
  431.  
  432. // Mark the Command as a SPROC
  433. myCommand.CommandType = CommandType.StoredProcedure;
  434.  
  435. // Add Parameters to SPROC
  436. SqlParameter parameterLocIntNo = new SqlParameter("@LocIntNo", SqlDbType.Int, );
  437. parameterLocIntNo.Value = locIntNo;
  438. parameterLocIntNo.Direction = ParameterDirection.InputOutput;
  439. myCommand.Parameters.Add(parameterLocIntNo);
  440.  
  441. try
  442. {
  443. myConnection.Open();
  444. myCommand.ExecuteNonQuery();
  445. myConnection.Dispose();
  446.  
  447. // Calculate the CustomerID using Output Param from SPROC
  448. int LocIntNo = (int)parameterLocIntNo.Value;
  449.  
  450. return LocIntNo;
  451. }
  452. catch (Exception ex)
  453. {
  454. errMessage = ex.Message;
  455. return ;
  456. }
  457. finally
  458. {
  459. myConnection.Dispose();
  460. }
  461. }
  462.  
  463. /// <summary>
  464. /// Gets the auth_Location list by auth DS.
  465. /// </summary>
  466. /// <param name="autIntNo">The aut int no.</param>
  467. /// <returns></returns>
  468. public DataSet GetValueTextListByLocationTable(int autIntNo)
  469. {
  470. SqlDataAdapter sqlDALocations = new SqlDataAdapter();
  471. DataSet dsLocations = new DataSet();
  472.  
  473. // Create Instance of Connection and Command Object
  474. sqlDALocations.SelectCommand = new SqlCommand();
  475. sqlDALocations.SelectCommand.Connection = new SqlConnection(mConstr);
  476. sqlDALocations.SelectCommand.CommandText = "GetValueTextListByLocationTable";
  477.  
  478. // Mark the Command as a SPROC
  479. sqlDALocations.SelectCommand.CommandType = CommandType.StoredProcedure;
  480.  
  481. SqlParameter parameterAutIntNo = new SqlParameter("@AutIntNo", SqlDbType.Int, );
  482. parameterAutIntNo.Value = autIntNo;
  483. sqlDALocations.SelectCommand.Parameters.Add(parameterAutIntNo);
  484.  
  485. // Execute the command and close the connection
  486. sqlDALocations.Fill(dsLocations);
  487. sqlDALocations.SelectCommand.Connection.Dispose();
  488.  
  489. // Return the dataset result
  490. return dsLocations;
  491. }
  492.  
  493. /// <summary>
  494. /// Heidi 2013-12-12 Get Railway Locations DDL by AutIntNo
  495. /// </summary>
  496. /// <param name="autIntNo">The aut int no.</param>
  497. /// <returns></returns>
  498. public DataSet GetRailwayLocationsByAutIntNo(int autIntNo,int locIntNo,bool IsAll)
  499. {
  500. SqlDataAdapter sqlDALocations = new SqlDataAdapter();
  501. DataSet dsLocations = new DataSet();
  502.  
  503. // Create Instance of Connection and Command Object
  504. sqlDALocations.SelectCommand = new SqlCommand();
  505. sqlDALocations.SelectCommand.Connection = new SqlConnection(mConstr);
  506. sqlDALocations.SelectCommand.CommandText = "GetRailwayLocationsByAutIntNo";
  507.  
  508. // Mark the Command as a SPROC
  509. sqlDALocations.SelectCommand.CommandType = CommandType.StoredProcedure;
  510.  
  511. SqlParameter parameterAutIntNo = new SqlParameter("@AutIntNo", SqlDbType.Int, );
  512. parameterAutIntNo.Value = autIntNo;
  513. sqlDALocations.SelectCommand.Parameters.Add(parameterAutIntNo);
  514.  
  515. SqlParameter parameterLocIntNo = new SqlParameter("@LocIntNo", SqlDbType.Int, );
  516. parameterLocIntNo.Value = locIntNo;
  517. sqlDALocations.SelectCommand.Parameters.Add(parameterLocIntNo);
  518.  
  519. SqlParameter parameterISALL = new SqlParameter("@ISALL", SqlDbType.Bit);
  520. parameterISALL.Value = IsAll;
  521. sqlDALocations.SelectCommand.Parameters.Add(parameterISALL);
  522.  
  523. // Execute the command and close the connection
  524. sqlDALocations.Fill(dsLocations);
  525. sqlDALocations.SelectCommand.Connection.Dispose();
  526.  
  527. // Return the dataset result
  528. return dsLocations;
  529. }
  530.  
  531. /// <summary>
  532. /// Heidi 2013-12-16 Get Railway Locations by AutIntNo and LocIntNo
  533. /// </summary>
  534. /// <param name="autIntNo">The aut int no.</param>
  535. /// <returns></returns>
  536. public DataSet GetLocationByLocIntNoAndIsRailwayCrossing(int autIntNo, int locIntNo)
  537. {
  538. SqlDataAdapter sqlDALocations = new SqlDataAdapter();
  539. DataSet dsLocations = new DataSet();
  540.  
  541. // Create Instance of Connection and Command Object
  542. sqlDALocations.SelectCommand = new SqlCommand();
  543. sqlDALocations.SelectCommand.Connection = new SqlConnection(mConstr);
  544. sqlDALocations.SelectCommand.CommandText = "GetLocationByLocIntNoAndIsRailwayCrossing";
  545.  
  546. // Mark the Command as a SPROC
  547. sqlDALocations.SelectCommand.CommandType = CommandType.StoredProcedure;
  548.  
  549. SqlParameter parameterAutIntNo = new SqlParameter("@AutIntNo", SqlDbType.Int, );
  550. parameterAutIntNo.Value = autIntNo;
  551. sqlDALocations.SelectCommand.Parameters.Add(parameterAutIntNo);
  552.  
  553. SqlParameter parameterLocIntNo= new SqlParameter("@LocIntNo", SqlDbType.Int, );
  554. parameterLocIntNo.Value = locIntNo;
  555. sqlDALocations.SelectCommand.Parameters.Add(parameterLocIntNo);
  556.  
  557. // Execute the command and close the connection
  558. sqlDALocations.Fill(dsLocations);
  559. sqlDALocations.SelectCommand.Connection.Dispose();
  560.  
  561. // Return the dataset result
  562. return dsLocations;
  563. }
  564. }
  565. }

从数据库中取数据(Stalberg.TMS.Data)的更多相关文章

  1. 定时从远程的数据库中取数据,然后把取出来的数据插入或更新本地的oracle数据库的表

    最近项目中有一种需求: 大致需求是这样的 通过给定的 用户名和密码 要定时从远程的数据库中取数据,然后把取出来的数据插入或更新本地的oracle数据库的表 项目的结构式struts1 hibernat ...

  2. php从mysql数据库中取数据

    php从数据库中取数据  面向过程 <?php $server_name="localhost:3306"; //数据库服务器名称 $username="root& ...

  3. loadrunner 参数化-如何从数据库中取数据-连接数据库进行参数化

    LoadRunner提供两种参数化取值方式,一种是手动编辑,另一种就是通过连接数据库取值.一般在大型业务并发压力测试时,数据量肯定也都是非常大的,所以手动去编辑就不切实际了,这时用连接数据库的功能就方 ...

  4. JDBC:从数据库中取数据的一个bug

    先看错误信息: java.sql.SQLException: Before start of result set at com.mysql.jdbc.SQLError.createSQLExcept ...

  5. mybatis从数据库中取数据且分组,返回分组数据

    mapper.xml文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PU ...

  6. vb.net从数据库中取数据

    1.设置从Model中的Sub Main 启动 2.程序结构 3.Model1 Imports System.Windows.Forms.Application Module Module1 Sub ...

  7. Jmeter-从数据库中获取数据并作为变量传输

    再今天重新学习,从数据库中取数据,并作为变量传到下一个请求中. 首先第一步要导入mysql驱动包 一.添加JDBC Connection Configuration 设置链接 Database URL ...

  8. android从数据库中取音乐数据

    android从手机数据库中取音乐数据 直接贴代码 public void getMp3(){ list = new ArrayList<>(); Cursor mAudioCursor ...

  9. 多线程查询数据,将结果存入到redis中,最后批量从redis中取数据批量插入数据库中【我】

    多线程查询数据,将结果存入到redis中,最后批量从redis中取数据批量插入数据库中 package com.xxx.xx.reve.service; import java.util.ArrayL ...

随机推荐

  1. scw——03错误,swagger开启错误

    错误: 代码: @Value("${swagger2.enable:false}") private boolean enable = false; 原因:没有开启swagger的 ...

  2. go基础_定时器

    每间隔5s打印一句hello // time_ticker package main import ( "fmt" "time" ) func main() { ...

  3. C#常用的form窗体属性(最大化、最小化、窗体居中)

    一.窗体居中 //窗体居中 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 二.去掉最小化.最大化 ...

  4. Linux - Linux中线程为何有PID?

    重现 用htop的Tree view(按F5)之后查看线程 参考 https://segmentfault.com/q/1010000003586656 mousycoder的回答 https://u ...

  5. JS高级---复习

    复习 面向过程和面向对象都是编程的思想, 方式不一样 面向过程: 凡事都是亲力亲为, 所有的代码都要自己写, 每一步都要很清楚, 注重的是过程 面向对象: 执行者成为指挥者, 只要找对象, 然后让对象 ...

  6. TCP的状态转换

    TCP的状态转换图 手写的状态转换图 一.服务端状态变迁:​ 服务端创建套接字之后调用listen函数将套接字有一个未连接的主动套接字转换为被动套接字,指示内核应接受指向该套接字的连接请求,套接字状态 ...

  7. sublime3使用技巧

    1.鼠标悬浮,显示文件引用 Preference ——>   Settings   ——>    "index_files": true   (保存,重新打开即可) 2 ...

  8. wampserver 配置的几个坑(雾

    1. 从安装版本说起 自从我进入大学之后,便继承了学长那里的wampserver2.5版本 直到有一天自己下载wamp的时候才注意到已经有 3.0.6版本了 (现在有更高的了 但是3.0.6够用了) ...

  9. [NLP]Transformer模型解析

    简介[2] Attention Is All You Need是2017年google提出来的一篇论文,论文里提出了一个新的模型,叫Transformer,这个结构广泛应用于NLP各大领域,是目前比较 ...

  10. Python 多任务(进程) day1(3)

    进程间的通信 可以用socket进行进程间的通信 可以用同意文件来进行通信(但是在硬盘上读取和写入比较慢,内存运行太快了) Queue队列(记得是队列)  在同一内存中通信 因为进程之间不能共享全局变 ...