public Driver(String argConnection, Int32 argDriverId) { mConnection = argConnection; string pstrSql = "SELECT * FROM Driver WHERE DriverId=" + argDriverId; SqlDataReader dr = SqlHelper.ExecuteReader(Connection, CommandType.Text, pstrSql); if (dr.Read()) { mDriverId = (System.Int32)dr["DriverId"]; mDefault = (System.String)dr["Driver"]; mDtLicenseIssue = (System.DateTime)dr["DtLicenseIssue"]; mLicenseNo = (System.String)dr["LicenseNo"]; mDtValidLicense = (System.DateTime)dr["DtValidLicense"]; mIssuingAuthority = (System.String)dr["IssuingAuthority"]; mLicenseType = new LicenseType(Connection, (int)dr["LicenseTypeId"]); mBadgeNo = (System.String)dr["BadgeNo"]; mStatusDL = (System.String)dr["StatusDL"]; } else { Exception ex = new Exception("Identifier does not exist."); ex.Source = "Driver.Driver()"; throw ex; } dr.Close(); }
public System.Boolean IsValid(LicenseType argLicenseType) { System.String sql = "SELECT * FROM VldtLtVc WHERE VehicleCategoryId = " + this.VehicleCategoryId + " AND LicenseTypeId = " + argLicenseType.LicenseTypeId; System.Data.SqlClient.SqlDataReader dr = SqlHelper.ExecuteReader(Connection, CommandType.Text, sql); System.Boolean pIsValid = dr.Read(); dr.Close(); return(pIsValid); }
public string Transaction(enumDBTransaction argTransactionType) { try { enumDBTransaction pTransactionType = argTransactionType; if (pTransactionType == enumDBTransaction.spAdd) { mDriverId = this.Identity.New(); } SqlParameter[] parrSP = new SqlParameter[10]; if (LicenseType.LicenseTypeId == 0) { LicenseType = new LicenseType(Connection, -1); } parrSP[0] = new SqlParameter("@Action", pTransactionType); parrSP[1] = new SqlParameter("@DriverId", DriverId); parrSP[2] = new SqlParameter("@Driver", Default); parrSP[3] = new SqlParameter("@DtLicenseIssue", DtLicenseIssue); parrSP[4] = new SqlParameter("@LicenseNo", LicenseNo); parrSP[5] = new SqlParameter("@DtValidLicense", DtValidLicense); parrSP[6] = new SqlParameter("@IssuingAuthority", IssuingAuthority); parrSP[7] = new SqlParameter("@LicenseTypeId", this.LicenseType.LicenseTypeId); parrSP[8] = new SqlParameter("@BadgeNo", BadgeNo); parrSP[9] = new SqlParameter("@StatusDL", StatusDL); SqlHelper.ExecuteNonQuery(Connection, CommandType.StoredProcedure, "uspDriver", parrSP); return(null); } catch (Exception ex) { //OSN.Generic.EventLogHelper appLog = new OSN.Generic.EventLogHelper(); //appLog.Source = "Communique"; //StringBuilder sb = new StringBuilder(); //sb.Append("public bool Transaction(enumDBTransaction argTransactionType)"); //sb.Append("Exception=" + ex.Message); //appLog.WriteEntry(sb.ToString()); return("Transaction failed"); } }