1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
publicclassItemMaster
{
privatestaticreadonlyItemMaster instance = newItemMaster();
privateDataSet _mixed = newDataSet();
publicDataTable _oracle = newDataTable("PART_ORACLE");
publicDataTable _db2 = newDataTable("PART_DB2");
publicDataTable _mixedtable = newDataTable("SELECTION");
static ItemMaster() { }
ItemMaster()
{
CreateOracle();
CreateDB2();
CreateSelection();
BuildDataset();
PopulateDataSet();
}
publicstaticItemMaster Instance
{
get { return instance; }
}
privatevoid CreateOracle()
{
_oracle.Columns.Add(
"CTIDNO", typeof(string));
_oracle.Columns.Add("RCPT_ZONE", typeof(string));
_oracle.PrimaryKey = newDataColumn[] { _oracle.Columns["CTIDNO"] };
}
privatevoid CreateDB2()
{
_db2.Columns.Add("CTIDNO", typeof(string));
_db2.Columns.Add("RCDLOC", typeof(string));
_db2.PrimaryKey = newDataColumn[] { _db2.Columns["CTIDNO"] };
}
privatevoid CreateSelection()
{_mixedtable.Columns.Add("CTIDNO", typeof(string));
_mixedtable.Columns.Add("RCDLOC", typeof(string));
_mixedtable.Columns.Add("RCPT_ZONE", typeof(string));
_mixedtable.PrimaryKey = newDataColumn[] { _mixedtable.Columns["CTIDNO"] };
}
privatevoid BuildDataset()
{_mixed.Tables.AddRange(
newDataTable[] { _oracle, _db2, _mixedtable });
_mixed.Relations.Add(_mixed.Tables["PART_ORACLE"].Columns["CTIDNO"], _mixed.Tables["PART_DB2"].Columns["CTIDNO"]);
}
publicDataSet GetFullDataSet
{
get { return _mixed; }
}
publicDataSet GetDataSetWithMixedBy(int _rowid)
{GetChildRowsFromDataRelation(_rowid);
return _mixed;
}
privateDataTable GetChildRowsFromDataRelation(int index)
{
try
{
_mixedtable.Rows.Clear();
DataRow[] childRows = _oracle.Rows[index].GetChildRows(_oracle.ChildRelations[0]);
foreach (DataRow dr in childRows)
{_mixedtable.Rows.Add(
newobject[] { dr[0], dr[1], _oracle.Rows[index][1] });
}
return _mixedtable;
}
catch (Exception ex)
{
returnnull;
}}
publicvoid PopulateDataSet()
{_mixed.Tables["PART_ORACLE"].Rows.Add(
newobject[] { "1W2456", "Champ_Rcpt_Zone" });
_mixed.Tables["PART_DB2"].Rows.Add(
newobject[] { "1W2456", "Champ_RecLoc" });
}
}
} |
Partager