public static void UpdateManualColumns(ListView lv, Project p) { var tests = new Session(); var totalhoursname = Reflection.GetFieldName(() => tests.TotalHours); var hourcolname = Reflection.GetFieldName(() => tests.HourlyRate); foreach (ListViewItem lvi in lv.Items) { var hours = Double.Parse(ListViewExtras.GetColumn(lv, lvi, totalhoursname)); var ts = TimeSpan.FromHours(hours); var hourlyrate = Double.Parse(ListViewExtras.GetColumn(lv, lvi, hourcolname)); //manual change columns var cost = (ts.TotalSeconds * (hourlyrate / 3600)); var chg = cost.ToString() + " " + p.CurrencyCode; ListViewExtras.SetColumn(lv, lvi, Form1.chargecolumn, chg); } ListViewExtras.AutoResize(lv); }
private static Session ShowTimesheetDialog(Session s = null) { bool create = s == null; if (s == null) s = new Session(); if (string.IsNullOrEmpty(s.Date)) s.Date = DateTime.Now.ToShortDateString(); var overloads = new List<MassVariableEdit.TextBoxItems>(); var fn = Reflection.GetFieldName(() => s.TotalHours); var fv = s.TotalHours.ToString(); overloads.Add(new MassVariableEdit.TextBoxItems(fn, fv, TextboxExtras.HandleInputAsFloat)); fn = Reflection.GetFieldName(() => s.HourlyRate); fv = s.HourlyRate.ToString(); overloads.Add(new MassVariableEdit.TextBoxItems(fn, fv, TextboxExtras.HandleInputAsFloat)); var res = MassVariableEdit.ShowDialogStatic(create ? "Create Session" : "Edit Session", s, overloads); return res; }
private void posttimebutton_Click(object sender, EventArgs e) { TimeSpan ts = TimeSpan.Zero; double hourlyrate = 0; try { ts = GetTotalSeconds(); hourlyrate = double.Parse(hourcost.Text); } catch (Exception ex) { MessageBox.Show("Error:" + ex); } var s = new Session(datetextbox.Text, hourlyrate, commentstextbox.Text, ts.TotalSeconds / 3600); ListViewExtras.CopyClassToListView(sessions, s); controller.UpdateManualColumns(sessions, p); SaveSessions(); }