public static void SearchDoctorsAvailabeTimeByPatient(TextBox textBox, DataGridView dataGridView)
        {
            DoctorPatientDataContext dp = new DoctorPatientDataContext(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Arwin\documents\visual studio 2015\Projects\CSharpProjects\DoctorPatientPortal\DoctorPatient.mdf;Integrated Security=True;Connect Timeout=30");
            DoctorAvailable          da = null;

            try
            {
                da = dp.DoctorAvailables.FirstOrDefault(dal => dal.DoctorId == int.Parse(textBox.Text)); /*&& dal.CurrentDateTime==DateTime.Now.AddDays(1)*/
            }catch (Exception ex)
            {
                MessageBox.Show(ex.GetType().Name + ", " + ex.Message, "Query Result");
            }

            if (da != null)
            {
                //DateTime dateResult = DateTime.ParseExact(DateTime.Now.AddDays(1).ToShortDateString(), "dd/mmm/yy", CultureInfo.InvariantCulture);

                var x = from a in dp.DoctorAvailables where da.DoctorId == int.Parse(textBox.Text) /*&& da.CurrentDateTime == DateTime.Now.AddDays(1).ToShortDateString()*/ select a;
                dataGridView.DataSource = x.ToList();
                MessageBox.Show("Doctor Available Time Found", "Query Result");
                //MessageBox.Show((DateTime.ParseExact(DateTime.Now.AddDays(1).ToString(),"dd-mm-yy")).ToString());
            }
            if (da == null)
            {
                MessageBox.Show("Doctor Availabe time not found. Try with another id", "Query Result");
                dataGridView.DataSource = null;
                textBox.Clear();
            }
        }
Beispiel #2
0
        public static void DoctorAvailableTimeSetToDB(string emailID, string fromTime, string toTime, int drID)
        {
            DoctorPatientDataContext dp = new DoctorPatientDataContext(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Arwin\documents\visual studio 2015\Projects\CSharpProjects\DoctorPatientPortal\DoctorPatient.mdf;Integrated Security=True;Connect Timeout=30");

            List <string> fromTimeList = new List <string>();

            fromTimeList.Add("8:00 AM");
            fromTimeList.Add("9:00 AM");
            fromTimeList.Add("10:00 AM");
            fromTimeList.Add("11:00 AM");
            fromTimeList.Add("12:00 PM");
            fromTimeList.Add("1:00 PM");
            fromTimeList.Add("2:00 PM");
            fromTimeList.Add("3:00 PM");
            fromTimeList.Add("4:00 PM");
            fromTimeList.Add("5:00 PM");
            fromTimeList.Add("6:00 PM");

            List <string> toTimeList = new List <string>();

            toTimeList.Add("12:00 PM");
            toTimeList.Add("1:00 PM");
            toTimeList.Add("2:00 PM");
            toTimeList.Add("3:00 PM");
            toTimeList.Add("4:00 PM");
            toTimeList.Add("5:00 PM");
            toTimeList.Add("6:00 PM");
            toTimeList.Add("7:00 PM");
            toTimeList.Add("8:00 PM");
            toTimeList.Add("9:00 PM");

            string[] arrayList = new string[11];
            int      i = 0, l = 0;

            foreach (string f in fromTimeList)
            {
                arrayList[i] = f;
                i++;
            }

            for (int j = 0; j < arrayList.Length; j++)
            {
                if (arrayList[j] == fromTime)
                {
                    l = j;
                }
            }
            for (int m = 0; m < l; m++)
            {
                arrayList[m] = "";
            }

            //new area 2

            string[] arrayList2 = new string[10];
            int      i2 = 0, l2 = 0;

            foreach (string f in toTimeList)
            {
                arrayList2[i2] = f;
                i2++;
            }

            for (int kk = 0; kk < arrayList2.Length; kk++)
            {
                if (arrayList2[kk] == arrayList[arrayList.Length - 1])
                {
                    l2 = arrayList2[kk].Length;
                }
            }

            for (int m = 0; m < l2; m++)
            {
                arrayList2[m] = "";
            }

            int s1 = 0;

            for (int s = 0; s < arrayList2.Length; s++)
            {
                if (arrayList2[s] == toTime)
                {
                    s1 = s;
                }
            }

            for (int s3 = arrayList2.Length - 1; s3 > s1; s3--)
            {
                arrayList2[s3] = "";
            }
            string          dt;
            DoctorAvailable ad = null;

            try
            {
                ad = new DoctorAvailable();

                ad.DoctorId        = drID;
                ad.CurrentDateTime = dt = DateTime.Now.AddDays(1).ToShortDateString();
                ad.FromTime1       = arrayList[0];
                ad.FromTime2       = arrayList[1];
                ad.FromTime3       = arrayList[2];
                ad.FromTime4       = arrayList[3];
                ad.FromTime5       = arrayList[4];
                ad.FromTime6       = arrayList[5];
                ad.FromTime7       = arrayList[6];
                ad.FromTime8       = arrayList[7];
                ad.FromTime9       = arrayList[8];
                ad.FromTime10      = arrayList[9];
                ad.FromTime11      = arrayList[10];

                ad.ToTime1  = arrayList2[0];
                ad.ToTime2  = arrayList2[1];
                ad.ToTime3  = arrayList2[2];
                ad.ToTime4  = arrayList2[3];
                ad.ToTime5  = arrayList2[4];
                ad.ToTime6  = arrayList2[5];
                ad.ToTime7  = arrayList2[6];
                ad.ToTime8  = arrayList2[7];
                ad.ToTime9  = arrayList2[8];
                ad.ToTime10 = arrayList2[9];

                dp.DoctorAvailables.InsertOnSubmit(ad);
                dp.SubmitChanges();
                MessageBox.Show("Available time set successfully...", "Query Result");
            }
            catch (Exception ex)
            {
                MessageBox.Show("c1" + ex.GetType().Name + ex.Message, "Query Result");
            }
        }