private void button1_Click(object sender, EventArgs e)
        {
            App_Data.PisDataSetTableAdapters.PatientsTableAdapter myPatAd = new App_Data.PisDataSetTableAdapters.PatientsTableAdapter();
            App_Data.PisDataSet.PatientsDataTable myPatTable = new App_Data.PisDataSet.PatientsDataTable();

            App_Data.PisDataSetTableAdapters.ImagesTableAdapter myImgAd = new App_Data.PisDataSetTableAdapters.ImagesTableAdapter();
            App_Data.PisDataSet.ImagesDataTable myImgtbl = new App_Data.PisDataSet.ImagesDataTable();

            if (publicClass.IsModification)
            {
                try
                {
                    if (txtImageLocation.Text != "" && cmbImageIndex.SelectedIndex != -1)
                    {
                        myImgAd.UpdateImageLocationQuery(txtImageLocation.Text, Convert.ToInt32(cmbImageID.Items[cmbImageIndex.SelectedIndex]));
                    }
                    myPatAd.UpdatePatientQuery(txtpatientName.Text,
                                        txtAge.Text,
                                        Convert.ToDateTime(Convert.ToDateTime(txtDate.Text).ToShortDateString()),
                                        txtMobileNo.Text,
                                        txtLandLine.Text,
                                        txtDoctorName.Text,
                                        txtAddress.Text,
                                        txtComplaint.Text,
                                        txtFindings.Text,
                                        publicClass.PatientID);
                    MessageBox.Show("Updated Successfully");
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Update Error! " + exc.Message);
                }
            }
            else
            {
                try
                {

                    txtImageLocation.Width = 193;
                    myImgAd.InsertImageQuery(txtImageLocation.Text, publicClass.PatientID);
                    myPatAd.InsertQuery(txtpatientName.Text,
                                        Convert.ToInt32(txtAge.Text).ToString(),
                                        Convert.ToDateTime(Convert.ToDateTime(txtDate.Text).ToShortDateString()),
                                        txtMobileNo.Text,
                                        txtLandLine.Text,
                                        txtDoctorName.Text,
                                        txtAddress.Text,
                                        txtComplaint.Text,
                                        txtFindings.Text);
                    MessageBox.Show("Record Added!");
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Add Error!! " + exc.Message);
                }
            }
        }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count!=1)
     {
         MessageBox.Show("Select a record to delete.");
     }
     else if (MessageBox.Show("Really delete?", "Confirm delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         setPatientID();
         PatientInformationSystem.App_Data.PisDataSetTableAdapters.PatientsTableAdapter patientsDA = new App_Data.PisDataSetTableAdapters.PatientsTableAdapter();
         PatientInformationSystem.App_Data.PisDataSetTableAdapters.HistoryTableAdapter HsitoryDA = new App_Data.PisDataSetTableAdapters.HistoryTableAdapter();
         App_Data.PisDataSetTableAdapters.ImagesTableAdapter ImagesDa = new App_Data.PisDataSetTableAdapters.ImagesTableAdapter();
         patientsDA.DeletePatientQuery(publicClass.PatientID);
         ImagesDa.DeleteImagesQuery(publicClass.PatientID);
         HsitoryDA.DeleteHistoryQuery(publicClass.PatientID);
         MessageBox.Show("Record Deleted Successfully!");
         listView1.Items.Clear();
     }
 }
        private void DetailsForm_Load(object sender, EventArgs e)
        {
            App_Data.PisDataSetTableAdapters.PatientsTableAdapter myPatientDa = new App_Data.PisDataSetTableAdapters.PatientsTableAdapter();
            App_Data.PisDataSet.PatientsDataTable myTbl = new App_Data.PisDataSet.PatientsDataTable();
            try
            {
                myPatientDa.FillPatientByIDBy(myTbl, Classes.publicClass.PatientID);
                lblNname.Text = myTbl.Rows[0]["PatientName"].ToString();
                lblAge.Text = myTbl.Rows[0]["PatientAge"].ToString();
                lblLandLineNo.Text = myTbl.Rows[0]["PatientLandLineNo"].ToString();
                lblMobileNo.Text = myTbl.Rows[0]["PatientMobileNo"].ToString();
                lblPatientAddress.Text = myTbl.Rows[0]["PatientAddress"].ToString();
                lblDoctorName.Text = myTbl.Rows[0]["PatientDoctor"].ToString();
                lblDov.Text = Text = Convert.ToDateTime(myTbl.Rows[0]["PatientDOA"].ToString()).ToShortDateString();

                txtClinicFindings.Text = myTbl.Rows[0]["PatientClinicalFindings"].ToString();
                txtComplaint.Text = myTbl.Rows[0]["PatientComplaint"].ToString();
            }
            catch(Exception exc)
            {
                MessageBox.Show("Error!! " + exc.Message );
            }
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            App_Data.PisDataSetTableAdapters.PatientsTableAdapter myAd = new App_Data.PisDataSetTableAdapters.PatientsTableAdapter();
            App_Data.PisDataSet.PatientsDataTable myTbl = new App_Data.PisDataSet.PatientsDataTable();

            if (radioByName.Checked)
            {
                myAd.FillSearchPatientNameBy(myTbl, txtSearch.Text.Trim());
            }

            else if (radioDoctor.Checked)
            {
                myAd.FillSearchByDoctorBy(myTbl, txtSearch.Text);
            }

            else if (radioMobile.Checked)
            {
                myAd.FillSearchMobileNoBy(myTbl, txtSearch.Text);
            }

            else if (radioLand.Checked)
            {
                myAd.FillSearchLandLineNoBy(myTbl, txtSearch.Text);
            }

            else if (radioAge.Checked)
            {
                myAd.FillSearchPatientsAgeBy(myTbl, txtSearch.Text);
            }

            else if(radioDate.Checked)
            {
                try
                {
                    myAd.FillDateBy(myTbl, Convert.ToDateTime(Convert.ToDateTime(txtSearch.Text).ToShortDateString()));
                }
                catch
                {
                    MessageBox.Show("Please input valid Date of MM/DD/YYYY Format");
                }
            }

            Classes.ListViewClass.WriteListView(myTbl, listView1, comboIDs);
            listView1.Visible = true;
        }