public Vehicle(String argConnection, Int32 argVehicleId) { mConnection = argConnection; string pstrSql = "SELECT * FROM Vehicle WHERE VehicleId=" + argVehicleId; SqlDataReader dr = SqlHelper.ExecuteReader(Connection, CommandType.Text, pstrSql); if (dr.Read()) { mVehicleId = (System.Int32)dr["VehicleId"]; mRegistrationNo = (System.String)dr["RegistrationNo"]; mDtRegistration = (System.DateTime)dr["DtRegistration"]; mDtPurchase = (System.DateTime)dr["DtPurchase"]; mRegisteredOwner = (System.String)dr["RegisteredOwner"]; mModelVersion = new ModelVersion(Connection, (int)dr["ModelVersionId"]); mTypeOfBody = (System.String)dr["TypeOfBody"]; mClassOfVehice = (System.String)dr["ClassOfVehice"]; mPreAccidentCondition = (System.String)dr["PreAccidentCondition"]; mRegisteredLadenWeight = (System.Single)dr["RegisteredLadenWeight"]; mUnladenWeight = (System.Single)dr["UnladenWeight"]; mFitnessCertificateNo = (System.String)dr["FitnessCertificateNo"]; mDtValidFitnessCertificate = (System.DateTime)dr["DtValidFitnessCertificate"]; mDtTaxPaidUpto = (System.DateTime)dr["DtTaxPaidUpto"]; mRoutePermitNo = (System.String)dr["RoutePermitNo"]; mDtValidRoutePermit = (System.DateTime)dr["DtValidRoutePermit"]; mTypeOfPermit = (System.String)dr["TypeOfPermit"]; mRouteArea = (System.String)dr["RouteArea"]; mStatusRC = (System.String)dr["StatusRC"]; mPaintType = new PaintType(Connection, (System.Int32)dr["PaintTypeId"]); mChassisNo = dr["ChassisNo"].ToString(); mEngineNo = dr["EngineNo"].ToString(); mIDV = dr["IDV"].ToString(); mDtRegistrationRemarks = dr["DtRegistrationRemarks"].ToString(); mDoPrintDOP = dr.GetBoolean(dr.GetOrdinal("DoPrintDOP")); } else { Exception ex = new Exception("Identifier does not exist."); ex.Source = "Vehicle.Vehicle()"; throw ex; } dr.Close(); }
public PartModelVersion(String argConnection, Int32 argPartModelVersionId) { mConnection = argConnection; string pstrSql = "SELECT * FROM PartModelVersion WHERE PartModelVersionId=" + argPartModelVersionId; SqlDataReader dr = SqlHelper.ExecuteReader(Connection, CommandType.Text, pstrSql); if (dr.Read()) { mPartModelVersionId = (System.Int32)dr["PartModelVersionId"]; mModelVersion = new ModelVersion(Connection, (int)dr["ModelVersionId"]); mPart = new Part(Connection, (int)dr["PartId"]); } else { Exception ex = new Exception("Identifier does not exist."); ex.Source = "PartModelVersion.PartModelVersion()"; throw ex; } dr.Close(); }
public System.Data.DataTable Items(ModelVersion argMv) { try { //string sql = "SELECT Part.PartId, Part.Part, Part.PartCategoryId, Part.VatRate, "; //sql += "Part.MCode, PartCategory.PartCategory, Model.Model, ModelVersion.ModelVersion, "; //sql += "VehicleMake.VehicleMake, Part.Code "; //sql += "FROM VehicleMake LEFT OUTER JOIN "; //sql += "PartVehicleMake ON VehicleMake.VehicleMakeId = PartVehicleMake.VehicleMakeId "; //sql += "RIGHT OUTER JOIN "; //sql += "Part INNER JOIN "; //sql += "PartCategory ON Part.PartCategoryId = PartCategory.PartCategoryId LEFT OUTER JOIN "; //sql += "Model RIGHT OUTER JOIN "; //sql += "PartModel ON Model.ModelId = PartModel.ModelId ON Part.PartId = PartModel.PartId "; //sql += "ON PartVehicleMake.PartId = Part.PartId LEFT OUTER JOIN "; //sql += "PartModelVersion LEFT OUTER JOIN "; //sql += "ModelVersion ON PartModelVersion.ModelVersionId = ModelVersion.ModelVersionId "; //sql += "ON Part.PartId = PartModelVersion.PartId "; //sql += "WHERE ModelVersion.ModelVersionId = " + argMv.ModelVersionId; String sql = null; sql = "SELECT CompundSelect.* FROM ( "; sql += " SELECT "; sql += " Part.PartId, Part.Part, Part.PartCategoryId, Code, "; sql += " Part.VatRate, Part.MCode, PartCategory.PartCategory, "; sql += " Model.Model, ModelVersion.ModelVersion, VehicleMake.VehicleMake "; sql += " FROM "; sql += " (ModelVersion INNER JOIN (Model INNER JOIN VehicleMake "; sql += " ON Model.VehicleMakeId = VehicleMake.VehicleMakeId) "; sql += " ON ModelVersion.ModelId = Model.ModelId) "; sql += " INNER JOIN (PartModelVersion INNER JOIN (Part INNER JOIN PartCategory "; sql += " ON Part.PartCategoryId = PartCategory.PartCategoryId) "; sql += " ON PartModelVersion.PartId = Part.PartId) "; sql += " ON PartModelVersion.ModelVersionId = ModelVersion.ModelVersionId "; sql += " WHERE ModelVersion.ModelVersionId = " + argMv.ModelVersionId + " "; sql += " UNION "; sql += " SELECT "; sql += " Part.PartId, Part.Part, Part.PartCategoryId, Code, "; sql += " Part.VatRate, Part.MCode, PartCategory.PartCategory, "; sql += " Model.Model, '<All>', VehicleMake.VehicleMake "; sql += " FROM "; sql += " (Model INNER JOIN VehicleMake "; sql += " ON Model.VehicleMakeId = VehicleMake.VehicleMakeId) "; sql += " INNER JOIN (PartModel INNER JOIN (Part INNER JOIN PartCategory "; sql += " ON Part.PartCategoryId = PartCategory.PartCategoryId) "; sql += " ON PartModel.PartId = Part.PartId) "; sql += " ON Model.ModelId = PartModel.ModelId "; sql += " WHERE Model.ModelId = " + argMv.Model.ModelId + " "; sql += " UNION "; sql += " SELECT "; sql += " Part.PartId, Part.Part, Part.PartCategoryId, Code, "; sql += " Part.VatRate, Part.MCode, PartCategory.PartCategory, "; sql += " '<All>', '<All>', VehicleMake.VehicleMake "; sql += " FROM "; sql += " VehicleMake "; sql += " INNER JOIN (PartVehicleMake INNER JOIN (Part INNER JOIN PartCategory "; sql += " ON Part.PartCategoryId = PartCategory.PartCategoryId) "; sql += " ON PartVehicleMake.PartId = Part.PartId) "; sql += " ON VehicleMake.VehicleMakeId = PartVehicleMake.VehicleMakeId "; sql += " WHERE VehicleMake.VehicleMakeId = " + argMv.Model.VehicleMake.VehicleMakeId + " "; sql += ") CompundSelect ORDER BY CompundSelect.Part"; DataSet ds = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(Connection, CommandType.Text, sql); return(ds.Tables[0]); } catch (Exception ex) { //OSN.Generic.EventLogHelper appLog = new OSN.Generic.EventLogHelper(); //appLog.Source = "Communique"; //StringBuilder sb = new StringBuilder(); //sb.Append("public System.Data.DataTable Items()"); //sb.Append("Exception=" + ex.Message); //appLog.WriteEntry(sb.ToString()); return(new DataTable()); } }