Example #1
0
        private void save_Click(object sender, EventArgs e)
        {
            checkid();
            int xx = checkid() - 1;
            int z  = checkk();

            if (z > xx)
            {
                string cns = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\DoctorAppoinment\DoctorAppoinment\Doctor.mdf;Integrated Security=True";

                SqlConnection cn1 = new SqlConnection(cns);
                cn1.Open();

                // SqlCommand cmd1 = new SqlCommand("INSERT INTO patientserial (id,serialNumber,patientName,_date) VALUES ('" + textBox1.Text + "' , '" + textBox3.Text + "', '" + textBox4.Text + "', '" + dateTimePicker1.Text + "')", cn1);

                SqlCommand cmd1 = new SqlCommand("INSERT INTO ps (_date,id,serialNum,patientName) VALUES ('" + dateTimePicker1.Text + "','" + textBox1.Text + "','" + textBox3.Text + "','" + textBox4.Text + "' )", cn1);


                try
                {
                    cmd1.ExecuteNonQuery();

                    MessageBox.Show("Successfully Saved");
                }
                catch (Exception ex)
                {
                    //Error when save data

                    MessageBox.Show(ex.Message);
                    cn1.Close();
                }

                if (type == "New")
                {
                    patientinfo p = new patientinfo();
                    p.Show();
                }
            }
            else
            {
                MessageBox.Show("Schedule limit reached for today. ");
            }
        }
        private void addToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            patientinfo p = new patientinfo();

            p.Show();
        }