public static Rollouts GetAllUnrolled(string ORDER_BY) { Rollouts rollouts = new Rollouts(); Rollout rollout; using (MySqlConnection conn = Connections.Inst.item("QED_DB").MySqlConnection){ conn.Open(); using(MySqlCommand cmd = conn.CreateCommand()){ cmd.CommandText = "SELECT * FROM " + _table + " WHERE rolled = 0" + ((ORDER_BY.Trim().Length == 0) ? "" : " ORDER BY " + ORDER_BY); using(MySqlDataReader dr = cmd.ExecuteReader()){ while(dr.Read()){ rollout = new Rollout(dr); rollouts.Add(rollout); } } } } return rollouts; }
private void btnFindRollByRollDate_Click(object sender, System.EventArgs e) { try{ bool cancel = false; Business.Time time = _times.item(_rollout); if (time != null){ PromptTimerStop(time, ref cancel); } if (!cancel){ Client client = (Client)this.cboClients.SelectedItem; Rollouts rolls = new Rollouts(client, this.dtpRoll.Value, SearchBy.RollDate); // Client can have 1 roll scheduled for a day. bool found = false; switch (rolls.Count){ case 0: MessageBox.Show(this, "Can't find rollout", "QED"); break; case 1: _rollout = rolls[0]; UpdateRolloutTab(); found = true; break; default: // Multiple ComboBox cbo = new ComboBox(); cbo.Name = "Select Rollout by Id"; cbo.DisplayMember = "Id"; foreach(Rollout roll in rolls){ cbo.Items.Add(roll); } InputModal im = new InputModal("Multiple entries returned", cbo); if (im.ShowDialog(this) == DialogResult.OK){ Rollout roll = (Rollout)cbo.SelectedItem; if (roll != null){ _rollout = roll; UpdateRolloutTab(); found = true; } } break; } if (found){ time = _times.item(_rollout); if (time == null){ time = new Business.Time(_rollout); PromptTimerStart(time); }else{ HookUpTimer(time); } } } } catch(Exception ex) { MessageBox.Show(this, ex.Message, "Exception"); } }
public static Rollouts Get(DateTime from, DateTime to, bool rolled, string orderBy) { Rollouts rollouts = new Rollouts(); Rollout rollout; using (MySqlConnection conn = Connections.Inst.item("QED_DB").MySqlConnection){ conn.Open(); using(MySqlCommand cmd = conn.CreateCommand()){ cmd.CommandText = "SELECT * FROM " + _table + " WHERE scheduledDate BETWEEN @FROM AND @TO AND rolled = @ROLLED ORDER BY " + orderBy; cmd.Parameters.Add("@FROM", from); cmd.Parameters.Add("@TO", to); cmd.Parameters.Add("@ROLLED", rolled); using(MySqlDataReader dr = cmd.ExecuteReader()){ while(dr.Read()){ rollout = new Rollout(dr); rollouts.Add(rollout); } } } } return rollouts; }
private void btnFindRollByScheduledRollDate_Click(object sender, System.EventArgs e) { try{ bool cancel = false; Business.Time time = _times.item(_rollout); if (time != null){ PromptTimerStop(time, ref cancel); } if (!cancel){ Client client = (Client)this.cboClients.SelectedItem; Rollouts rolls = new Rollouts(client, this.dtpRoll.Value, SearchBy.ScheduledDate); Rollout roll = rolls[0]; if (roll.IsNew) { if (MessageBox.Show(this, "Rollout for " + client.Name + " on " + dtpRoll.Value.ToLongDateString() + " doesn't exist. Create?", "Create", MessageBoxButtons.YesNo) == DialogResult.Yes){ roll.Update(); _rollout = roll; UpdateRolloutTab(); } }else{ _rollout = roll; UpdateRolloutTab(); } if (_rollout != null){ time = _times.item(_rollout); if (time == null){ time = new QED.Business.Time(_rollout); PromptTimerStart(time); }else{ HookUpTimer(time); } } } } catch(Exception ex) { MessageBox.Show(this, ex.Message, "Exception"); } }