Example #1
0
        private void Form3_FormClosing(object sender, FormClosingEventArgs e)
        {
            Delivery_Option f = new Delivery_Option(dt, dt4);

            f.Show();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            f1 = c.Date1(dateTimePicker1);                          //Validation
            f2 = c.Date2(dateTimePicker1, dateTimePicker2);         //Validation

            if (f1 == 0 && f2 == 0)
            {
                ActiveForm.Hide();
                Delivery_Option f = new Delivery_Option(dateTimePicker1, dateTimePicker2);
                f.Show();
            }

            if (f2 == 1)
            {
                dateTimePicker2.Focus();
                label5.Text = "*Should Be less \n than present";
                label5.Show();
                using (StreamWriter w = File.AppendText("log.txt"))
                {
                    c.Log(label4.Text, w);
                }

                using (StreamReader r = File.OpenText("log.txt"))
                {
                    c.DumpLog(r);
                }
            }
            else if (f2 == 2)
            {
                dateTimePicker2.Focus();
                label5.Text = "Should be \n greater than\n from booking\n   date";
                label5.Show();
                using (StreamWriter w = File.AppendText("log.txt"))
                {
                    c.Log(label4.Text, w);
                }

                using (StreamReader r = File.OpenText("log.txt"))
                {
                    c.DumpLog(r);
                }
            }
            else
            {
                label5.Hide();
            }

            if (f1 == 1)
            {
                dateTimePicker1.Focus();
                label4.Text = "*Invalid Date";
                label4.Show();
                using (StreamWriter w = File.AppendText("log.txt"))
                {
                    c.Log(label4.Text, w);
                }

                using (StreamReader r = File.OpenText("log.txt"))
                {
                    c.DumpLog(r);
                }
            }
            else
            {
                label4.Hide();
            }
        }