Ejemplo n.º 1
0
 public Rollouts(Client client, DateTime date, SearchBy searchBy)
 {
     MySqlCommand cmd;
     Rollout roll;
     string dateField = (searchBy == SearchBy.RollDate) ? "rolledDate" : "scheduledDate";
     date = date.Date; // Store date part, time part not needed.
     using(MySqlConnection conn = (MySqlConnection)this.Conn){
         conn.Open();
         cmd = conn.CreateCommand();
         cmd.CommandText = "SELECT * FROM " + _table + " WHERE clientId = @clientId AND " + dateField + " = @" + dateField;
         cmd.Parameters.Add("@clientId", client.Id);
         cmd.Parameters.Add("@" + dateField, date);
         using(MySqlDataReader dr = cmd.ExecuteReader()){
             if(!dr.HasRows && dateField == "scheduledDate"){
                 roll = new Rollout();
                 roll.Client = client;
                 roll.ScheduledDate = date;
                 roll.BusinessCollection = this;
                 List.Add(roll);
             }else{
                 while (dr.Read()){
                     roll = new Rollout(dr);
                     roll.BusinessCollection = this;
                     List.Add(roll);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public Client Add(Client obj)
 {
     obj.BusinessCollection = this;
     List.Add(obj); return obj;
 }
Ejemplo n.º 3
0
 public bool Contains(Client obj)
 {
     foreach(Client child in List) {
         if (obj.Equals(child)){
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 4
0
 private Clients()
 {
     Client obj;
     using(MySqlConnection conn = Connections.Inst.item("HTS").MySqlConnection){
         using (MySqlDataReader dr = MySqlDBLayer.LoadAll(conn, _table)){
             while(dr.Read()) {
                 obj = new Client(dr);
                 obj.BusinessCollection = this;
                 List.Add(new Client(dr));
             }
         }
     }
 }