protected void AddVisitButton_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            String btnId = btn.ID;

            if (btnId.Equals("AddVisitButton"))
            {
                if (IsValid)
                {
                    System.Threading.Thread.Sleep(3000);
                    var hospital = GetId(HospitalTxt.Text, "hospital")[0];
                    var doctor = GetId(DoctorTxt.Text, "doctor")[0];
                    var patient = GetId(PatientTxt.Text, "patient")[0];
                    var icd = GetId(ICDTxt.Text, "icd")[0];
                    //var prescription = GetId(PrescriptionTxt.Text, "prescription")[0];
                    //var labOrder = GetId(LabOrderTxt.Text, "laborder")[0];
                    var date = Convert.ToDateTime(visitedDate.Text);
                    var outcome = OutcomeTxt.Text;

                    //var visit = new Visit() { hospitalId = hospital, doctorId = doctor, patientId = patient, icdId = icd, prescriptionId = prescription, labOrderId = labOrder, dateVisit = date, outcome = outcome };
                    var visit = new Visit() { hospitalId = hospital, doctorId = doctor, patientId = patient, icdId = icd, dateVisit = date, outcome = outcome };
                    _dataContext.Visits.InsertOnSubmit(visit);
                    _dataContext.SubmitChanges();
                    VisitList.DataBind();

                    ResetInputField();
                }
            }
            else if (btnId.Equals("ResetVisitButton"))
            {
                ResetInputField();
            }
        }
        protected void UpdateBtn_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                System.Threading.Thread.Sleep(2000);
                var editedRowIndex = VisitList.EditIndex;
                var idTxt = VisitList.Rows[editedRowIndex].FindControl("EditId") as Label;
                var hospitalTxt = VisitList.Rows[editedRowIndex].FindControl("EditHospital") as TextBox;
                var doctorTxt = VisitList.Rows[editedRowIndex].FindControl("EditDoctor") as TextBox;
                var patientTxt = VisitList.Rows[editedRowIndex].FindControl("EditPatient") as TextBox;
                var icdTxt = VisitList.Rows[editedRowIndex].FindControl("EditIcd") as TextBox;
                //var prescriptionTxt = VisitList.Rows[editedRowIndex].FindControl("EditPrescription") as TextBox;
                //var labOrderTxt = VisitList.Rows[editedRowIndex].FindControl("EditLabOrder") as TextBox;
                var dateTxt = VisitList.Rows[editedRowIndex].FindControl("EditDate") as TextBox;
                var outcomeTxt = VisitList.Rows[editedRowIndex].FindControl("EditOutcome") as TextBox;

                var id = long.Parse(idTxt.Text);
                var hospital = GetId(hospitalTxt.Text, "hospital")[0];
                var doctor = GetId(doctorTxt.Text, "doctor")[0];
                var patient = GetId(patientTxt.Text, "patient")[0];
                var icd = GetId(icdTxt.Text, "icd")[0];
                //var prescription = GetId(prescriptionTxt.Text, "prescription")[0];
                //var labOrder = GetId(labOrderTxt.Text, "laborder")[0];
                var date = Convert.ToDateTime(dateTxt.Text);
                var outcome = outcomeTxt.Text;

                var visit = new Visit() { visitId = id, hospitalId = hospital, doctorId = doctor, patientId = patient, icdId = icd, dateVisit = date, outcome = outcome };
                _dataContext.Visits.Attach(visit);
                _dataContext.Refresh(RefreshMode.KeepCurrentValues, visit);
                _dataContext.SubmitChanges();
                VisitList.EditIndex = -1;
            }
        }
		private void attach_Visits(Visit entity)
		{
			this.SendPropertyChanging();
			entity.Doctor = this;
		}
		private void detach_Visits(Visit entity)
		{
			this.SendPropertyChanging();
			entity.Doctor = null;
		}
 partial void UpdateVisit(Visit instance);
 partial void DeleteVisit(Visit instance);
 partial void InsertVisit(Visit instance);
		private void detach_Visits(Visit entity)
		{
			this.SendPropertyChanging();
			entity.Prescription = null;
		}
		private void detach_Visits(Visit entity)
		{
			this.SendPropertyChanging();
			entity.Hospital = null;
		}
		private void attach_Visits(Visit entity)
		{
			this.SendPropertyChanging();
			entity.Hospital = this;
		}
        //Update Button Control
        protected void UpdateButton_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                System.Threading.Thread.Sleep(3000);
                var idTxt = FormView1.FindControl("EditId") as Label;
                var hospitalTxt = FormView1.FindControl("EditHospital") as TextBox;
                var doctorTxt = FormView1.FindControl("EditDoctor") as TextBox;
                var patientTxt = FormView1.FindControl("EditPatient") as TextBox;
                var icdTxt = FormView1.FindControl("EditIcd") as TextBox;
                //var prescriptionTxt = FormView1.FindControl("EditPrescription") as TextBox;
                //var labOrderTxt = FormView1.FindControl("EditLabOrder") as TextBox;
                var dateTxt = FormView1.FindControl("EditDate") as TextBox;
                var outcomeTxt = FormView1.FindControl("EditOutcome") as TextBox;

                var id = long.Parse(idTxt.Text);
                var hospital = GetId(hospitalTxt.Text, "hospital")[0];
                var doctor = GetId(doctorTxt.Text, "doctor")[0];
                var patient = GetId(patientTxt.Text, "patient")[0];
                var icd = GetId(icdTxt.Text, "icd")[0];
                //var prescription = GetId(prescriptionTxt.Text, "prescription")[0];
                //var labOrder = GetId(labOrderTxt.Text, "laborder")[0];
                var date = Convert.ToDateTime(dateTxt.Text);
                var outcome = outcomeTxt.Text;

                var visit = new Visit() { visitId = id, hospitalId = hospital, doctorId = doctor, patientId = patient, icdId = icd, dateVisit = date, outcome = outcome };
                _dataContext.Visits.Attach(visit);
                _dataContext.Refresh(RefreshMode.KeepCurrentValues, visit);
                _dataContext.SubmitChanges();
                //Use For Debug passed value
                //Debug.WriteLine("id: " + id);
                //Debug.WriteLine("groupId: " + groupId);
                //Debug.WriteLine("Name: " + name);
                //Debug.WriteLine("price: " + price);
            }
        }