public Defect Add(Defect def) { def.BusinessCollection = this; def.Parent = this._parent; List.Add(def); return def; }
public bool Contains(Defect def) { foreach(Defect obj in List) { if (obj.Equals(def)){ return true; } } return false; }
public Defects(BusinessBase parent) { Defect def; string SQL; _parent = parent; using(MySqlConnection conn = Connections.Inst.item("QED_DB").MySqlConnection){ conn.Open(); using(MySqlCommand cmd = conn.CreateCommand()){ if (parent is Effort){ SQL = "SELECT * FROM " + _table + " WHERE effId = @effId and forRoll = 0"; cmd.Parameters.Add("@effId", parent.Id); }else{ SQL = "SELECT * FROM " + _table + " WHERE rollId = @rollId and forRoll = 1"; cmd.Parameters.Add("@rollId", parent.Id); } cmd.CommandText = SQL; using(MySqlDataReader dr = cmd.ExecuteReader()){ while(dr.Read()) { def = new Defect(dr); def.BusinessCollection = this; List.Add(def); } conn.Close(); } } } }