Ejemplo n.º 1
0
        //click on the doctors button
        private void doctorsButton_Click(object sender, RoutedEventArgs e)
        {
            DoctorsWindow docWindow = new DoctorsWindow();

            //docWindow.Owner = this; //TODO idk if i should remove this
            docWindow.Show();
        }
Ejemplo n.º 2
0
        //DataTable dt = new DataTable();

        //initially loading data fromt he big boy fake database
        public DoctorsWindow()
        {
            DoctorsWindow.newWindowOpened += handleNewWindow;
            MainWindow.mainClosed         += handleMainClose;
            DoctorsWindow.newWindowOpened(this, null);

            InitializeComponent();

            //load data
            List <Doctor> ls = MediSchedData.getDocList();

            if (ls.Count > 0)
            {
                for (int i = 0; i < ls.Count; i++)
                {
                    //docListGrid.Items.Add(new Doctor() {ID = ls[i].ID, Name = ls[i].Name, Days = ls[i].Days, Hours = ls[i].Hours });
                    docListGrid.Items.Add(ls[i]);
                }
            }
        }
Ejemplo n.º 3
0
        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            DoctorsWindow parentDoc = (DoctorsWindow)this.Owner;
            string        cbox1Val  = "";
            string        cbox2Val  = "";

            canAdd = true;

            if (parentDoc != null)
            {
                Doctor rowToBeUpdated = (Doctor)parentDoc.docListGrid.SelectedItem;

                string dash = "-";
                if (startTBlock1.Text.Length == 0 && startTBlock2.Text.Length == 0 && endTBlock1.Text.Length == 0 && endTBlock2.Text.Length == 0)
                {
                    dash = "";
                }

                if (mondayBox.IsChecked == true)
                {
                    isM = true;
                }
                else if (mondayBox.IsChecked == false)
                {
                    isM = false;
                }

                if (tuesdayBox.IsChecked == true)
                {
                    isT = true;
                }
                else if (tuesdayBox.IsChecked == false)
                {
                    isT = false;
                }

                if (wednesdayBox.IsChecked == true)
                {
                    isW = true;
                }
                else if (wednesdayBox.IsChecked == false)
                {
                    isW = false;
                }

                if (thursdayBox.IsChecked == true)
                {
                    isR = true;
                }
                else if (thursdayBox.IsChecked == false)
                {
                    isR = false;
                }

                if (fridayBox.IsChecked == true)
                {
                    isF = true;
                }
                else if (fridayBox.IsChecked == false)
                {
                    isF = false;
                }

                this.workingDays = "";

                if (isM)
                {
                    this.workingDays = "M";
                }

                if (isT)
                {
                    this.workingDays += "T";
                }

                if (isW)
                {
                    this.workingDays += "W";
                }

                if (isR)
                {
                    this.workingDays += "R";
                }

                if (isF)
                {
                    this.workingDays += "F";
                }


                if (string.IsNullOrEmpty(docNameBlock.Text.Trim()))
                {
                    canAdd = false;
                    docNameBlock.BorderBrush = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    docNameBlock.BorderBrush = new SolidColorBrush(Colors.Gray);
                }

                //check if name or time is empty

                /*
                 * if (string.IsNullOrEmpty(startTBlock1.Text.Trim()) || string.IsNullOrEmpty(startTBlock2.Text.Trim()) ||
                 *  !Regex.IsMatch(startTBlock1.Text, @"^[0-9]*$") || !Regex.IsMatch(startTBlock2.Text, @"^[0-9]*$"))
                 */
                if (string.IsNullOrEmpty(startTBlock1.Text.Trim()) || string.IsNullOrEmpty(startTBlock2.Text.Trim()) ||
                    !Regex.IsMatch(startTBlock1.Text, @"^[0-9]*$") || !Regex.IsMatch(startTBlock2.Text, @"^\d{2}$"))
                {
                    canAdd = false;
                    startTBlock1.BorderBrush = new SolidColorBrush(Colors.Red);
                    startTBlock2.BorderBrush = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    startTBlock1.BorderBrush = new SolidColorBrush(Colors.Gray);
                    startTBlock2.BorderBrush = new SolidColorBrush(Colors.Gray);
                }

                if (string.IsNullOrEmpty(endTBlock1.Text.Trim()) || string.IsNullOrEmpty(endTBlock2.Text.Trim()) ||
                    !Regex.IsMatch(endTBlock1.Text, @"^[0-9]*$") || !Regex.IsMatch(endTBlock2.Text, @"^\d{2}$"))
                {
                    canAdd = false;
                    endTBlock1.BorderBrush = new SolidColorBrush(Colors.Red);
                    endTBlock2.BorderBrush = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    endTBlock1.BorderBrush = new SolidColorBrush(Colors.Gray);
                    endTBlock2.BorderBrush = new SolidColorBrush(Colors.Gray);
                }

                //check for valid time
                if (canAdd)
                {
                    if ((this.amPmComboBox1.SelectedIndex == 1 && this.amPmComboBox2.SelectedIndex == 0) || (this.amPmComboBox1.SelectedIndex == this.amPmComboBox2.SelectedIndex) &&
                        (Int32.Parse(startTBlock1.Text) > Int32.Parse(endTBlock1.Text) || (Int32.Parse(startTBlock2.Text) > Int32.Parse(endTBlock2.Text)) &&
                         Int32.Parse(startTBlock1.Text) > 12 || Int32.Parse(endTBlock1.Text) > 12 || Int32.Parse(startTBlock2.Text) > 59 || Int32.Parse(endTBlock2.Text) > 59))
                    {
                        canAdd = false;

                        startTBlock1.BorderBrush = new SolidColorBrush(Colors.Red);
                        startTBlock2.BorderBrush = new SolidColorBrush(Colors.Red);
                        endTBlock1.BorderBrush   = new SolidColorBrush(Colors.Red);
                        endTBlock2.BorderBrush   = new SolidColorBrush(Colors.Red);
                    }
                    else
                    {
                        startTBlock1.BorderBrush = new SolidColorBrush(Colors.Gray);
                        startTBlock2.BorderBrush = new SolidColorBrush(Colors.Gray);
                        endTBlock1.BorderBrush   = new SolidColorBrush(Colors.Gray);
                        endTBlock2.BorderBrush   = new SolidColorBrush(Colors.Gray);
                    }
                }


                if (canAdd)
                {
                    //canAdd = true;

                    //if row is selected and edit button is clicked
                    if (rowToBeUpdated != null && isEdit == true)
                    {
                        cbox1Val = amPmComboBox1.Text;
                        cbox2Val = amPmComboBox2.Text;

                        rowToBeUpdated.Name  = docNameBlock.Text;
                        rowToBeUpdated.Hours = startTBlock1.Text + ':' + startTBlock2.Text + cbox1Val + dash + endTBlock1.Text + ':' + endTBlock2.Text + cbox2Val;
                        rowToBeUpdated.Days  = this.workingDays;

                        //MediSchedData.updateDocInfo(rowToBeUpdated.ID, rowToBeUpdated.Name, rowToBeUpdated.Hours, rowToBeUpdated.Days);
                        MediSchedData.updateDoc(rowToBeUpdated);
                        parentDoc.docListGrid.Items.Refresh();
                    }
                    else if (isEdit == false)   //otherwise they clicked the add new doctor button
                    {
                        cbox1Val = amPmComboBox1.Text;
                        cbox2Val = amPmComboBox2.Text;

                        List <Doctor> docLs  = MediSchedData.getDocList();
                        int           lastID = 0;

                        if (docLs.Count != 0)
                        {
                            lastID = docLs[docLs.Count - 1].ID;
                        }

                        Doctor newDoc = new Doctor(docNameBlock.Text, this.workingDays, (startTBlock1.Text + ':' + startTBlock2.Text + cbox1Val + dash + endTBlock1.Text + ':' + endTBlock2.Text + cbox2Val));
                        parentDoc.docListGrid.Items.Add(newDoc);
                        MediSchedData.addDocToList(newDoc);
                    }
                }
            }
            if (canAdd)
            {
                this.Close();
            }
        }