public static List<Tidbit> GetTidbitsMySql(int typeId, Int32 refId) { List<Tidbit> tidbits = new List<Tidbit>(); MySqlConnection cn = null; MySqlCommand cmd = null; MySqlDataReader rdr = null; DataTable tbl = null; try { cn = createConnectionMySql(); String sql = "select * from tidbits where referencetype = " + typeId + " and referenceid = " + refId + " and tidbitorder < 999 order by tidbitorder"; cmd = new MySqlCommand(sql, cn); rdr = cmd.ExecuteReader(); tbl = new DataTable(); tbl.Load(rdr); rdr.Close(); rdr.Dispose(); foreach (DataRow row in tbl.Rows) { Tidbit tidbit = new Tidbit(); tidbit.ReferenceType = Convert.ToInt16(row["referencetype"]); tidbit.ReferenceID = Convert.ToInt32(row["referenceid"]); tidbit.TidbitOrder = Convert.ToInt16(row["tidbitorder"]); tidbit.TidbitText = row["text"].ToString(); if (row["enabled"] != DBNull.Value) { tidbit.Enabled = Convert.ToBoolean(row["enabled"]); } tidbits.Add(tidbit); } } finally { if (cmd != null) cmd.Dispose(); if (tbl != null) tbl.Dispose(); if (cn != null) cn.Close(); cn.Dispose(); } return tidbits; }
public static List<Tidbit> GetAllPlayerTidbitsSDR() { List<Tidbit> tidbits = new List<Tidbit>(); OracleConnection cn = null; OracleCommand cmd = null; OracleDataReader rdr = null; DataTable tbl = null; try { cn = createConnectionSDR(); if (cn != null) { String sql = "select * from drafttidbits where referencetype = 1 and tidbitorder < 999"; cmd = new OracleCommand(sql, cn); rdr = cmd.ExecuteReader(); tbl = new DataTable(); tbl.Load(rdr); rdr.Close(); rdr.Dispose(); foreach (DataRow row in tbl.Rows) { Tidbit tidbit = new Tidbit(); tidbit.ReferenceType = Convert.ToInt16(row["referencetype"]); tidbit.ReferenceID = Convert.ToInt32(row["referenceid"]); tidbit.TidbitOrder = Convert.ToInt16(row["tidbitorder"]); tidbit.TidbitText = row["text"].ToString(); if (row["enabled"] != DBNull.Value) { tidbit.Enabled = Convert.ToBoolean(row["enabled"]); } else { tidbit.Enabled = false; } tidbits.Add(tidbit); } } else { System.Windows.MessageBox.Show("There was a problem connecting to the SDR database"); } } finally { if (cmd != null) cmd.Dispose(); if (tbl != null) tbl.Dispose(); if (cn != null) cn.Close(); cn.Dispose(); } return tidbits; }
public TidbitViewModel(Tidbit tidbit) { _tidbit = tidbit; }