protected void Page_Load(object sender, EventArgs e) { clsDBCalls objDb = new clsDBCalls(); string sessionId = Session.SessionID.ToString(); string toId = Request["toId"]; objDb.resetAlert(sessionId, toId); Response.Redirect("\\ChatSite\\Chat.aspx?toId=" + toId); }
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { string SelectedId = ListBox1.SelectedItem.ToString(); string sessionId = Session.SessionID.ToString(); //string UserId = null; clsDBCalls dbObj = new clsDBCalls(); //UserId = dbObj.getUserName(sessionId); dbObj.setAlert(sessionId, SelectedId); Response.Write("<script>open('\\Chat.aspx?toId=" + SelectedId + "','List','scrollbars=no,resizable=no,width=600,height=400');</script>"); }
protected void Page_Load(object sender, EventArgs e) { clsDBCalls dbObj = new clsDBCalls(); if (dbObj.CheckSession(Session.SessionID.ToString()) == 1) { Response.Redirect("\\chatsite\\Home.aspx"); } txtEmailID.Focus(); }
protected void Timer1_Tick(object sender, EventArgs e) { //Check for alerts clsDBCalls objDBcall = new clsDBCalls(); string sessionId = Session.SessionID.ToString(); DataTable dtCheckAlert = new DataTable(); dtCheckAlert = objDBcall.checkAlert(sessionId); foreach(DataRow dr in dtCheckAlert.Rows) { string InviterId = dr["UserId1"].ToString(); lnkMessageButton.Text = "You have a new message from " + InviterId; lnkMessageButton.OnClientClick = "document.getElementById('lnkMessageButton').innerText=''; open('\\ResetAlert.aspx?toId=" + InviterId + "','List','scrollbars=no,resizable=no,width=600,height=400')"; } }
protected void btnSend_Click(object sender, EventArgs e) { string Message = txtMessage.Text; txtMessage.Text = ""; txtMessage.Focus(); string sessionId = Session.SessionID.ToString(); clsDBCalls objData = new clsDBCalls(); string toId = Request["toId"]; int retVal = objData.InsertMessage(sessionId, toId, Message); if (retVal == 1) { lblMessage.Text = "An error occurred while sending your message "; } }
protected void btnLogin_Click(object sender, EventArgs e) { string md5Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "MD5"); clsDBCalls objLogin = new clsDBCalls(); string userName = (txtEmailID.Text.Trim()); string sessionId = Session.SessionID.ToString(); int retval = objLogin.CheckLogin(userName, md5Password, sessionId); if (retval == 1) { Response.Redirect("\\chatsite\\Home.aspx"); } else { lblMessage.Text = "Invalid mail id or password"; } }
protected void btnAdd_Click(object sender, EventArgs e) { string sessionId = Session.SessionID.ToString(); string FriendId = txtFreindID.Text; clsDBCalls dbObj = new clsDBCalls(); int status = Convert.ToInt32(dbObj.AddFriend(sessionId, FriendId)); if (status == 0) { lblMessage.Text = "You friend is not registered with us"; } else { lblMessage.Text = "Friend Added"; } }
protected void btnRegister_Click(object sender, EventArgs e) { string md5Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "MD5"); string userName = txtEmailId.Text.Trim(); clsDBCalls dbObj = new clsDBCalls(); int retVal = dbObj.RegisterUser(userName, md5Password); if (retVal == 1) { lblIdAvailable.Text = "User Id already taken"; } else if(retVal == 2) { lblIdAvailable.Text = "DB Error"; } else if (retVal == 0) { lblIdAvailable.Text = "User Registered. Please login"; } }
protected void Timer1_Tick(object sender, EventArgs e) { string sessionId = Session.SessionID.ToString(); clsDBCalls objData = new clsDBCalls(); string toId = Request["toId"]; DataTable dtChat = new DataTable(); dtChat = objData.getMessages(sessionId, toId); if (dtChat.Rows.Count > 0) { string Chats = null; foreach (DataRow row in dtChat.Rows) { string msender = row["Userid1"].ToString(); string mmessage = row["messages"].ToString(); string times = (DateTime.Parse(row["timest"].ToString())).ToShortTimeString(); Chats = Chats + msender + ": \t" + mmessage + "\t" + times + "\n"; } txtChat.Text = Chats; } }
protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { string sessionId = Session.SessionID.ToString(); clsDBCalls fetchFriends = new clsDBCalls(); DataTable dtFriendList = new DataTable(); dtFriendList = fetchFriends.fetchFriends(sessionId); if (dtFriendList.Rows.Count > 0) { ListBox1.DataSource = dtFriendList; ListBox1.DataTextField = "UserName"; ListBox1.DataValueField = "UserId"; ListBox1.DataBind(); } else { lnkAddFriend.Text = "You do not have any friends, add some frnds and start chatting"; } } }