Exemple #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        eventID           = Request.QueryString["ID"];
        litOrg1.Text      = ConfigurationManager.AppSettings["Org"];
        litOrg2.Text      = ConfigurationManager.AppSettings["Org"];
        offset            = ConfigurationManager.AppSettings["SignupOffset"];
        IsAccessControlOn = false;
        if ((ConfigurationManager.AppSettings["AccessControl"] != null) &&
            (ConfigurationManager.AppSettings["AccessControl"].ToLower().Trim() == "on"))
        {
            IsAccessControlOn = true;
        }
        if (!IsAccessControlOn)
        {
            lblAccessCode.Visible = false;
            tbAccessCode.Visible  = false;
        }
        signupOffset = 0;
        if (offset != null)
        {
            if (offset.Trim() != "")
            {
                signupOffset = Convert.ToInt32(offset);
            }
        }


        MrTimeZone tz = new MrTimeZone();

        deadline      = tz.eastTimeNow();
        postDate      = tz.eastTimeNow();
        playerLimit   = 1;
        hostClubPhone = "";
//            linkbuttonSR.Visible = false;


        enableSignups = false;
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        MRParams  param         = db.MRParams.FirstOrDefault(p => p.Key == keySignups);

        if (IsSignupAllowed(param))
        {
            enableSignups = true;
        }
        if (!IsPostBack)
        {
            NormalPanel.Visible      = true;
            SignupPanel.Visible      = true;
            ClosedPanel.Visible      = false;
            GuestListPanel.Visible   = false;
            SpecialRulePanel.Visible = false;
            GuestOption = false;
//				cbSpecialRule.Checked = false;
            SRCBLPanel.Visible = false;
            SRCBKL.Visible     = false;
            SRCBKL.Items.Clear();
            cbGuestRule.Checked = false;
            tbGFN.Text          = "";
            tbGLN.Text          = "";
            tbGHcp.Text         = "";
            GetCookieUserInfo();
        }
        var mixer = db.Events.FirstOrDefault(ev => ev.EventID == eventID);

        if (mixer != null)
        {
            if (mixer.Type.Trim() == "Home")
            {
                Page.Title = string.Format("{0} {1} Sign-up", mixer.Date.ToString("MMM d"), ConfigurationManager.AppSettings["Org"]);
            }
            else
            {
                Page.Title = string.Format("{0} {1} Sign-up", mixer.Date.ToString("MMM d"), mixer.Title);
            }
            deadline      = mixer.Deadline;
            playerLimit   = mixer.PlayerLimit;
            hostClubPhone = GetHostPhone(mixer.HostID);
            postDate      = mixer.PostDate;
            if (playerLimit == maxLimit)
            {
                lblPlayerLimit.Text = "(Player Limit: Unlimited)";
            }
            else
            {
                lblPlayerLimit.Text = "(Player Limit: " + playerLimit.ToString("##0") + "*)";
            }
            if (mixer.SpecialRule != null)
            {
                sRule        = mixer.SpecialRule.Trim();
                sRuleChoices = sRule.Split(delimiterChars);
            }
            if ((mixer.Guest != null) && (mixer.Guest.Trim()) == Guest)
            {
                GuestOption = true;;
            }
        }
        postDate      = tz.eastTimeNow().AddDays(-signupOffset); // temporary for testing
        enableSignups = (tz.eastTimeNow() >= postDate) && enableSignups;

        //
        // load mixer details  from text file
        //
        path = Server.MapPath("");
        MrLoadMixerInfo mixerInfo = new MrLoadMixerInfo(path, eventID);

        LoadMixerInfo(mixerInfo.MixerLines());
        btnSubmit.Enabled = mixerInfo.PageFileExists;
        lblEventID.Text   = eventID;
        //
        // Get the mixer from the events db
        //

        MRParams entry = db.MRParams.FirstOrDefault(p => p.Key == keySignupLimit);

        if (entry != null)
        {
            maxLimit = Convert.ToInt32((string)entry.Value);
        }

        getPlayersList(eventID);
        //
        // Check for deadline already passed
        //
        if (MrSignup.IsClosed(deadline))
        {
            // Deadline is in the past			}
            lblClosed.Text = @"<span class=""closed"">Contact ";
            //                lblSignupForm.Text += "the<br />Host Club at<br />";
            //				  lblSignupForm.Text += hostClubPhone;
//                lblClosed.Text += "your <br />MISGA Rep, <br >";
            lblClosed.Text += ConfigurationManager.AppSettings["Contact"] + " at<br />";
            string cp = ConfigurationManager.AppSettings["ContactPhone"];
            if (cp == "")
            {
                cp = hostClubPhone;
            }

            lblClosed.Text += cp;

            lblClosed.Text += "<br />to see if you can be added to the list.</span>";

/*                rblAction.Items[0].Selected = false;
 *              rblAction.Items[1].Selected = true;
 *              rblAction.Items[0].Enabled = false;
 *              rblAction.Items[1].Enabled = true;
 * */
            SignupPanel.Visible        = false;
            ClosedPanel.Visible        = true;
            ClosedMessagePanel.Visible = true;
            tblGenderPool.Visible      = false;
            rblAction.Visible          = false;
            cbCarpool.Visible          = false;
            lblgender.Visible          = false;
            rblgender.Visible          = false;
            PlayerPanel.Visible        = false;
//                lblFN.Visible = false;
//                lblLN.Visible = false;
//                FirstNameTextBox.Visible = false;
//                LastNameTextBox.Visible = false;
//                cbCarpool.Visible = false;
//                LinkButton1.Visible = false;
            SpecialRulePanel.Visible = false;
            SRCBLPanel.Visible       = false;
            SRCBKL.Visible           = false;
            SRCBKL.Items.Clear();
            linkbuttonSR.Visible = false;
            cbGuestRule.Visible  = false;
//                cbSpecialRule.Visible = false;
            GuestPanel.Visible = false;
            if (GuestOption)
            {
                GuestListPanel.Visible = true;
                NormalPanel.Visible    = false;
            }
            enableSignups = false;
        }
        else
        {
            // enable signup page to accomodate special rule
            if (!IsPostBack)
            {
                if ((sRuleChoices.Length > 0) && (sRuleChoices[0] != ""))
                {
                    SRCBKL.Items.Add("Default");
                    foreach (string choice in sRuleChoices)
                    {
                        if (choice != "")
                        {
                            SRCBKL.Items.Add(choice);
                        }
                    }
                    srCount = 0;
                    if (SRCBKL.Items.Count > 0)
                    {
                        SpecialRulePanel.Visible = true;
                        linkbuttonSR.Visible     = true;
                        SRCBKL.Visible           = true;
                        SRCBLPanel.Visible       = true;
                        prevSRSelection          = -1;
                        prevSRItem = "";
                    }
                }
            }

/*                if (sRule != "")
 *                              {
 *                                  cbSpecialRule.Text = sRule;
 *                                  SpecialRulePanel.Visible = true;
 *                                  cbSpecialRule.Visible = true;
 *                                  linkbuttonSR.Visible = true;
 *
 *                              }   */
            if (GuestOption)
            {
                SpecialRulePanel.Visible = true;
                cbGuestRule.Text         = "Partner";
                cbGuestRule.Visible      = true;

                GuestPanel.Visible = true;

                GuestListPanel.Visible = true;
                NormalPanel.Visible    = false;
            }
        }
        btnSubmit.Enabled   = (mixerInfo.PageFileExists && enableSignups);
        SubmitPanel.Visible = (mixerInfo.PageFileExists && enableSignups);
//            btnSubmit.Enabled = (mixerInfo.PageFileExists);
    }
    public static string AddToList(string EventID, int pID, string Action, string Carpool, int Sex, string sr, int guestID)
    {
        ///<Remarks>
        ///
        /// Action settings
        ///    Signup
        ///    Cancel
        ///
        /// Carpool Settings
        ///    No  to Carpool
        ///    Yes to Carpool
        ///
        ////*  Add Player to Players List for the mixer or event specified in'EventID'
        /// *  First task is to find player in the table of 'Players' and if the player cannot be found,
        /// *  to give the player the next PlayerID available then add the player to the 'Players' Table.
        /// *  After completing that then create a players list entry for this player and event.  Then add that entry to the 'PlayersList'
        /// *  Table.
        /// *
        /// * Then return control to caller with a success indicator as the result.
        /// * Result of integer Zero indicates successful completion
        /// *           integer One  indicates an unsuccessful completion
        /// *
        /// * */
        ///

        string result = "";
        //
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        //
        //
        MrTimeZone tz   = new MrTimeZone();
        Events     evnt = db.Events.FirstOrDefault(e => e.EventID == EventID);

        if (evnt != null)
        {
            Players player = db.Players.FirstOrDefault(x => x.PlayerID == pID);
            if (player != null)
            {
                PlayersList entry = db.PlayersList.FirstOrDefault(p => p.EventID == EventID && p.PlayerID == pID && p.Marked == 0);
                if (entry != null)
                {
                    if (Action == txtCancel)
                    {
                        entry.Marked = 1;       // set marked for Delete
                        if (evnt.Date < tz.eastTimeNow().AddHours(24))
                        {
                            result = "Cannot cancel online within 24 hours of Event.<br />Call the Golf Shop.";
                        }
                        else
                        {
                            if (tz.eastTimeNow() > evnt.Deadline)
                            {
                                result = "Cancel recorded.<br />Please notify the Host Golf Shop that you cancelled.";
                            }
                            else
                            {
                                result = "Cancel successful.";
                            }
                        }
                    }
                    else
                    {                           // modify existing entry in players database
                        entry.Carpool     = Carpool;
                        entry.SpecialRule = sr;
                        entry.GuestID     = guestID;
                        result            = "Modification of entry was sucessful.";
                    }
                }
                else
                {                               // no entry for this player and event
                    PlayersList ple = new PlayersList()
                    {                           // create new entry in players list database
                        EventID     = EventID,
                        TransDate   = tz.eastTimeNow(),
                        Marked      = 0,                // set entrymark to zero
                        PlayerID    = pID,
                        Action      = Action,
                        Carpool     = Carpool,
                        SpecialRule = sr,
                        GuestID     = guestID
                    };
                    if (Action != txtCancel)
                    {                                       // cannot do a cancel on new entry
                        db.PlayersList.InsertOnSubmit(ple);
                        result = "Sign-up was successful.";
                    }
                    else
                    {
                        ple.Marked = 1;        // set to not display canceled entries
                        result     = string.Format("Cancel unsuccessful because {0} {1} not Signed Up.", player.FName, player.LName);
                    }
                }
                db.SubmitChanges();
            }
            else
            {
                result = "Player not in database.";
            }
        }
        else
        {
            result = "Event not in database.";
        }
        return(result);
    }
    public static bool IsClosed(DateTime deadline)
    {
        MrTimeZone etz = new MrTimeZone();

        return(etz.eastTimeNow() >= deadline);
    }
Exemple #4
0
    //   protected void btnLogon_Click(object sender, EventArgs e)
//    {

//    }

    private bool ValidateUser(string UserName, string PassWord)
    {
        string userName;
        string passWord;

        userName = UserName;
        passWord = PassWord;
        if (testEnvironment)
        {
            if ((UserName == "") && (PassWord == ""))
            {
                userName = "******";
                passWord = "******";
            }
        }
        string lookupPassword = null;

        string    sdbc = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db   = new MRMISGADB(sdbc);

        // Check for invalid userName.
        // userName must not be null and must be between 1 and 15 characters.
        if ((null == userName) || (0 == userName.Length) || (userName.Length > 15))
        {
            System.Diagnostics.Trace.WriteLine("[ValidateUser] Input validation of userName failed.");
            return(false);
        }

        // Check for invalid passWord.
        // passWord must not be null and must be between 1 and 25 characters.
        if ((null == passWord) || (0 == passWord.Length) || (passWord.Length > 25))
        {
            System.Diagnostics.Trace.WriteLine("[ValidateUser] Input validation of passWord failed.");
            return(false);
        }

        try
        {
            var cs = db.Users.FirstOrDefault(c => c.UserID.ToLower() == userName.ToLower());
            if (cs != null)
            {
                lookupPassword = cs.Password;
                usr.UserID     = cs.UserID;
                usr.Name       = cs.Name;
                usr.ClubID     = cs.ClubID;
                usr.Email      = cs.Email;
                usr.Phone      = cs.Phone;
                usr.role       = cs.role;
                usr.LoginCount = cs.LoginCount;
            }
        }
        catch (Exception ex)
        {
            // Add error handling here for debugging.
            // This error message should not be sent back to the caller.
            string stop = "yes";
            System.Diagnostics.Trace.WriteLine("[ValidateUser] Exception " + ex.Message);
        }

        // If no password found, return false.
        if (null == lookupPassword)
        {
            // You could write failed Logon attempts here to event log for additional security.
            return(false);
        }

        // Compare lookupPassword and input passWord, using a case-sensitive comparison.
        if (0 == string.Compare(lookupPassword, passWord, false))
        {
            MrTimeZone tz = new MrTimeZone();

            var cs = db.Users.FirstOrDefault(c => c.UserID == userName);
            cs.LoginCount++;
            cs.LastLogin = tz.eastTimeNow();
            db.SubmitChanges();
            return(true);
        }
        return(false);
    }