我在mysql中有一个名为asset的车主表。司机必须在3个不同的栏目中输入3个到期日,即保险到期日,健身证到期日和道路税到期日。
还有一个名为vehiclenotification table的表,其中包含保险,健身和roadtax日期的通知类型列,根据在7天,1天前15天发送的警报,每种类型存储12次4记录到期日。
如何通过车辆通知表截止日期的一列中的所有3个日期和车辆通知表的通知日期列下保存的12条记录?
Vehicle Master Table: CREATE TABLE asset (
asID int(11) NOT NULL AUTO_INCREMENT,
asCode varchar(15) DEFAULT NULL COMMENT 'Asset CODE',
asName varchar(100) DEFAULT NULL COMMENT 'Asset NAME',
asInsuranceDueDt int(11) DEFAULT NULL COMMENT 'Insurance Due DATE',
asFitCertDueDate int(11) DEFAULT NULL COMMENT 'Fitness Certificate Due DATE',
asRoadTaxDueDt int(11) DEFAULT NULL COMMENT 'Road Tax Due DATE',
asBattLastChargeDate int(11) DEFAULT NULL COMMENT 'Battery LAST Charge DATE' )
Vehicle Mail Notification Table: CREATE TABLE assetemailnotification (
anID INT(11) NOT NULL AUTO_INCREMENT,
asID INT(11) NOT NULL,
anType SMALLINT(2) DEFAULT NULL COMMENT '1->Insurance, 2->Fitnes Certificate, 3->Road Tax',
anNoOdays SMALLINT(2) DEFAULT NULL COMMENT 'No Of days Notification',
anDueDate INT(11) DEFAULT NULL COMMENT 'Notification Due Date',
anNotificationDate INT(11) DEFAULT NULL,
anStatus SMALLINT(1) DEFAULT NULL COMMENT '0->Not Send, 1-Send',
acAccID INT(11) DEFAULT NULL PRIMARY KEY (anID) )
private int InsertRecord()
{
int _retVal = -1;
try
{
int _errorCode = (int)ErrorCodes.NoError;
string _tblNM = DBStructure.TABLE_ASSET_MASTER;
FieldNames[] _selFlds = new FieldNames[1];
_selFlds[0].FieldName = DBStructure.ASSET_MASTER_CODE;
cndCheck[] _whCnd = new cndCheck[2];
_whCnd[0].FieldName = DBStructure.ASSET_MASTER_CODE;
_whCnd[0].FieldType = Fieldtypes.Char;
_whCnd[0].FirstFieldValue = AssetCode.ToString();
_whCnd[0].ArithmeticOp = ArithmeticOperator.EQUALS;
_whCnd[0].LogicOp = LogicalOperator.AND;
_whCnd[1].FieldName = DBStructure.ASSET_MASTER_ACCOUNT_ID;
_whCnd[1].FieldType = Fieldtypes.Integer;
_whCnd[1].FirstFieldValue = UserGroupID.ToString();
_whCnd[1].ArithmeticOp = ArithmeticOperator.EQUALS;
DataSet _dsAsset = _dalAccess.Select(false, _tblNM, true, _selFlds, _whCnd, out _errorCode);
if (_errorCode == (int)ErrorCodes.NoError)
{
if (_dsAsset.Tables[0].Rows.Count > 0)
StatusDescription = GetGlobalResourceObject(ResorceFileName, "AssetExists").ToString();
else
{
RecordValues[] _newRec = new RecordValues[24];
_newRec[0].FieldName = DBStructure.ASSET_MASTER_CODE;
_newRec[0].FieldType = Fieldtypes.VarChar;
_newRec[0].FieldValue = AssetCode;
_newRec[1].FieldName = DBStructure.ASSET_MASTER_NAME;
_newRec[1].FieldType = Fieldtypes.VarChar;
_newRec[1].FieldValue = AssetName;
_newRec[16].FieldName = DBStructure.ASSET_MASTER_INSURANCE_DUE_DATE;
_newRec[16].FieldType = Fieldtypes.Integer;
_newRec[16].FieldValue = String.IsNullOrEmpty(InsuranceDueDate.ToString()) ? null : InsuranceDueDate.ToString();
_newRec[17].FieldName = DBStructure.ASSET_MASTER_FITNESS_CERTIFICATION_DUE_DATE;
_newRec[17].FieldType = Fieldtypes.Integer;
_newRec[17].FieldValue = String.IsNullOrEmpty(FitnessCertificationDueDate.ToString()) ? null : FitnessCertificationDueDate.ToString();
_newRec[18].FieldName = DBStructure.ASSET_MASTER_ROAD_TAX_DUE_DATE;
_newRec[18].FieldType = Fieldtypes.Integer;
_newRec[18].FieldValue = String.IsNullOrEmpty(RoadTaxDueDate.ToString()) ? null : RoadTaxDueDate.ToString();
_retVal = _dalAccess.Insert(false, _tblNM, _newRec, out _errorCode);
if (_errorCode == (int)ErrorCodes.NoError)
{
StatusDescription = GetGlobalResourceObject(globalResourceFileName, "InsertedSucessfully").ToString();
}
}
}
else
StatusDescription = _errorLogger.GetErrorMessage(_errorCode);
return _retVal;
}
catch (Exception Ex)
{
_errorLogger.PrintUnknownError(Ex.Message.ToString(), GetModuleName(), GetPageName(), "InsertRecord()");
return -1;
}
}