示例#1
0
        //TODO, Put radio buttons to set the date
        //1 month, 3 months this year..
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int eventID = int.Parse(Request.QueryString["EventID"]);
                EventClient evClient = new EventClient();
                Events event_;
                List<EventDay> evDays_;
                try
                {
                    event_ = evClient.GetEvent(eventID);
                    evDays_ = evClient.GetDays(event_.EventID).ToList<EventDay>();
                }
                catch (Exception ex)
                {
                    evClient.Close();
                    Response.Redirect("~/Error404.aspx");
                    return;
                }

                evClient.Close();
                try
                {
                    this.hypRegister.NavigateUrl = "~/Register.aspx?EventID=" + eventID.ToString() + "&Name=" + event_.Name;

                    RegistrationClient client = new RegistrationClient();
                    Publish publish = client.ViewPublish(eventID);
                    client.Close();

                    menuEvent.Visible = true;
                    mvTab.Visible = true;

                    lbleventname.Text = event_.Name;
                    lbleventdate.Text = "From " + event_.StartDateTime.ToString("dd MMM yyyy") + " To "
                        + event_.EndDateTime.ToString("dd MMM yyyy");

                    lbleventdescription.Text = event_.Description;
                    hypeventwebsite.Text = event_.Website;

                    if (event_.Website.Length == 0)
                    {
                        hypeventwebsite.Visible = false;
                        lblWebsite.Visible = false;
                    }
                    else
                    {
                        hypeventwebsite.NavigateUrl = event_.Website;
                    }

                    if (publish != null)
                    {
                        lbleventpublishinfo.Text = publish.Remarks;
                        lblPublish.Visible = true;

                        if (publish.PaymentAMount > 0)
                        {
                            lblpaymentinfo.Text = "$" + publish.PaymentAMount.ToString("0.00");
                        }
                        else
                        {
                            lblpaymentinfo.Text = "Event is Free! :)";
                        }
                    }
                    else
                    {
                        lbleventpublishinfo.Text = "";
                        lblPublish.Visible = false;
                        lblpaymentinfo.Text = "";
                    }

                    lblpaymentinfo.Visible = lblPublish.Visible;
                    lblpaymentinfo.Visible = lblpayment.Visible;

                    ddlEventDay.DataSource = evDays_;
                    ddlEventDay.DataValueField = "DayID";
                    ddlEventDay.DataTextField = "StartDateTime";

                    ddlEventDay.DataBind();
                    ddlEventDay_SelectedIndexChanged(this.ddlEventDay, new EventArgs());
                    evClient.Close();

                    if (publish == null || (publish.StartDateTime > DateTime.Now || publish.EndDateTime < DateTime.Now))
                    {
                        this.hypRegister.Visible = false;
                    }
                    else
                    {
                        hypRegister.Visible = true;
                    }

                }
                catch (Exception ex)
                {
                    Alert.Show("Error Retreiving List of Events from Server", false, "~/Default.aspx");
                    return;
                }
            }
        }