private void cbo_SelectedIndexChanged(object sender, EventArgs e) { lblamin.Text = "AM_IN :"; lblamout.Text = "AM_OUT :"; lblpmin.Text = "PM_IN :"; lblpmout.Text = "PM_OUT :"; lblhour.Text = "HOUR :"; if (cbo.Text != "") { Schedule s, s1 = new Schedule(); s1.template_name = cbo.Text; s = s1.SELECT_BY_TEMPLATE_NAME(); hours_allocated = s.hours_allocated; lblamin.Text += s.first_half_in.ToString("HH:mm"); lblamout.Text += s.first_half_out.ToString("HH:mm"); lblpmin.Text += s.second_half_in.ToString("HH:mm"); lblpmout.Text += s.second_half_out.ToString("HH:mm"); lblhour.Text = "HOURS :" + hours_allocated.ToString(); } else { lblamin.Text = "AM_IN :"; lblamout.Text = "AM_OUT :"; lblpmin.Text = "PM_IN :"; lblpmout.Text = "PM_OUT :"; lblhour.Text = "HOUR :"; hours_allocated = TimeSpan.Parse("0:00:00"); } }
public void LoadScheduleOnListView(ListView lv) { Schedule s = new Schedule(); DataTable dt = new DataTable(); dt = s.SELECT_ALL(); if (dt != null) { int ctr = 1; foreach (DataRow r in dt.Rows) { ListViewItem li = new ListViewItem(); li.Text = ctr.ToString(); li.SubItems.Add(r["template_name"].ToString()); li.SubItems.Add(r["first_half_in"].ToString()); li.SubItems.Add(r["first_half_out"].ToString()); li.SubItems.Add(r["second_half_in"].ToString()); li.SubItems.Add(r["second_half_out"].ToString()); li.SubItems.Add(r["hours_allocated"].ToString() + " Hours"); lv.Items.Add(li); ctr++; } } }
public void LoadSchedules(ComboBox cbo) { Schedule s= new Schedule(); DataTable dt = new DataTable(); dt = s.SELECT_ALL(); foreach (DataRow r in dt.Rows) { cbo.Items.Add(r["template_name"].ToString()); } }
private void btnsave_Click(object sender, EventArgs e) { Schedule s = new Schedule(); s.first_half_in = new System.DateTime(1, 1, 1, this.first_half.hour_in, this.first_half.min_in, 0); s.first_half_out = new System.DateTime(1, 1, 1, this.first_half.hour_out, this.first_half.min_out, 0); s.second_half_in = new System.DateTime(1, 1, 1, this.second_half.hour_in, this.second_half.min_in, 0); s.second_half_out = new System.DateTime(1, 1, 1, this.second_half.hour_out, this.second_half.min_out, 0); s.template_name = txttemplate_name.Text; s.hours_allocated = this.first_half.hoursallocated + this.second_half.hoursallocated; //MessageBox.Show(s.am_in.ToLongTimeString()); if (s.save()) { MessageBox.Show("Successful", "Saving...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.Parent.Height = 0; this.Parent.Controls.Clear(); this.Dispose(); } else { MessageBox.Show("There was a problem saving this template :" + db.err.Message); } }
private void emp_sched_new_Load(object sender, EventArgs e) { emp.LoadEmployee(cboEmp); Schedule s = new Schedule(); s.LoadSchedules(this.mon.combobox); s.LoadSchedules(this.tue.combobox); s.LoadSchedules(this.wed.combobox); s.LoadSchedules(this.thu.combobox); s.LoadSchedules(this.fri.combobox); s.LoadSchedules(this.sat.combobox); s.LoadSchedules(this.sun.combobox); s.LoadSchedules(this.sched_adjustment.combobox); }
public Schedule SELECT_BY_TEMPLATE_NAME() { Schedule s = new Schedule(); DataTable dt = new DataTable(); MySqlCommand cmd = new MySqlCommand(); db.SET_COMMAND_PARAMS(cmd, "SCHEDULE_SELECT_BY_TEMPLATE"); cmd.Parameters.AddWithValue("_template_name", template_name); MySqlDataAdapter da = new MySqlDataAdapter(cmd); da.Fill(dt); if (dt != null) { if (dt.Rows.Count > 0) { DataRow r =dt.Rows[0]; s.first_half_in = Convert.ToDateTime(r["first_half_in"].ToString()); s.first_half_out = Convert.ToDateTime(r["first_half_out"].ToString()); s.second_half_in = Convert.ToDateTime(r["second_half_in"].ToString()); s.second_half_out = Convert.ToDateTime(r["second_half_out"].ToString()); DateTime dateTime = DateTime.Parse(r["hours_allocated"].ToString()); TimeSpan timeSpan = TimeSpan.Parse(dateTime.ToString("hh:mm:ss")); s.hours_allocated = timeSpan; return s; } else { return null; } } else { return s; } }
private void sched_ctrl_Load(object sender, EventArgs e) { Schedule s = new Schedule(); s.LoadScheduleOnListView(lv); }