Right now a C#.net 2010 application edits the columns for field1 and field2 separately. Now I need to combine the edits together since the two columns are related to each other alot.
Thus here is the following code, can you tell me how you would combine the edits together for these two columns:
(note: data table is obtained from information loaded into an excel 2003 spreadsheet)
public override List<ColumnNames> GetColumnNames() { List<ColumnNames> list = base.GetColumnNames(); list.Add(ColumnNames.filed1); list.Add(ColumnNames.field2); return list; } public override List<RuleError> ValidateData(DateTime receivedDate) { base.ValidateData(receivedDate); DataTable excelData = ExcelDataTable; string colName = ColumnNames.field2.ToString(); string field2ColName = colMap[colName].ToString(); colName = ColumnNames.filed1.ToString(); string field1ColName = colMap[colName].ToString();
int iEnd = excelData.Rows.Count; for (int i = DataRowNumber - 1; i < iEnd; i++) { //First validate all common fields from ColumnMap DataRow dr = excelData.Rows[i];
{ //Call Base class function to validate common fields List<RuleError> list = Validate(dr, receivedDate, didc); if (list == null) list = new List<RuleError>();
string field1 = dr[field1ColName].ToString(); re = Validatefield1ible(field1); if (re != null) { list.Add(re); }
string colVal = dr[field2ColName].ToString(); re = Validatefield2(colVal); if (re != null) { list.Add(re); } } excelData.AcceptChanges(); didc.Dispose();
return masterList; }
public override List<RuleError> LoadData(ImportWkbk wb, string destDocLoc) {
string colName = ColumnNames.field2.ToString(); string field2ColName = colMap[colName].ToString(); colName = ColumnNames.filed1.ToString(); string field1ColName = colMap[colName].ToString(); Hashtable htSubs = new Hashtable();
Int64 submissionID = 0; VCust firstCust = null; int iEnd = ExcelDataTable.Rows.Count; for (int i = DataRowNumber - 1; i < iEnd; i++) { DataRow dr = ExcelDataTable.Rows[i]; try { string field1 = dr[field1ColName].ToString().Trim().ToUpper(); lis.filed1 = field1.Length > 0 ? field1 : null; string field2 = dr[field2ColName].ToString().Trim().ToUpper(); lis.field2 = field2.Length > 0 ? field2 : null;
didc.SubmitChanges(); didc.Dispose(); return null; }
public RuleError Validatefield1ible(string field1) { RuleError re = null; if (field1 == null || field1.Trim().Length < 1) return null;
if (field1.Trim().ToUpper().Equals (field1ibleStatus.PART) || field1.Trim().ToUpper().Equals (field1ibleStatus.aLL) ) { return null; }
re = new RuleError(RuleErrorCodes.OTHER, RuleErrorTypes.ERROR, "error 1"); return re; }
/// <summary> /// Validates Institutional Status value. /// </summary> /// <param name="field2us"></param> /// <returns></returns> public RuleError Validatefield2(string field2us) { RuleError re = null; if (field2us == null || field2us.Trim().Length < 1) return null;
if(field2us.Trim().ToUpper().Equals(field2.NO) || field2us.Trim().ToUpper().Equals(field2.YES) || field2us.Trim().ToUpper().Equals(field2.maybe) ) { return null; }
re = new RuleError(RuleErrorCodes.OTHER, RuleErrorTypes.ERROR, "error 2."); return re; } }