コード例 #1
0
        public void SendMessage(string userName, string message, string time, string groupId, string isPrivate)
        {
            string UserImg = GetUserImage(userName);

            // save message to database
            string query = "INSERT INTO Messages(Username,GroupID,Text,Time) VALUES('" + userName + "','" + groupId + "','" + message + "','" + time + "')";

            if (ConnC.ExecuteNonQuery(query) == 0)
            {
                return;
            }

            // Broadcast message
            Clients.Group(groupId).messageReceived(userName, message, time, UserImg, groupId, isPrivate);
        }
コード例 #2
0
        protected void btnChangePicModel_Click(object sender, EventArgs e)
        {
            string serverPath = HttpContext.Current.Server.MapPath("~/");

            //path = serverPath + path;
            if (FileUpload1.HasFile)
            {
                string FileWithPath = serverPath + @"images/DP/" + UserName + FileUpload1.FileName;

                FileUpload1.SaveAs(FileWithPath);
                SD.Image img  = SD.Image.FromFile(FileWithPath);
                SD.Image img1 = RezizeImage(img, 151, 150);
                img1.Save(FileWithPath);
                if (File.Exists(FileWithPath))
                {
                    FileInfo fi        = new FileInfo(FileWithPath);
                    string   ImageName = fi.Name;
                    string   query     = "update Users set Photo='" + ImageName + "' where Username='******'";
                    if (ConnC.ExecuteNonQuery(query) > 0)
                    {
                        UserImage = "images/DP/" + ImageName;
                    }
                }
            }
        }
コード例 #3
0
        protected void btnRegister_ServerClick(object sender, EventArgs e)
        {
            string Query  = "insert into Users(Username,Password)Values('" + txtUser.Value + "','" + txtPassword.Value + "')";
            string ExistQ = "select * from Users where Username='******'";

            if (!ConnC.IsExist(ExistQ))
            {
                if (ConnC.ExecuteNonQuery(Query) > 0)
                {
                    ConnC.ExecuteNonQuery("INSERT INTO UsersInGroups(Username,GroupID) VALUES ('" + txtUser.Value + "',1)");
                    ScriptManager.RegisterStartupScript(this, GetType(), "Message", "alert('Registration successful!');", true);
                    Session["UserName"] = txtUser.Value;
                    Response.Redirect("Chat.aspx");
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "Message", "alert('Username Already exists!');", true);
            }
        }