Пример #1
0
        protected void BtnMessages_Click(object sender, EventArgs e)
        {
            MultiView2.ActiveViewIndex = 1;

            // mesajları çekme
            var           connection = WebConfigurationManager.ConnectionStrings["DBConnection"];
            SqlConnection sc         = new SqlConnection(connection.ConnectionString);
            SqlCommand    c          = new SqlCommand("SELECT * FROM VUsrMessages");
            SqlCommand    c2         = new SqlCommand("SELECT * FROM tblOtherMessages");
            SqlDataReader r;

            c.Connection  = sc;
            c2.Connection = sc;
            try
            {
                sc.Open();
                r = c.ExecuteReader();
                RepeaterMessages.DataSource = r;
                RepeaterMessages.DataBind();
                r.Close();
                r = c2.ExecuteReader();
                RepeaterOtherMsg.DataSource = r;
                RepeaterOtherMsg.DataBind();
                r.Close();
            }
            catch (SqlException ex)
            {
                Response.Write("Error!" + ex.Message);
            }
            finally
            {
                sc.Close();
                sc.Dispose();
            }
        }
Пример #2
0
        protected void Refresh(object sender, EventArgs e)
        {
            List <Message> messages = context.Messages.Take(100).ToList <Message>();

            RepeaterMessages.DataSource = messages;
            RepeaterMessages.DataBind();
        }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet ds = GetData();

        RepeaterRequest.DataSource = ds;
        RepeaterRequest.DataBind();

        ds = GetMessage();
        RepeaterMessages.DataSource = ds;
        RepeaterMessages.DataBind();
    }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["UserId"] != null)
     {
         int userId     = Convert.ToInt32(Session["UserId"]);
         int recieverId = Convert.ToInt32(Session["MessageToId"]);
         RepeaterMessages.DataSource = GetMessages("Select m.Message,u.Name from tblMessage as m inner join tblUsers as u on m.senderId=u.Id where (senderId = " + userId + " and recieverId = " + recieverId + ") or (senderId = " + recieverId + " and recieverId = " + userId + " )");
         RepeaterMessages.DataBind();
         imgYou.ImageUrl      = "../User/Handler.ashx?imgID=" + Session["UserId"];
         imgReciever.ImageUrl = "../User/Handler.ashx?imgID=" + Session["MessageToId"];
     }
     else
     {
         Response.Redirect("Login.aspx");
     }
 }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //check login
            int UserId = 0;

            if (Request.Cookies["VC"] != null)
            {
                string VC = Request.Cookies["VC"].Values["VC"];
                Classes.LoginSession ls = new Classes.LoginSession();
                UserId = ls.getUserId(VC);
                if (UserId == 0) //if user not logged in redirect to login
                {
                    Response.Redirect("~/Login/Messages");
                }
                else
                {
                    Session["UserId"] = UserId.ToString();
                }
            }
            else
            {
                Response.Redirect("~/Login/Messages");
            }

            int otherId = Convert.ToInt32(Page.RouteData.Values["ProfileId"].ToString());

            Classes.Messages m = new Classes.Messages();
            Tuple <int, DataTable, DataTable, DataTable> result = m.showMessages(UserId, otherId);

            int       status      = result.Item1;
            DataTable dtUserName  = result.Item2;
            DataTable dtOtherName = result.Item3;
            DataTable dtMessages  = result.Item4;

            if (status == -1)
            {
                Response.Redirect("~/Messages");
            }

            HiddenFieldOwnerName.Value = dtUserName.Rows[0]["FirstName"].ToString() + " " + dtUserName.Rows[0]["LastName"].ToString();
            HiddenFieldOtherName.Value = dtOtherName.Rows[0]["FirstName"].ToString() + " " + dtOtherName.Rows[0]["LastName"].ToString();
            Page.Title = "Messages : " + dtOtherName.Rows[0]["FirstName"].ToString() + " " + dtOtherName.Rows[0]["LastName"].ToString();

            RepeaterMessages.DataSource = dtMessages;
            RepeaterMessages.DataBind();
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //check login
            int UserId = 0;

            if (Request.Cookies["VC"] != null)
            {
                string VC = Request.Cookies["VC"].Values["VC"];
                Classes.LoginSession ls = new Classes.LoginSession();
                UserId = ls.getUserId(VC);
                if (UserId == 0) //if user not logged in redirect to login
                {
                    Response.Redirect("~/Login/Messages");
                }
                else
                {
                    Session["UserId"] = UserId.ToString();
                }
            }
            else
            {
                Response.Redirect("~/Login/Messages");
            }

            //all read
            Classes.Messages m = new Classes.Messages();
            m.allRead(UserId);

            //get message lists
            DataTable dt = m.messageLists(UserId);

            if (dt.Rows.Count == 0)
            {
                LabelNoRecord.Visible = true;
            }
            else
            {
                RepeaterMessages.DataSource = dt;
                RepeaterMessages.DataBind();
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //check login
            int UserId = 0;

            if (Session["UserId"] != null)
            {
                UserId = Convert.ToInt32(Session["UserId"]);
            }
            else
            {
                if (Request.Cookies["VC"] != null)
                {
                    string VC = Request.Cookies["VC"].Values["VC"];
                    Classes.LoginSession ls = new Classes.LoginSession();
                    UserId = ls.getUserId(VC);
                    if (UserId == 0) //if user not logged in redirect to login
                    {
                        Response.Redirect("~/Login/Messages");
                    }
                    else
                    {
                        Session["UserId"] = UserId.ToString();
                    }
                }
                else
                {
                    Response.Redirect("~/Login/Messages");
                }
            }

            //check user status
            string completionValue = Session["DoneCompletion"] as string; if (String.IsNullOrEmpty(completionValue))

            {
                Classes.UserInfo ui = new Classes.UserInfo();
                int userStatus      = ui.getUserStatus(UserId);
                switch (userStatus)
                {
                case 1:
                    Session["DoneCompletion"] = "1";
                    break;

                case 0:
                case 4:
                    Response.Redirect("~/Completion");
                    break;

                case 2:
                    Response.Redirect("~/Error/UserDisabled");
                    break;

                case 3:
                    Response.Redirect("~/Error/UserDeactivated");
                    break;
                }
            }

            //all read
            Classes.Messages m = new Classes.Messages();
            m.allRead(UserId);

            //get message lists
            DataTable dt = m.messageLists(UserId);

            if (dt.Rows.Count == 0)
            {
                HiddenFieldStatus.Value = "0";
            }
            else
            {
                RepeaterMessages.DataSource = dt;
                RepeaterMessages.DataBind();
                HiddenFieldStatus.Value = "1";
            }
        }