Esempio n. 1
0
        private StringBuilder UpdateDonorEventList(string id, string field, string value)
        {
            var sbReturn = new StringBuilder();

            try
            {
                var donorEventList = new DonorEventList(User.Identity.Name, int.Parse(id));

                switch (field)
                {
                case "TicketsRequested":
                    donorEventList.TicketsRequested = int.Parse(value);
                    break;

                case "Attending":
                    donorEventList.Attending = bool.Parse(value);
                    break;

                case "SPLCComments":
                    donorEventList.SPLCComments = value;
                    break;
                }

//                donorEventList.Update();
                donorEventList.SaveChanges();
                sbReturn.Append("True");
            }
            catch (Exception ex)
            {
                sbReturn.Append("Error");
            }

            return(sbReturn);
        }
        protected void btnUpdateDemo_Click(object sender, EventArgs e)
        {
            var donorEventList = new DonorEventList(User.Identity.Name, int.Parse(Request["delid"]))
            {
                UpdatedInfo         = false,
                UpdatedInfo_User    = User.Identity.Name,
                UpdatedInfoDateTime = DateTime.Parse("1/1/1000")
            };

            donorEventList.SaveChanges();

            Response.Redirect("DonorEventListDetails.aspx?delid=" + donorEventList.pk_DonorEventList);
        }
        protected void btnMailCard_Click(object sender, EventArgs e)
        {
            var donorEventList = new DonorEventList(User.Identity.Name, int.Parse(Request["delid"]))
            {
                TicketsMailed_Date = DateTime.Now,
                TicketsMailed_User = User.Identity.Name,
                TicketsRequested   = int.Parse(txtAttending.Text),
                WaitingList_Date   = DateTime.Parse(BaseDate),
                WaitingListOrder   = 0
            };

            donorEventList.SaveChanges();

            btnMailCard.Visible   = false;
            lblCardMailed.Visible = true;
            lblCMailed.Visible    = true;
            lblCMailed.Text       = donorEventList.TicketsMailed_Date.ToShortDateString();

            Response.Redirect("DonorEventListDetails.aspx?delid=" + donorEventList.pk_DonorEventList);
        }
Esempio n. 4
0
        protected void btnRegisterUser_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsValid)
                {
                    lblMessage.Text = "NO";
                }
                else
                {
                    if (txtAttending.Text.Equals(""))
                    {
                        txtAttending.Text = "0";
                    }

                    // Validate Data Entry
                    if (!chkGuest.Checked)
                    {
                        if (txtDonorID.Text.Length.Equals(0))
                        {
                            throw new Exception("Please enter a valid Donor ID!");
                        }
                    }

                    if (chkAttending.Checked && int.Parse(txtAttending.Text) < 1)
                    {
                        throw new Exception("Please enter the number of attendees!");
                    }

                    if (!chkAttending.Checked && int.Parse(txtAttending.Text) > 0)
                    {
                        throw new Exception("If not attending please remove the number of attendees!");
                    }

                    var       eventList      = new EventList(User.Identity.Name, int.Parse(ddlEvents.SelectedValue));
                    var       donorEventList = new DonorEventList(User.Identity.Name);
                    DonorList donorList;

                    if (chkGuest.Checked)
                    {
                        donorList = new DonorList();
                        donorList.AddNewGuestToEvent(eventList.pk_Event);

                        donorEventList.fk_Event     = eventList.pk_Event;
                        donorEventList.fk_DonorList = donorList.pk_DonorList;
                        donorEventList.AddNew();
                    }
                    else
                    {
                        var specialEventCodes = new[] { "jbond", "jsncc", "naacp", "splcj", "jbhrc", "bondj", "jhbms" };
                        var finderNumber      = txtDonorID.Text.Trim();


                        if (specialEventCodes.Contains(finderNumber.ToLower()))
                        {
                            var guid = Guid.NewGuid();

                            var key   = finderNumber + guid.ToString().Replace("-", "").Substring(0, 5).ToUpper();
                            var donor = new DonorList()
                            {
                                pk_DonorList = key.ToUpper(), IsValid = true, AccountType = "Guest", DonorType = "Guest"
                            };
                            donor.Create();

                            var del = new DonorEventList("")
                            {
                                fk_Event = eventList.pk_Event, fk_DonorList = key
                            };
                            del.Create();
                            finderNumber = key;
                        }

                        donorEventList.Load(eventList.pk_Event, finderNumber);

                        if (donorEventList.pk_DonorEventList <= 0)
                        {
                            throw new Exception("Donor ID is not registered with this Event!");
                        }

                        if (donorEventList.Response_Date > DateTime.Parse(BaseDate))
                        {
                            throw new Exception("Donor has already registered for this Event!");
                        }
                    }

                    donorList = new DonorList(donorEventList.fk_DonorList);

                    // Update Donor Information
                    if (UpdateDonorList(donorList))
                    {
                        donorEventList.UpdatedInfo         = true;
                        donorEventList.UpdatedInfoDateTime = DateTime.Now;
                        donorEventList.UpdatedInfo_User    = donorList.AccountName;
                    }

                    // Register User
                    donorEventList.Response_Date = DateTime.Now;
                    donorEventList.Response_Type = "SPLC Admin";

                    if (chkAttending.Checked)
                    {
                        donorEventList.Attending = true;
                        lblMessage.Text          = "Donor is registered";
                    }
                    else
                    {
                        donorEventList.Attending = false;
                        lblMessage.Text          = "Donor is not attending.";
                    }

                    // Register User
                    if (donorEventList.GetTicketCountForEvent() > eventList.Capacity && chkAttending.Checked)
                    {
                        // Add to Waiting List
                        donorEventList.Response_Date = DateTime.Now;
                        donorEventList.Response_Type = "SPLC Admin";

                        donorEventList.WaitingList_Date = DateTime.Now;
                        donorEventList.WaitingListOrder = donorEventList.GetNextWaitListNumber();
                        donorEventList.TicketsRequested = int.Parse(txtAttending.Text);
                        lblMessage.Text = "Donor was added to the Waiting List";
                    }
                    else
                    {
                        donorEventList.TicketsRequested = int.Parse(txtAttending.Text);
                        lblMessage.ForeColor            = System.Drawing.Color.Green;
                    }

                    //                    DonorEL.Update();
                    donorEventList.SaveChanges();
                    txtDonorID.Text      = "";
                    txtAttending.Text    = "0";
                    chkAttending.Checked = false;

                    if (donorList.EmailAddress.Equals(""))
                    {
                        return;
                    }

                    var donorEmail = new DonorEmail(User.Identity.ToString(), ConfigurationManager.AppSettings["EmailTemplatesURL"], donorList, donorEventList);
                    donorEmail.SendEmail();
                    ClearControl(Form);
                }
            }
            catch (Exception ex)
            {
                lblMessage.ForeColor = System.Drawing.Color.Red;
                lblMessage.Text      = ex.Message; // "Donor ID is not registered with this Event!";
            }
        }