public TrackManagerEdit(Manager database, Track track) { localization = new System.ComponentModel.ComponentResourceManager(typeof(WorkerTimeStrings)); this.database = database; this.track = track; this.Text = localization.GetString("String18") + " " + localization.GetString("String20"); InitializeComponent(); }
public static Track GetTrack(Manager database, Int32 ID) { Track track; DbDataReader reader = database.ExecuteReader("SELECT * FROM Tracks WHERE ID='" + ID + "'"); reader.Read(); if (reader.HasRows) { track = new Track(Int32.Parse(reader["ProjectID"].ToString()), Int32.Parse(reader["ActivityID"].ToString())); track.ID = Int32.Parse(reader["ID"].ToString()); track.startTime = (DateTime)reader["Start"]; track.endTime = (DateTime)reader["End"]; } else { throw new ApplicationException("Contagem não encontrada na base de dados"); } reader.Close(); return track; }
private void TrackManagerEdit_Load(object sender, EventArgs e) { if (track == null) track = new Track(); TrackUtils.PopulateComboBoxProjects(database, comboBoxProject); TrackUtils.SelectComboBoxProjectItem(database, comboBoxProject, track.projectId.ToString()); TrackUtils.PopulateComboBoxActivities(database, comboBoxProject, comboBoxActivity); TrackUtils.SelectComboBoxActivityItem(database, comboBoxActivity, track.activityId.ToString()); dateTimeStart.CustomFormat = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern + " " + Thread.CurrentThread.CurrentUICulture.DateTimeFormat.LongTimePattern; dateTimeEnd.CustomFormat = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern + " " + Thread.CurrentThread.CurrentUICulture.DateTimeFormat.LongTimePattern; // Verify if track.[startTime|endTime] is a valid DateTime if (track.startTime > DateTime.MinValue) dateTimeStart.Value = track.startTime; else track.startTime = DateTime.Now; if (track.endTime > DateTime.MinValue) dateTimeEnd.Value = track.endTime; else track.endTime = DateTime.Now; UpdateDuration(track.ElapsedTime()); }
private void buttonNew_Click(object sender, EventArgs e) { Track track = new Track(); TrackManagerEdit trackManagerEdit = new TrackManagerEdit(database, track); if (trackManagerEdit.ShowDialog() == DialogResult.OK) { track.Save(database); ReadDatabase(); dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true; } }