public override bool IsDataOk(ParadoxRecord dataRec) { var val = dataRec.DataValues[this.DataFieldIndex]; var comp = Comparer.Default.Compare(val, this.Value); switch (Operator) { case ParadoxCompareOperator.Equal: return comp == 0; case ParadoxCompareOperator.NotEqual: return comp != 0; case ParadoxCompareOperator.Greater: return comp > 0; case ParadoxCompareOperator.GreaterOrEqual: return comp >= 0; case ParadoxCompareOperator.Less: return comp < 0; case ParadoxCompareOperator.LessOrEqual: return comp <= 0; default: throw new NotSupportedException(); } }
private int insertParkChargeRecord(int parkSpaceID, ParadoxRecord rec, int localParkID) { object[] chargeitems = { "Balance Forward", //Balance Forward "Late Charge", //Late Charge rec.DataValues[28], //Charge item 1 rec.DataValues[31], //Charge item 2 rec.DataValues[34], //Charge item 3 rec.DataValues[37], //Charge item 4 rec.DataValues[40], //Charge item 5 rec.DataValues[43], //Charge item 6 rec.DataValues[46], //Charge item 7 rec.DataValues[49], //Charge item 8 rec.DataValues[127], //Charge item 9 rec.DataValues[130] //Charge item 10 }; object[] chargevalues = { rec.DataValues[25], //Balance Forward rec.DataValues[26], //Late Charge rec.DataValues[29], //Charge item 1 value rec.DataValues[32], //Charge item 2 value rec.DataValues[35], //Charge item 3 value rec.DataValues[38], //Charge item 4 value rec.DataValues[41], //Charge item 5 value rec.DataValues[44], //Charge item 6 value rec.DataValues[47], //Charge item 7 value rec.DataValues[50], //Charge item 8 value rec.DataValues[128], //Charge item 9 value rec.DataValues[131] //Charge item 10 value }; for (int a = 0; a < 12; a = a + 1) { if (chargevalues[a] != DBNull.Value) { try { int x = 0; // get the id of chargeitem[a] from the chargeeitem table and check if the parkchargeitem table has the record x = getCharegeItemID(chargeitems[a].ToString()); string c = "parkID = @value0 and chargeItemID = @value1"; object[] v = { localParkID, x }; String[] parkOptionsColumns = { "ParkID", "ChargeItemID" }; object[] r = DatabaseControl.getSingleRecord(parkOptionsColumns, DatabaseControl.parkOptionsTable, c, v); if (r == null) { DatabaseControl.executeInsertQuery(DatabaseControl.parkOptionsTable, parkOptionsColumns, v); } object[] values = { parkSpaceID, rec.DataValues[2], chargeitems[a], chargevalues[a], x }; if (a < 9 ) { DatabaseControl.executeInsertQuery(DatabaseControl.spaceChargeTable, DatabaseControl.spaceChargeColumns, values); } else // recode 9, 10, 11 are temporary charges { object[] tempValues = { parkSpaceID, rec.DataValues[2], chargeitems[a], chargevalues[a] }; DatabaseControl.executeInsertQuery(DatabaseControl.spaceTempChargeTable, DatabaseControl.spaceTempChargeColumns, tempValues); } } catch (Exception e) { String s = e.Message; //MessageBox.Show("Import failed for charge item: " +chargeitems[a].ToString() + chargevalues[a].ToString() + " for " + parkSpaceID.ToString()); } } } return 1; }
private void insertMessage(ParadoxRecord rec, int localParkID, int column) { string topMessage = rec.DataValues[column].ToString() + rec.DataValues[column + 1].ToString(); string botMessage = rec.DataValues[column + 2].ToString() + rec.DataValues[column + 3].ToString() + rec.DataValues[column + 4].ToString() + rec.DataValues[column + 5].ToString() + rec.DataValues[column + 6].ToString(); object[] values = { localParkID, rec.DataValues[2], botMessage, topMessage}; try { DatabaseControl.executeInsertQuery(DatabaseControl.messageTable, DatabaseControl.messageColumns, values); } catch { } }
private void insertBasicRateforSCE(ParadoxRecord rec, int utilRateID) { Object[] value = { utilRateID, "Regular", 0, //minimum rate rec.DataValues[20] //Regulau Rate }; DatabaseControl.executeInsertQuery(DatabaseControl.utilBasicRatesTable, DatabaseControl.utilBasicRatesColumns, value); value[1] = "Medical"; DatabaseControl.executeInsertQuery(DatabaseControl.utilBasicRatesTable, DatabaseControl.utilBasicRatesColumns, value); value[1] = "CARE"; value[3] = rec.DataValues[21]; DatabaseControl.executeInsertQuery(DatabaseControl.utilBasicRatesTable, DatabaseControl.utilBasicRatesColumns, value); value[1] = "CARE/Medical"; DatabaseControl.executeInsertQuery(DatabaseControl.utilBasicRatesTable, DatabaseControl.utilBasicRatesColumns, value); value[1] = "Regular"; value[2] = 1; // Basic rate value[3] = rec.DataValues[5]; DatabaseControl.executeInsertQuery(DatabaseControl.utilBasicRatesTable, DatabaseControl.utilBasicRatesColumns, value); value[1] = "Medical"; DatabaseControl.executeInsertQuery(DatabaseControl.utilBasicRatesTable, DatabaseControl.utilBasicRatesColumns, value); value[1] = "CARE"; value[3] = rec.DataValues[6]; DatabaseControl.executeInsertQuery(DatabaseControl.utilBasicRatesTable, DatabaseControl.utilBasicRatesColumns, value); value[1] = "CARE/Medical"; DatabaseControl.executeInsertQuery(DatabaseControl.utilBasicRatesTable, DatabaseControl.utilBasicRatesColumns, value); }
private int determineMedicalAllowanceForGas(ParadoxRecord rec) { int result = 0; result = checkStatusColumn(rec.DataValues[11].ToString()); return result; }
public override bool IsDataOk(ParadoxRecord dataRec) { return this.Test(c => c.IsDataOk(dataRec)); }
public abstract bool IsDataOk(ParadoxRecord dataRec);
private int insertUtilCompany(ParadoxRecord rec, string serviceType) { // Check if the utility company exist in database // if not, insert a new one char type = serviceType[4]; //'E' or 'G' or 'W' bool ele = false; bool gas = false; bool wat = false; switch (type) { case 'E': ele = true; break; case 'G': gas = true; break; case 'W': wat = true; break; default: break; } // utilCompanyColumns = {"CompanyName", "IsElectricity", "IsGas", "IsWater"}; Object[] values = { rec.DataValues[1], //Utility Company Name ele,gas,wat }; try { return DatabaseControl.executeInsertQuery(DatabaseControl.utilCompanyTable, DatabaseControl.utilCompanyColumns, values); } catch { return -1; } }
private int insertUtilRate(ParadoxRecord rec, string serviceType, int utilCompanyID, string path) { //For input file of Paradox Tables utilStartDate = getStartDate(path); char type = serviceType[4]; //The fifth letter:'E' or 'G' or 'W' int result = 0; Object[] values = { utilCompanyID, type, utilStartDate, //Effective Date rec.DataValues[3], //Method rec.DataValues[4], //Unit; 1, //Tier Set ID 0 //dirty bit }; try { result = DatabaseControl.executeInsertQuery(DatabaseControl.utilRateTable, DatabaseControl.utilRateColumns, values); } catch { result = -1; } return result; }
private int insertMeterReadRecord(int parkSpaceID, ParadoxRecord rec) { int parkID = DatabaseControl.getParkIDByParkSpaceID(parkSpaceID); Double gasread ; Double eleread ; Double watread ; if (rec.DataValues[20] is DBNull) {gasread = 0;} else {gasread = Convert.ToDouble(rec.DataValues[20]);} if (rec.DataValues[22] is DBNull) {eleread = 0;} else {eleread = Convert.ToDouble(rec.DataValues[22]);} if (rec.DataValues[24] is DBNull) { watread = 0; } else { watread = Convert.ToDouble(rec.DataValues[24]); } Object[] meterValues = { parkID, rec.DataValues[0], //spaceID rec.DataValues[18], //StartDate rec.DataValues[17], //EndDate gasread, //GasCurrentRead eleread, //EleCurrentRead watread, //WatCurrentRead rec.DataValues[137], //Employee ID rec.DataValues[138], //read time rec.DataValues[2], //dueDate rec.DataValues[55], //Gas Thermo factor }; try { DatabaseControl.executeInsertQuery(DatabaseControl.meterReadsTable, DatabaseControl.meterReadsColumns, meterValues); } catch { //MessageBox.Show("Insert Meter Read record failed!" + parkSpaceID); } return 1; }
private int insertPeriodRecord(int parkID, ParadoxRecord rec) { Object[] values = { parkID, rec.DataValues[18], //StartDate rec.DataValues[17], //EndDate rec.DataValues[2], //dueDate }; try { DatabaseControl.executeInsertQuery("ParkPeriod", DatabaseControl.periodColumns, values); } catch { //MessageBox.Show("Insert Meter Read record failed!" + parkSpaceID); } return 1; }
private int insertBillRecord(int parkSpaceID, ParadoxRecord rec) { Object[] billValues = { parkSpaceID, rec.DataValues[2], //DueDate rec.DataValues[19], //GasPreviousRead rec.DataValues[20], //GasCurrentRead rec.DataValues[56], //GasUsage rec.DataValues[73], //GasBill rec.DataValues[21], //ElePreviousRead rec.DataValues[22], //EleCurrentRead rec.DataValues[77], //EleUsage rec.DataValues[96], //EleBill rec.DataValues[23], //WatPreviousRead rec.DataValues[24], //WatCurrentRead rec.DataValues[99], //WatUsage rec.DataValues[116] //WatBill }; for (int i = 2; i < 14; i++) { if (billValues[i] == DBNull.Value) { billValues[i] = 0; } } try { DatabaseControl.executeInsertQuery(DatabaseControl.spaceBillTable, DatabaseControl.spaceBillColumns, billValues); } catch { string ParkNumber = (DatabaseControl.getParkNumberByParkSpaceID(parkSpaceID)).ToString(); //MessageBox.Show("Tenant Bill Import failed for Park/Tenant: " + ParkNumber + "/" + parkSpaceID); } return 1; }
private int insertMeterLocationRecord(int localParkID, ParadoxRecord rec) { String[] locColumns = { "ParkID", "OrderID", "GasMeterLoc", "EleMeterLoc", "WatMeterLoc", "SpecialAccess" }; Object[] locValues = { localParkID, //ParkID rec.DataValues[0], //spaceID rec.DataValues[134], //Gas Location rec.DataValues[133], //Ele Location rec.DataValues[135], //Wat Location rec.DataValues[136] //Wat Location }; try { DatabaseControl.executeInsertQuery(DatabaseControl.meterInfoTable, locColumns, locValues); } catch { //MessageBox.Show("Meter Location Import failed for Park/Space: " + localParkID.ToString() + "/" + rec.DataValues[0].ToString()); } return 1; }
private int insertTenantRecord(int localParkID, ParadoxRecord rec) { //need to convert tenant status string gasStatus = convertStatus(rec.DataValues[11].ToString()); string eleStatus = convertStatus(rec.DataValues[12].ToString()); string watStatus = convertStatus(rec.DataValues[13].ToString()); bool DBForGas = false; bool DBForEle = false; bool DBForWat = false; if (rec.DataValues[14].ToString() == "Y") { DBForGas = true;} if (rec.DataValues[15].ToString() == "Y") { DBForEle = true; } if (rec.DataValues[16].ToString() == "Y") { DBForWat = true; } String[] tenantColumns = { "ParkID", "SpaceID", "Tenant", "MoveInDate", "GasStatus", "EleStatus", "WatStatus", "GasMedical", "EleMedical", "GasType", "EleType", "DontBillForGas", "DontBillForEle", "DontBillForWat", "Address1", "City", "State", "Zip", "OrderID", //"Concession", "ConcessionType" }; int allowanceForEle = determineMedicalAllowanceForEle(rec); int allowanceForGas = determineMedicalAllowanceForGas(rec); char concessionType; if (rec.DataValues[4].ToString().Length == 1) { concessionType = Convert.ToChar(rec.DataValues[4]); } else { concessionType = ' '; } string spaceName = " "; if (rec.DataValues[1] is DBNull) { spaceName = rec.DataValues[0].ToString(); } else { spaceName = rec.DataValues[1].ToString(); } Object[] tenantValues = { localParkID, //ParkID spaceName, //spaceID rec.DataValues[5], //Tenant Name rec.DataValues[18], //Move-in Date gasStatus, //GasStatus eleStatus, //EleStatus watStatus, //WatStatus allowanceForGas, allowanceForEle, 1, //Gas Type - All Service 1, //Ele Type = All Service DBForGas, //DontBillForGas DBForEle, //DontBillForEle DBForWat, //DontBillForWat rec.DataValues[7], //Address1 rec.DataValues[8], //City rec.DataValues[9], //State rec.DataValues[10], //Zip rec.DataValues[0], //space order ID concessionType }; try { DatabaseControl.executeInsertQuery(DatabaseControl.spaceTable, tenantColumns, tenantValues); return DatabaseControl.getParkSpaceID(localParkID, spaceName); } catch { MessageBox.Show("Park/Tenant Import failed!" + localParkID.ToString() + "/" + rec.DataValues[0].ToString()); return -1; } }
private int updateTenantRecordWithMoveOutDate(int localParkID, int parkSpaceID, ParadoxRecord rec) { String[] tenantColumns = {"MoveOutDate"}; Object[] tenantValues = {rec.DataValues[18]}; //the move out date for old tenant is the move in date for the new tenant try { String cond = "ParkSpaceID = "+ parkSpaceID.ToString(); DatabaseControl.executeUpdateQuery(DatabaseControl.spaceTable, tenantColumns, tenantValues, cond); } catch { //MessageBox.Show("Tenant Import failed!" + localParkID.ToString() + "/" + rec.DataValues[0].ToString()); } return 1; }
private int insertSurcharge(ParadoxRecord rec, int utilityRateID) { //utilSurchargeColumns = { "UtilityRateID", "Description", "RateType", "ChargeType", "Usage", "Rate" }; Object[] values = { utilityRateID, "DWR BC", //Description "All", //Tenant Type, Regular, CARE, Medical, ... 'D', 2, // 1- Flat Rate 2- Usage 3-Daily rec.DataValues[DWRBCColumn] }; /* SCE unique * if (DWRBCColumn > 0) { try { return DatabaseControl.executeInsertQuery(DatabaseControl.utilSurchargeTable, DatabaseControl.utilSurchargeColumns, values); } catch { return -1; } } */ if (FERADiscountColumn > 0) { try { values[0] = utilityRateID; values[1] = "FERA Discount"; values[2] = "All"; values[3] = "D"; values[4] = 2; values[5] = rec.DataValues[FERADiscountColumn]; return DatabaseControl.executeInsertQuery(DatabaseControl.utilSurchargeTable, DatabaseControl.utilSurchargeColumns, values); } catch { return -1; } } try { values[0] = utilityRateID; values[1] = "State Tax"; values[2] = "All"; values[3] = "D"; values[4] = 2; values[5] = rec.DataValues[73]; return DatabaseControl.executeInsertQuery(DatabaseControl.utilSurchargeTable, DatabaseControl.utilSurchargeColumns, values); } catch { return -1; } }
private int updateTenantRecord(int localParkID, int parkSpaceID, ParadoxRecord rec) { //need to convert tenant status string gasStatus = convertStatus(rec.DataValues[11].ToString()); string eleStatus = convertStatus(rec.DataValues[12].ToString()); string watStatus = convertStatus(rec.DataValues[13].ToString()); bool DBForGas = false; bool DBForEle = false; bool DBForWat = false; if (rec.DataValues[14].ToString() == "Y") { DBForGas = true; } if (rec.DataValues[15].ToString() == "Y") { DBForEle = true; } if (rec.DataValues[16].ToString() == "Y") { DBForWat = true; } // Except move-in date, we update all other columns String[] tenantColumns = {"ParkID", "SpaceID", "Tenant", "GasStatus", "EleStatus", "WatStatus", "GasMedical", "EleMedical", "GasType", "EleType", "DontBillForGas", "DontBillForEle", "DontBillForWat", "Address1", "City", "State", "Zip", "OrderID", //"Concession", "ConcessionType" }; int allowanceForEle = determineMedicalAllowanceForEle(rec); int allowanceForGas = determineMedicalAllowanceForGas(rec); string spaceName = " "; if (rec.DataValues[1] is DBNull) { spaceName = rec.DataValues[0].ToString(); } else { spaceName = rec.DataValues[1].ToString(); } Object[] tenantValues = { localParkID, //ParkID spaceName, //spaceID rec.DataValues[5], //Tenant Name gasStatus, //GasStatus eleStatus, //EleStatus watStatus, //WatStatus allowanceForGas, allowanceForEle, 1, //GasType - All Service 1, //EleType - All Service DBForGas, //DontBillForGas DBForEle, //DontBillForEle DBForWat, //DontBillForWat rec.DataValues[7], //Address1 rec.DataValues[8], //City rec.DataValues[9], //State rec.DataValues[10], //Zip rec.DataValues[0], //Tenany order rec.DataValues[4] }; try { String cond = "ParkSpaceID = "+ parkSpaceID.ToString(); DatabaseControl.executeUpdateQuery(DatabaseControl.spaceTable, tenantColumns, tenantValues, cond); } catch { //MessageBox.Show("Tenant Import failed!" + localParkID.ToString() + "/" + rec.DataValues[0].ToString()); } return 1; }
private void insertTierRateforPGE(ParadoxRecord rec, int utilRateID) { Object[] value = { utilRateID, "G", // Generation charge "Regular", // Type of user rec.DataValues[23], // Regulau Tier Rate 1 rec.DataValues[45], // Regulau Tier Rate 2 rec.DataValues[67], // Regulau Tier Rate 3 rec.DataValues[14], // Regulau Tier Rate 4 rec.DataValues[76] // Regulau Tier Rate 5 }; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); value[2] = "FERA"; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); value[2] = "CARE"; value[3] = rec.DataValues[34]; value[4] = rec.DataValues[57]; value[5] = rec.DataValues[69]; value[6] = rec.DataValues[15]; value[7] = rec.DataValues[77]; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); value[2] = "CARE/Medical"; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); value[2] = "Medical"; value[3] = rec.DataValues[33]; value[4] = rec.DataValues[56]; value[5] = rec.DataValues[71]; value[6] = rec.DataValues[16]; value[7] = rec.DataValues[78]; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); }
public override bool IsIndexPossible(ParadoxRecord indexRec, ParadoxRecord nextRec) { return this.Test(c => c.IsIndexPossible(indexRec, nextRec)); }
private void insertTierRateforSCE(ParadoxRecord rec, int utilRateID) { Object[] value = { utilRateID, "D", // Generation charge "Regular", // Type of user rec.DataValues[16], // Regulau Tier Rate 1 rec.DataValues[36], // Regulau Tier Rate 2 rec.DataValues[47], // Regulau Tier Rate 3 rec.DataValues[72], // Regulau Tier Rate 4 rec.DataValues[76] // Regulau Tier Rate 5 }; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); value[2] = "Medical"; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); value[2] = "CARE"; value[3] = rec.DataValues[24]; value[4] = rec.DataValues[46]; value[5] = rec.DataValues[68]; value[6] = rec.DataValues[70]; value[7] = rec.DataValues[77]; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); value[2] = "CARE/Medical"; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); value[1] = "G"; value[2] = "Regular"; value[3] = rec.DataValues[23]; value[4] = rec.DataValues[45]; value[5] = rec.DataValues[67]; value[6] = rec.DataValues[14]; value[7] = rec.DataValues[25]; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); value[2] = "CARE"; value[3] = rec.DataValues[34]; value[4] = rec.DataValues[57]; value[5] = rec.DataValues[69]; value[6] = rec.DataValues[15]; value[7] = rec.DataValues[29]; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); value[2] = "Medical"; value[3] = rec.DataValues[31]; value[4] = rec.DataValues[54]; value[5] = rec.DataValues[43]; value[6] = rec.DataValues[65]; value[7] = rec.DataValues[32]; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); value[2] = "CARE/Medical"; value[3] = rec.DataValues[27]; value[4] = rec.DataValues[50]; value[5] = rec.DataValues[39]; value[6] = rec.DataValues[61]; value[7] = rec.DataValues[28]; DatabaseControl.executeInsertQuery(DatabaseControl.utilTierRatesTable, DatabaseControl.utilTierRatesColumns, value); }
public abstract bool IsIndexPossible(ParadoxRecord indexRec, ParadoxRecord nextRec);
private void insertBaselineAllowance(ParadoxRecord rec, int utilRateID) { DateTime summerStartDate = new DateTime(2015, 05, 01); DateTime winterStartDate = new DateTime(2015, 11, 01); int x = 113; //winter allowance rate column starts here int y = 82; //winter medical baseline allownace column if ((utilStartDate > summerStartDate) & (utilStartDate < winterStartDate)) // { x = 93; //summer allowance rate column starts here y = 81; //winter medical baseline allownace column } for (int i = 0; i < 10; i = i + 1) { Object[] value = { utilRateID, '1', // All Services allowance i, // Zone rec.DataValues[x+i] // Allowance }; DatabaseControl.executeInsertQuery(DatabaseControl.baselineAllowanceTable, DatabaseControl.baselineAllowanceColumns, value); value[1] = '2'; // All Electricity Services allowance value[3] = rec.DataValues[x-10+i]; DatabaseControl.executeInsertQuery(DatabaseControl.baselineAllowanceTable, DatabaseControl.baselineAllowanceColumns, value); } Object[] valueM = { utilRateID, 'M', // Medical Baseline Allowance 'M', // Zone rec.DataValues[y] // Allowance }; DatabaseControl.executeInsertQuery(DatabaseControl.baselineAllowanceTable, DatabaseControl.baselineAllowanceColumns, valueM); }
public override bool IsIndexPossible(ParadoxRecord indexRec, ParadoxRecord nextRec) { var val1 = indexRec.DataValues[this.DataFieldIndex]; var comp1 = Comparer.Default.Compare(val1, this.Value); int comp2; if (nextRec != null) { var val2 = nextRec.DataValues[this.DataFieldIndex]; comp2 = Comparer.Default.Compare(val2, this.Value); } else { comp2 = 1; // last index range ends in infinite } switch (Operator) { case ParadoxCompareOperator.Equal: return comp1 <= 0 && comp2 >= 0; case ParadoxCompareOperator.NotEqual: return comp1 > 0 || comp2 < 0; case ParadoxCompareOperator.Greater: return comp2 > 0; case ParadoxCompareOperator.GreaterOrEqual: return comp2 >= 0; case ParadoxCompareOperator.Less: return comp1 < 0; case ParadoxCompareOperator.LessOrEqual: return comp1 <= 0; default: throw new NotSupportedException(); } }
private int determineMedicalAllowanceForEle(ParadoxRecord rec) { int result = 0; if (eleMedAlloanceColumn == -1) // if there is ele Med Allowance column exist in DB { result = checkStatusColumn(rec.DataValues[12].ToString()); } else { if (rec.DataValues[eleMedAlloanceColumn] != DBNull.Value) { result = (Int16)rec.DataValues[eleMedAlloanceColumn]; } else { result = checkStatusColumn(rec.DataValues[11].ToString()); } } return result; }