示例#1
0
 //Datagridview call click
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (isCanceling == true)
     {
         int          appointmentID = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
         int          patientID     = int.Parse(dataGridView1.CurrentRow.Cells[1].Value.ToString());
         DialogResult result        = MessageBox.Show("Are you sure you want cancel this appointment?", "Cancel Appointment", MessageBoxButtons.OKCancel);
         if (result == DialogResult.OK)
         {
             Appointemts appointemt = new Appointemts();
             appointemt.cancelAppointment(appointmentID, patientID);
             MessageBox.Show("Appointment Canceled", "Cancel Appointment");
             DialogResult results = MessageBox.Show("Appointment Canceled. Would you like to\ncancel another?", "Cancel Appointment", MessageBoxButtons.YesNo);
             if (results == DialogResult.Yes)
             {
                 Appointemts allAppointments = new Appointemts();
                 DataTable   dtAppointments  = allAppointments.getAllAppointments();
                 dataGridView1.DataSource  = dtAppointments; //Fill datagrid with datatable
                 dataGridView1.CurrentCell = null;
             }
             else
             {
                 dataGridView1.DataSource = null; //Empty datagrid view
                 Patients  allPatients   = new Patients();
                 DataTable dtAllPatients = allPatients.getAllPatients();
                 dataGridView1.DataSource  = dtAllPatients;
                 dataGridView1.CurrentCell = null;
                 button2.Enabled           = true;
                 isCanceling = false;
             }
         }
     }
     else
     {
         regBTN.Enabled  = false;
         fnameTB.Text    = dataGridView1.CurrentRow.Cells[1].Value.ToString();
         LnameTB.Text    = dataGridView1.CurrentRow.Cells[2].Value.ToString();
         ageTB.Text      = dataGridView1.CurrentRow.Cells[3].Value.ToString();
         addressTB.Text  = dataGridView1.CurrentRow.Cells[4].Value.ToString();
         townTB.Text     = dataGridView1.CurrentRow.Cells[5].Value.ToString();
         countyTB.Text   = dataGridView1.CurrentRow.Cells[6].Value.ToString();
         postcodeTB.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString();
         telTB.Text      = dataGridView1.CurrentRow.Cells[8].Value.ToString();
         regBTN.Enabled  = false;
     }
     //int i = 1;
     //regBTN.Enabled = false;
     //foreach (var cell in dataGridView1.SelectedRows)
     //{
     //    foreach (Control textbox in patientGB.Controls)
     //    {
     //        if (textbox is TextBox)
     //        {
     //            string currentValue = dataGridView1.CurrentRow.Cells[i].Value.ToString();
     //            textbox.Text = currentValue;
     //            i++;
     //        }
     //    }
     //}
 }
示例#2
0
        //Cancel appointments button
        private void button2_Click(object sender, EventArgs e)
        {
            dataGridView1.DataSource = null;                                    //Empty datagrid view
            Appointemts allAppointments = new Appointemts();
            DataTable   dtAppointments  = allAppointments.getAllAppointments(); //Call get all appointments from appointments class

            dataGridView1.DataSource  = dtAppointments;                         //Fill datagrid with datatable
            dataGridView1.CurrentCell = null;
            button2.Enabled           = false;
            createAppBTN.Enabled      = true;
            isCanceling = true;
        }