Example #1
0
        private void button3_Click(object sender, EventArgs e)//edit
        {
            jobSchedule Job  = (jobSchedule)dataGridView1.CurrentRow.DataBoundItem;
            EditForm    edit = new EditForm();

            edit.EditJob(Job);

            DialogResult dr = edit.ShowDialog();

            if (dr == DialogResult.OK)
            {
                dataGridView1.Refresh();
            }
            JobMethods.SaveJobList(Jobs, path);
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)//add
        {
            job = new jobSchedule();
            EditForm edit = new EditForm();

            edit.EditJob(job);
            DialogResult dr = edit.ShowDialog();

            if (dr == DialogResult.OK)
            {
                Jobs.Add(job);
                DataGridRefresh();
            }

            JobMethods.SaveJobList(Jobs, path);
        }
Example #3
0
        public static void DeleteSelectedJob(List <jobSchedule> job, DataGridView dataGridView, string path)
        {
            jobSchedule jb = new jobSchedule();

            if (dataGridView.CurrentRow != null)
            {
                job.RemoveAt(dataGridView.CurrentRow.Index);
                dataGridView.DataSource = job.ToList();
                var source = new BindingSource();
                source.DataSource       = job;
                dataGridView.DataSource = source;
                XmlSerializer xs = new XmlSerializer(job.GetType());
                TextWriter    tw = new System.IO.StreamWriter(path);
                xs.Serialize(tw, job);
                tw.Close();
            }
        }
Example #4
0
        public void EditJob(jobSchedule jb)
        {
            job = jb;
            checkBox1.Checked = jb.days[0];
            checkBox2.Checked = jb.days[1];
            checkBox3.Checked = jb.days[2];
            checkBox4.Checked = jb.days[3];
            checkBox5.Checked = jb.days[4];
            checkBox6.Checked = jb.days[5];
            checkBox7.Checked = jb.days[6];
            textBox1.Text     = jb.source;
            textBox2.Text     = jb.destination;
            string start = numericUpDown1.Value.ToString() + ":" + numericUpDown3.Value.ToString();
            string end   = numericUpDown2.Value.ToString() + ":" + numericUpDown4.Value.ToString();

            numericUpDown1.Value = jb.StartHour;
            numericUpDown3.Value = jb.StartMinute;
            numericUpDown2.Value = jb.EndHour;
            numericUpDown4.Value = jb.EndMinute;
        }