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); }
protected void btnSubmit_Click(object sender, EventArgs e) { ln = LastNameTextBox.Text.Trim(); fn = FirstNameTextBox.Text.Trim(); string action = rblAction.SelectedValue; // Action = Signup or Cancel carpool = cbCarpool.Checked?"Yes":"No"; // Carpool = No or Yes tgender = rblgender.SelectedValue; if (carpool.Trim() == "No") { carpool = ""; } /* if (invalidMember(ln, fn)) * { * errorCode = 5; * } */ if (IsAccessControlOn) { if (!AccessControl.IsValidMember(ln, fn, tbAccessCode.Text)) { errorCode = 6; } } SaveUserInfo(fn, ln, tgender, carpool); int gender = rblgender.SelectedIndex + 1; lblAction.Text = ""; lblAction.Visible = false; linkbuttonSR.Visible = false; spcRule = ""; int n = 0; if (SRCBKL.Items.Count > 0) { for (int i = 1; i < SRCBKL.Items.Count; i++) { if (SRCBKL.Items[i].Selected) { spcRule += SRCBKL.Items[i].Value; n++; } } } if (n > 2) { errorCode = 4; } string eid = eventID; string gln = ""; string gfn = ""; int ggender = 0; string ghcp = tbGHcp.Text; int guestID = 0; int PlayerID = MrSignup.GetPlayerID(ln, fn, gender); if (cbGuestRule.Checked) { gln = tbGLN.Text.Trim(); gfn = tbGFN.Text.Trim(); ggender = rblGgender.SelectedIndex + 1; guestID = MrSignup.GetGuestID(gln, gfn, ghcp, ggender); errorCode = MrSignup.ValidateGuestPlaying(eid, guestID, PlayerID); } if (errorCode == 0) { string errmsg = MrSignup.AddToList(eid, PlayerID, action, carpool, gender, spcRule, guestID); // lblAction.Text = string.Format("Your {0} for this event was successful.",action); lblAction.Text = errmsg; // lblAction.ForeColor = System.Drawing.Color.DarkGreen; lblAction.ForeColor = System.Drawing.Color.Firebrick; lblAction.Font.Bold = true; lblAction.Visible = true; // LinkButton1.Visible = false; } if (errorCode == 1) { lblAction.Text = "Partner already playing. Signup is unsuccessful."; lblAction.ForeColor = System.Drawing.Color.Firebrick; lblAction.Visible = true; // LinkButton1.Visible = false; } if (errorCode == 2) { lblAction.Text = "Partner has played once. Signup unsuccessful."; lblAction.ForeColor = System.Drawing.Color.Firebrick; lblAction.Visible = true; // LinkButton1.Visible = false; } if (errorCode == 4) { lblAction.Text = "Select no more than one Special Rule. Signup unsuccessful."; lblAction.ForeColor = System.Drawing.Color.Firebrick; lblAction.Visible = true; } if (errorCode == 6) { lblAction.Text = "Invalid Access Code. Please try again"; lblAction.ForeColor = System.Drawing.Color.Firebrick; lblAction.Visible = true; } getPlayersList(eventID); resetSignupForm(); if (errorCode == 0) { // Server.Transfer("Default.aspx"); } }