Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //add properties to drop down list
            if (!this.IsPostBack)
            {
                MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["TestCapstone"].ConnectionString);
                conn.Open();
                string          checkShowing = "select distinct PropertyName from  table4";
                MySqlCommand    comd         = new MySqlCommand(checkShowing, conn);
                MySqlDataReader dr           = comd.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    AddressDropDownList.DataSource     = dr;
                    AddressDropDownList.DataTextField  = "PropertyName";
                    AddressDropDownList.DataValueField = "PropertyName";
                    AddressDropDownList.DataBind();
                }
                dr.Close();
                conn.Close();
                AddressDropDownList.Items.Insert(0, new ListItem("--Select Address--", "0"));
            }

            if (Convert.ToInt32(Session["userType"]) == 2)
            {
                LiteralControl nav = new LiteralControl();
                nav.Text = "<a href=\"Registration.aspx\">Users</a>";
                navADD.Controls.Add(nav);
                LiteralControl navedit = new LiteralControl();
                navedit.Text = "<a href=\"EditHousingList.aspx\">Edit Housing List</a>";
                editADD.Controls.Add(navedit);
            }
            if (Session["user"] == null)
            {
                Response.Write("<script language=javascript> var agree; agree=confirm('You have to log in first'); window.location='Login.aspx';</script>");
            }
            if (Session["PhoneNumber"] == null)
            {
                Response.Write("<script language=javascript> var agree; agree=confirm('You have to log in first'); window.location='Login.aspx';</script>");
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null)
            {
                Response.Write("<script language=javascript> var agree; agree=confirm('You have to log in first'); window.location='Login.aspx';</script>");
            }
            else if (Convert.ToInt32(Session["usertype"]) != 2)
            {
                Response.Write("<script language=javascript> var agree; agree=confirm('You are not allowed access to this page'); window.location='Login.aspx';</script>");
            }
            if (Session["PhoneNumber"] == null)
            {
                Response.Write("<script language=javascript> var agree; agree=confirm('You have to log in first'); window.location='Login.aspx';</script>");
            }


            //add addresses to drop down list
            if (!this.IsPostBack)
            {
                MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["TestCapstone"].ConnectionString);
                conn.Open();
                string          checkShowing = "select distinct PropertyName from table4";
                MySqlCommand    comd         = new MySqlCommand(checkShowing, conn);
                MySqlDataReader dr           = comd.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    AddressDropDownList.DataSource     = dr;
                    AddressDropDownList.DataTextField  = "PropertyName";
                    AddressDropDownList.DataValueField = "PropertyName";
                    AddressDropDownList.DataBind();
                }
                dr.Close();
                conn.Close();
                AddressDropDownList.Items.Insert(0, new ListItem("--Select Address--", "0"));
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null)
            {
                Response.Write("<script language=javascript> var agree; agree=confirm('You have to log in first'); window.location='Login.aspx';</script>");
            }
            if (Convert.ToInt32(Session["userType"]) != 2)
            {
            }
            else
            {
                LiteralControl nav = new LiteralControl();
                nav.Text = "<a href=\"Registration.aspx\">Users</a>";
                navADD.Controls.Add(nav);
                LiteralControl navedit = new LiteralControl();
                navedit.Text = "<a href=\"EditHousingList.aspx\">Edit Housing List</a>";
                editADD.Controls.Add(navedit);
            }
            if (Session["PhoneNumber"] == null)
            {
                Response.Write("<script language=javascript> var agree; agree=confirm('You have to log in first'); window.location='Login.aspx';</script>");
            }

            if (!IsPostBack)
            {
                string qry = "select * from (select * from messages where phoneNumber = '" + Session["PhoneNumber"].ToString() + "' order by `Address`, id desc, messageBody) x group by `Address`";
                if (Convert.ToInt32(Session["userType"]) == 2)
                {
                    qry = "select * from (select * from messages order by `Address`, id desc, messageBody) x group by `Address`";
                }
                MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["TestCapstone"].ConnectionString);
                conn.Open();

                MySqlCommand    cmd = new MySqlCommand(qry, conn);
                MySqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    string btn;
                    string address  = rdr["Address"].ToString();
                    string contentb = rdr["messageBody"].ToString();
                    string start    = "<tr>";
                    string phnum    = "<td>" + address + "</td>";
                    string content  = "<td>" + contentb + "</td>";
                    if (CompareLatestMessage(address) == true)
                    {
                        btn = "<td style=\"width:20%;\"><a href=\"EditMessage.aspx?Address=" + address + "\" class=\"btn btn-default\">View</a>&nbsp<i class=\"fa fa-exclamation-circle\" style=\"font - size:64px; color: red\"></i></td>";
                    }
                    else
                    {
                        btn = "<td style=\"width:20%;\"><a href=\"EditMessage.aspx?Address=" + address + "\" class=\"btn btn-default\">View</a></td>";
                    }
                    string end = "</tr>";
                    messageList.InnerHtml += start + phnum + content + btn + end;
                }

                //close Data Reader
                rdr.Close();

                //close Connection
                conn.Close();
            }

            //add addresses to drop down list
            if (!this.IsPostBack)
            {
                MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["TestCapstone"].ConnectionString);
                conn.Open();
                string          checkShowing = "select distinct PropertyName from table4";
                MySqlCommand    comd         = new MySqlCommand(checkShowing, conn);
                MySqlDataReader dr           = comd.ExecuteReader();
                dr.Read();
                if (dr.HasRows)
                {
                    AddressDropDownList.DataSource     = dr;
                    AddressDropDownList.DataTextField  = "PropertyName";
                    AddressDropDownList.DataValueField = "PropertyName";
                    AddressDropDownList.DataBind();
                }
                dr.Close();
                conn.Close();

                AddressDropDownList.Items.Insert(0, new ListItem("--Select Address--", "0"));
                if (Convert.ToInt32(Session["userType"]) == 2)
                {
                    AddressDropDownList.Items.Insert(1, new ListItem("Send To All Addresses", "1"));
                }
            }
            tbMessage.Attributes.Add("maxlength", "1500");
        }