private void Images_Load(object sender, EventArgs e)
        {
            try
            {
                App_Data.PisDataSet.ImagesDataTable myTbl = new App_Data.PisDataSet.ImagesDataTable();
                App_Data.PisDataSetTableAdapters.ImagesTableAdapter myAd = new App_Data.PisDataSetTableAdapters.ImagesTableAdapter();

                myAd.FillImagesbyPatientBy(myTbl, Classes.publicClass.PatientID);
                // MessageBox.Show(myTbl.Rows.Count.ToString());
                string[] MyStrImageLocation = new string[myTbl.Rows.Count];
                string[] MyStrImageID = new string[myTbl.Rows.Count];

                foreach (DataRow dr in myTbl.Rows)
                {
                    MyStrImageID[index] = dr["ImageID"].ToString();
                    MyStrImageLocation[index] = dr["ImageLocation"].ToString();
                    index++;
                    //MessageBox.Show(dr["ImageID"].ToString());
                    //MessageBox.Show(dr["ImageLocation"].ToString());
                }
                myStrImageID = MyStrImageID;
                myStrImageLocation = MyStrImageLocation;
                index = 0;
                pictureBox1.ImageLocation = myStrImageLocation[index];
                btnPrevious.Enabled = false;
                if (myStrImageID.Length == 1)
                    btnNext.Enabled = false;
            }
            catch (Exception Exc)
            {
                MessageBox.Show(Exc.Message + "\nPossibly No Images to Load ADD Images Please");
                this.Close();
            }
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (cmbImageIndex.SelectedIndex != -1)
            {

                App_Data.PisDataSetTableAdapters.ImagesTableAdapter myAd = new App_Data.PisDataSetTableAdapters.ImagesTableAdapter();
                myAd.DeleteImageByImageIDQuery(Convert.ToInt32(cmbImageID.Items[cmbImageIndex.SelectedIndex]));

                App_Data.PisDataSet.ImagesDataTable myTbl = new App_Data.PisDataSet.ImagesDataTable();
                myAd.FillImagesbyPatientBy(myTbl, Classes.publicClass.PatientID);

                cmbImageID.Items.Clear();
                cmbImageIndex.Items.Clear();
                for (int index = 0; index < myTbl.Rows.Count; index++)
                {
                    cmbImageIndex.Items.Add((index + 1).ToString());
                    cmbImageID.Items.Add(myTbl.Rows[index]["ImageID"].ToString());
                }
                txtImageLocation.Text = "";
                cmbImageIndex.SelectedIndex = -1;
                cmbImageIndex.Text = "";
                MessageBox.Show("Image Deleted");

            }

            else
            {
                MessageBox.Show("Select An Image Index to delete it");
            }
        }
        void FillFormData()
        {
            App_Data.PisDataSet.ImagesDataTable myImageTbl = new App_Data.PisDataSet.ImagesDataTable();
            App_Data.PisDataSetTableAdapters.ImagesTableAdapter myAd = new App_Data.PisDataSetTableAdapters.ImagesTableAdapter();
            myAd.FillImagesbyPatientBy(myImageTbl, Classes.publicClass.PatientID);

            txtAge.Text = Classes.publicClass.age.ToString();
            txtLandLine.Text = Classes.publicClass.LandLineNo;
            txtMobileNo.Text = Classes.publicClass.MobileNo;

            txtpatientName.Text = Classes.publicClass.PatientName;
            txtAddress.Text = Classes.publicClass.Address;
            txtDoctorName.Text = Classes.publicClass.DoctorName;
            txtAge.Text = Classes.publicClass.age.ToString();
            txtFindings.Text = Classes.publicClass.ClinicalFinding;
            txtComplaint.Text = Classes.publicClass.Complaint;

            txtDate.Text = Convert.ToDateTime(Classes.publicClass.DOV).ToShortDateString();

            for (int index = 0; index < myImageTbl.Rows.Count; index++)
            {

                cmbImageIndex.Items.Add((index + 1).ToString());
                cmbImageID.Items.Add(myImageTbl.Rows[index]["ImageID"].ToString());
            }
        }
        private void button1_Click_2(object sender, EventArgs e)
        {
            try
            {
                if (txtImageLocation.Text == "")
                {
                    MessageBox.Show("Image Location Can't Be Null");
                    return;
                }
                else if (txtImageLocation.Text != "")
                {
                    App_Data.PisDataSetTableAdapters.ImagesTableAdapter myAd = new App_Data.PisDataSetTableAdapters.ImagesTableAdapter();
                    App_Data.PisDataSet.ImagesDataTable myTbl = new App_Data.PisDataSet.ImagesDataTable();

                    myAd.InsertImageQuery(txtImageLocation.Text, publicClass.PatientID);
                    myAd.FillImagesbyPatientBy(myTbl, Classes.publicClass.PatientID);
                    cmbImageID.Items.Clear();
                    cmbImageIndex.Items.Clear();
                    for (int index = 0; index < myTbl.Rows.Count; index++)
                    {
                        cmbImageIndex.Items.Add((index + 1).ToString());
                        cmbImageID.Items.Add(myTbl.Rows[index]["ImageID"].ToString());
                    }

                  txtImageLocation.Text = "";
                  cmbImageIndex.SelectedIndex = -1;
                  cmbImageIndex.Text = "";
                    MessageBox.Show("New Image Loaded!");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }