Пример #1
0
        private void DisplayMedSchoolDetails()
        {
            string MedicalSchoolCode = txtMedicalSchoolCode.Text;

            //LINQ code to get the name, university and award of the medical school

            using (var dtContext = new JMConsultantsDataContext())

            {
                //Put the results of stored procedure into a variable
                var MedSchoolDetails = dtContext.sproc_GetMedicalSchoolDetails(MedicalSchoolCode);

                //use a foreach loop to index the the details in the variable array
                foreach (var DetailsIndexed in MedSchoolDetails)
                {
                    //get the School name and pass the name to the School name text box
                    txtMedSchoolName.Text = Convert.ToString(DetailsIndexed.JM_Name);

                    //get the University and pass it to the text University textbox
                    txtUniversity.Text = Convert.ToString(DetailsIndexed.JM_University);

                    //get the Award and pass it to the Award textbox
                    txtAward.Text = Convert.ToString(DetailsIndexed.JM_Award);
                }
            }
        }
Пример #2
0
        private void DisplayGPDetails()
        {
            //first try to execute the code.
            try
            {
                //declare an Integer to store the GP Number
                Int32 GPNumberIn = Convert.ToInt32(txtGPNo.Text);

                //LINQ code to get the name, medical school code for the GP
                using (var dtContext = new JMConsultantsDataContext())

                {
                    //Put the results of stored procedure into a variable
                    var GPDetails = dtContext.sproc_tblGP_Get_GPName_and_MedSchool(GPNumberIn);

                    //use a foreach loop to index the the details in the variable array
                    foreach (var DetailsIndexed in GPDetails)
                    {
                        //get the GP name and pass it to the GP name text box
                        txtGPName.Text = Convert.ToString(DetailsIndexed.JM_Name);

                        //get the Medical School number and pass it to the medical school box
                        txtMedicalSchoolCode.Text = Convert.ToString(DetailsIndexed.JM_MedicalSchoolCode);
                    }
                }
            }
            catch
            {
                //in case of error do nothing
            }
        }
Пример #3
0
 private Int32 GetNextPracticeGPNo()
 {
     //find the next available GP no
     using (var dtContext = new JMConsultantsDataContext())
     {
         Int32 maxPracticeGPNo = 0;
         //using stored procedure via LINQ assuming the GP number in database are ordered
         var PracticeGPNumbers = dtContext.sproc_tblPracticeGP_Get_HighesPracticeGPNo();
         foreach (var PracticeGPNumberIndexed in PracticeGPNumbers)                         //Note 1/2 to self: analogous to GPNumberIndexed[Index] = GPNumbers is the result
         {
             maxPracticeGPNo = Convert.ToInt32(PracticeGPNumberIndexed.maxJM_PracticeGPNo); //Note 2/2  to self: analogous to array GPNumberIndexed[Index].JM_GPNo
         }
         return(maxPracticeGPNo + 1);
     }
 }
Пример #4
0
 private Int32 GetNextGPNo()
 {
     //find the next available GP no
     using (var dtContext = new JMConsultantsDataContext())
     {
         Int32 previousGPNo = 0; //assume the numbers start at 1
         Int32 currentGPNo;
         //using stored procedure via LINQ assuming the GP number in database are ordered
         var GPNumbers = dtContext.sproc_tblGP_Get_GP_numbers();
         foreach (var GPNumberIndexed in GPNumbers)                  //Note 1/2 to self: analogous to GPNumberIndexed[Index] = GPNumbers is the result
         {
             currentGPNo = Convert.ToInt32(GPNumberIndexed.JM_GPNo); //Note 2/2  to self: analogous to array GPNumberIndexed[Index].JM_GPNo
             //Find the difference;
             var difference = currentGPNo - previousGPNo;
             //if the difference is greater than one then there is a gap for a GPNo
             if (difference > 1)
             {
                 break;
             }
             previousGPNo = currentGPNo;
         }
         return(previousGPNo + 1);
     }
 }