Exemple #1
0
        private bool EventNameValid(string eventName)
        {
            EventDB eventDB = new EventDB();

            if (eventName.Length < 1)
            {
                WPFMessageBox.Show("You must enter an event name.");
                return(false);
            }
            if (eventName.Length > 50)
            {
                WPFMessageBox.Show("Event names may not be longer than 50 characters.");
                return(false);
            }
            if (!RegExpressions.RegexValidateEventName(eventName))
            {
                WPFMessageBox.Show("Event names may only contain letters and spaces.");
                return(false);
            }
            if ((eventDB.EventNameExists(eventName) && this.oldEventName == null) ||
                (this.oldEventName != null && this.txt_EventName.Text != this.oldEventName && eventDB.EventNameExists(eventName)))
            {
                WPFMessageBox.Show("The event name you have entered already exists.");
                return(false);
            }
            return(true);
        }
        private void btn_Enter_Click(object sender, RoutedEventArgs e)
        {
            ConnectionsDB  conDB = new ConnectionsDB();
            GuardianInfoDB gdb = new GuardianInfoDB();
            string         fID = "", pID = "";
            bool           formNotComplete = CheckIfNull();

            if (!formNotComplete)//form is completed
            {
                bool sameID  = CheckIfSame(txt_GuardianID.Text, txt_GuardianID2.Text);
                bool regexID = RegExpressions.RegexID(txt_GuardianID.Text);
                if (sameID && regexID)//both IDand PIN are the same vlues
                {
                    pID = txt_GuardianID.Text;

                    MakeFamilyID(pID);
                    if (linked == 0)  //link child

                    {
                        int connID = this.db.GetMaxConnectionID();
                        connID = connID + 1;

                        string connectionID = string.Format("{0:000000}", connID);
                        fID = MakeFamilyID(pID);
                        bool guardianExists = false;
                        guardianExists = gdb.GuardianNotDeletedAndExists(pID);
                        if (guardianExists)
                        {
                            conDB.UpdateAllowedConnections(connectionID, pID, childID, fID);
                        }
                        else
                        {
                            WPFMessageBox.Show("Guardian with ID: " + pID + " does not exist.");
                        }
                    }
                    else if (linked == 1)    //delink child
                    {
                        bool connExists     = conDB.ConnectionExists(pID, childID);
                        bool guardianExists = gdb.GuardianNotDeletedAndExists(pID);
                        if (connExists && guardianExists)
                        {
                            conDB.DeleteAllowedConnection(childID, pID);
                        }

                        else
                        {
                            WPFMessageBox.Show("No connection to the Guardian with ID: " + pID + " exists or no Guardian with that ID exists.");
                        }
                    }
                    this.Close();
                }
            }
        }
        private void btn_AddNewParent_Click(object sender, RoutedEventArgs e)
        {
            string pID = "", PIN = "";
            bool   formNotComplete = CheckIfNull();

            if (!formNotComplete)
            {
                bool sameID  = CheckIfSame(txt_ParentID1.Text, txt_ParentID2.Text);
                bool samePIN = CheckIfSame(psw_ParentPIN1.Password, psw_ParentPIN2.Password);

                bool regexID  = RegExpressions.RegexID(txt_ParentID1.Text);
                bool regexPIN = RegExpressions.RegexPIN(psw_ParentPIN1.Password);

                if (sameID && samePIN && regexID && regexPIN)
                {
                    pID = string.Format("{0:000000}", txt_ParentID1.Text);
                    PIN = string.Format("{0:0000}", psw_ParentPIN1.Password);
                    DataSet DS = new DataSet();
                    DS = this.db.GetParentInfoDS(pID);
                    int count = DS.Tables[0].Rows.Count;

                    if (count == 0)
                    {
                        string hashedPIN = ChildcareApplication.AdminTools.Hashing.HashPass(PIN);
                        hashedPIN = "\"" + hashedPIN + "\"";
                        this.db.AddNewParent(pID, hashedPIN, "\"First\"", "\"Last\"", "\"000-000-0000\"", "\"[email protected]\"", "\"123 Road St\"", "\"none\"", "\"City\"", "\"WA\"", "\"12345\"", "'" + "C:\\Users\\Public\\Documents" + "\\Childcare Application\\Pictures\\default.jpg'"); //TAG: pictures access
                        MakeFamilyID(pID);
                        try {
                            AdminEditParentInfo adminEditParentInfo = new AdminEditParentInfo(pID);
                            adminEditParentInfo.Show();
                        }catch (System.IO.DirectoryNotFoundException err)
                        {
                            WPFMessageBox.Show(err.ToString());
                        }
                        this.Close();
                    }
                    else
                    {
                        WPFMessageBox.Show("A Guardian with this ID already Exists. Please re-enter your ID");
                    }
                }
            }
        }
        internal bool RegexValidation()
        {
            formError = true;
            bool fname = false, lname = false, path = false;

            if (formError)
            {
                fname = RegExpressions.RegexName(txt_FirstName.Text);
                if (!fname)
                {
                    txt_FirstName.Focus();
                    formError = false;
                }
            }
            if (formError)
            {
                lname = RegExpressions.RegexName(txt_LastName.Text);
                if (!lname)
                {
                    txt_LastName.Focus();
                    formError = false;
                }
            }

            if (formError)
            {
                path = RegExpressions.RegexFilePath(txt_FilePath.Text);
                if (!path)
                {
                    formError = false;
                }
            }

            if (fname && lname && path)
            {
                return(true);
            }

            return(false);
        }
Exemple #5
0
        internal bool RegexValidation()
        {
            formError = true;
            bool fname = false, lname = false, phone = false, email = false, address = false, city = false, zip = false, path = false;

            if (formError)
            {
                fname = RegExpressions.RegexName(txt_FirstName.Text);
                if (!fname)
                {
                    txt_FirstName.Focus();
                    formError = false;
                }
            }
            if (formError)
            {
                lname = RegExpressions.RegexName(txt_LastName.Text);
                if (!lname)
                {
                    txt_LastName.Focus();
                    formError = false;
                }
            }
            if (formError)
            {
                phone = RegExpressions.RegexPhoneNumber(txt_PhoneNumber.Text);
                if (!phone)
                {
                    txt_PhoneNumber.Focus();
                    formError = false;
                }
            }
            if (formError)
            {
                email = RegExpressions.RegexEmail(txt_Email.Text);
                if (!email)
                {
                    txt_Email.Focus();
                    formError = false;
                }
            }
            if (formError)
            {
                address = RegExpressions.RegexAddress(txt_Address.Text);
                if (!address)
                {
                    txt_Address.Focus();
                    formError = false;
                }
            }
            if (formError)
            {
                city = RegExpressions.RegexCity(txt_City.Text);
                if (!city)
                {
                    txt_City.Focus();
                    formError = false;
                }
            }
            if (formError)
            {
                zip = RegExpressions.RegexZIP(txt_Zip.Text);
                if (!zip)
                {
                    txt_Zip.Focus();
                    formError = false;
                }
            }

            if (formError)
            {
                path = RegExpressions.RegexFilePath(txt_FilePath.Text);
                if (!path)
                {
                    formError = false;
                }
            }

            if (fname && lname && phone && email && address && city && zip && path)
            {
                return(true);
            }

            return(false);
        }