Example #1
0
 private void ClearAll()
 {
     courseIDTextBox.Clear();
     DaysTextBox.Clear();
     timeTextBox.Clear();
     instructorTextBox.Clear();
     semesterTextBox.Clear();
     listSection.Clear();
 }
        private void PrescriptionSaveButton_Click(object sender, EventArgs e)
        {
            Medicine medicine = null;

            DateTime dateTime = DateTime.Now;
            //string time = dateTime.ToShortTimeString();
            string date = dateTime.ToShortDateString();

            //MessageBox.Show();
            int    morningDose = 0, afternoonDose = 0, nightDose = 0;
            string morningGroupBoxValue = "", afternoonGroupBoxValue = "", nightGroupBoxValue = "", patientID = "", medicineName = "";

            try
            {
                medicineName           = MedicineNameTextBox.Text.ToString();
                morningGroupBoxValue   = MorningDoseGroupBox.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked).Name;
                afternoonGroupBoxValue = AfternoonGroupBox.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked).Name.Split('_')[1];
                nightGroupBoxValue     = NightDoseGroupBox.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked).Name.Split('_')[1];
                patientID = ToPatientTextBox.Text.ToString().Split('(', ')')[1];
                UserInfo.TempPatientIDForDoctor = patientID;
                UserInfo.medicineIDHelper       = patientID + RandNumber + date;
            }

            catch (System.IndexOutOfRangeException)
            {
                MessageBox.Show("Please enter the patient name in respective field and the patient name should be from the dropdown box.", "ValidationError", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception) { }

            //MessageBox.Show(afternoonGroupBoxValue);
            //switch(morningGroupBoxValue)
            //{
            //    case "one":
            //        morningDose = 1;
            //        break;
            //    case "two":
            //        morningDose = 2;
            //        break;
            //    case "three":
            //        morningDose = 3;
            //        break;
            //    case "four":
            //        morningDose = 4;
            //        break;
            //    default:
            //        morningDose = 0;
            //        break;
            //}
            Hashtable hashtable = new Hashtable();

            hashtable.Add("zero", 0);
            hashtable.Add("one", 1);
            hashtable.Add("two", 2);
            hashtable.Add("three", 3);
            hashtable.Add("four", 4);

            foreach (DictionaryEntry item in hashtable)
            {
                if (morningGroupBoxValue == item.Key.ToString())
                {
                    morningDose = (int)item.Value;
                }
                if (afternoonGroupBoxValue == item.Key.ToString())
                {
                    afternoonDose = (int)item.Value;
                }
                if (nightGroupBoxValue == item.Key.ToString())
                {
                    nightDose = (int)item.Value;
                }
            }
            //MessageBox.Show(morningDose.ToString() + " " + afternoonDose.ToString() + " " + nightDose.ToString());

            try
            {
                using (DatabaseContext databaseContext = new DatabaseContext())
                {
                    var medObject = databaseContext.MedNames.Where(m => m.MedicineName == medicineName).FirstOrDefault <MedName>();
                    if (medObject == null)
                    {
                        MedName medName = new MedName()
                        {
                            MedicineName = medicineName,
                            AddedBy      = UserInfo.UserEmail
                        };
                        databaseContext.MedNames.Add(medName);
                    }
                    medicine = new Medicine();
                    medicine.AfterNoonDose    = afternoonDose;
                    medicine.Days             = Convert.ToInt32(DaysTextBox.Text);
                    medicine.UniqueMedicineID = UserInfo.medicineIDHelper;
                    medicine.MorningDose      = morningDose;
                    medicine.NightDose        = nightDose;
                    medicine.MedicineName     = MedicineNameTextBox.Text.ToString();
                    databaseContext.Medicines.Add(medicine);
                    databaseContext.SaveChanges();
                }
                MessageBox.Show("Medicine " + MedicineNameTextBox.Text.ToString() + " stored in current prescription", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MedicineNameTextBox.Clear();
                DaysTextBox.Clear();
                MedicineNameTextBox.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception Occured" + ex.ToString());
            }
        }
Example #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DaysTextBox.Clear();
            WeeksTextBox.Clear();
            MonthsTextBox.Clear();
            DateTime?firstdate = firstdatepick.SelectedDate;

            DDayCalendar.DisplayDate  = firstdate.Value.Date;
            DDayCalendar.SelectedDate = firstdate.Value.Date;
            DDayCalendar.Visibility   = Visibility.Visible;
            Label1.Visibility         = Visibility.Visible;
            Label3.Content            = "";
            Label4.Content            = "";
            Label5.Content            = "";

            int day_index = DaysOverall(firstdate.Value.Date.Day, firstdate.Value.Date.Month, firstdate.Value.Date.Year);

            //     DAYS anniversary counter
            Label3.Content = "It's " + day_index + " days since VID today";
            if (day_index % 100 == 0 | day_index % 1000 == 0)
            {
                DaysTextBox.AppendText(" TODAY is " + day_index + " days since D-Day" + "\n");
            }
            for (int i = 1, q = 0; q < 3; i++)
            {
                day_index = DaysOverall(firstdate.Value.Date.Day, firstdate.Value.Date.Month, firstdate.Value.Date.Year) + i;
                if (day_index % 100 == 0 | day_index % 1000 == 0)
                {
                    DateTime anniversary_days = DateTime.Now.AddDays(i);
                    if (day_index % 1000 == 0)
                    {
                    }
                    DaysTextBox.AppendText(anniversary_days.ToString(" MM.dd.yyyy") + " it will be " + day_index + " days since D-Day" + "\n");
                    q++;
                }
            }

            //     WEEKS annyversary counter
            day_index = DaysOverall(firstdate.Value.Date.Day, firstdate.Value.Date.Month, firstdate.Value.Date.Year);
            int week_index = day_index / 7;

            if (day_index % 7 == 0)
            {
                Label4.Content = "It's " + week_index + " weeks since VID today";
            }
            if (week_index % 10 == 0 | week_index % 100 == 0)
            {
                WeeksTextBox.Foreground = Brushes.Red;
                WeeksTextBox.AppendText(" TODAY is " + week_index + " weeks since D-Day" + "\n");
                WeeksTextBox.Foreground = Brushes.Black;
            }

            for (int i = week_index, q = 0; q < 3; i++)
            {
                if ((week_index % 10 == 0 | week_index % 100 == 0) & (DateTime.Compare(firstdate.Value.Date.AddDays(i * 7), DateTime.Now) > 0))
                {
                    DateTime anniversary_weeks = firstdate.Value.Date.AddDays(i * 7);
                    if (week_index % 100 == 0)
                    {
                    }
                    WeeksTextBox.AppendText(anniversary_weeks.ToString(" MM.dd.yyyy") + " it will be " + week_index + " weeks since D-Day" + "\n");
                    q++;
                }
                week_index++;
            }

            //     MONTHS anniversary counter
            int month_index = MonthsOverall(firstdate.Value.Date);

            if (firstdate.Value.Date.Day == DateTime.Now.Date.Day)
            {
                Label5.Content = "It's " + month_index + " months since VID today";
            }
            for (int i = month_index, q = 0; i < 1000 & q < 3; i++)
            {
                if ((i % 10 == 0 | i % 100 == 0 | i % 1000 == 0) & i > 0)
                {
                    DateTime anniversary_months = firstdate.Value.Date.AddMonths(i);
                    if (i % 10 == 0 | i % 100 == 0)
                    {
                    }
                    MonthsTextBox.AppendText(anniversary_months.ToString(" MM.dd.yyyy") + " it will be " + i + " months since D-Day" + "\n");

                    q++;
                }
            }
        }