コード例 #1
0
        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();
                }
            }
        }
コード例 #2
0
        private void SubmitID()
        {
            GuardianInfoDB parentDB = new GuardianInfoDB();

            if (string.IsNullOrWhiteSpace(this.txt_IDEntry.Text))
            {
                WPFMessageBox.Show("Please enter the parents ID number.");
            }
            else
            {
                string ID = txt_IDEntry.Text;

                if (parentDB.GuardianNotDeletedAndExists(ID))
                {
                    if (editParent)
                    {
                        DisplayAdminEditParentWindow(ID);
                    }
                    else
                    {
                        DisplayAdminEditChildInfo(ID);
                    }
                }
                else
                {
                    WPFMessageBox.Show("User ID or PIN does not exist");
                    txt_IDEntry.Focus();
                }
            }
        }