protected void btnRegister_ServerClick(object sender, EventArgs e) { if (FileImgsave.HasFile) { lblmsg.Text = ""; var supportedTypes = new[] { "png", "jpg", "bmp", "jpeg", "tif", "eps", "jfif" }; var fileExt = System.IO.Path.GetExtension(FileImgsave.FileName).Substring(1); if (!supportedTypes.Contains(fileExt)) { lblmsg.ForeColor = Color.Red; lblmsg.Text = "File Extension Is InValid - Only Upload png,jpg,jpeg,bmp,tif,eps,jfif format images"; } else { string str = FileImgsave.FileName; FileImgsave.PostedFile.SaveAs(Server.MapPath("~/Images/" + "profile/" + str)); string imgPath = "images/" + "profile/" + str; string Query = "insert into tbl_Users(UserName,Badge,EnrollNo,Department,Year,Email,Password,Photo)Values('" + txtName.Value + "','" + Badge.Text + "','" + EnrollNo.Value + "','" + Department.Text + "','" + year.Text + "','" + txtEmail.Value + "','" + txtPassword.Value + "','" + imgPath + "')"; string ExistQ = "select * from tbl_Users where Email='" + txtEmail.Value + "'"; if (!ConnC.IsExist(ExistQ)) { if (ConnC.ExecuteQuery(Query)) { string CreateTableQuery = "create table if not exists groupsof_" + EnrollNo.Value + "(GroupID varchar(40))"; ConnC.ExecuteQuery(CreateTableQuery); if (Badge.Text == "Student" || Badge.Text == "CR") { string InsertGroupQuery = "insert into " + "groupsof_" + EnrollNo.Value + "(GroupID) values('" + year.Text + Department.Text + "')"; ConnC.ExecuteQuery(InsertGroupQuery); ConnC.AddToGroup(year.Text + Department.Text, EnrollNo.Value); } ScriptManager.RegisterStartupScript(this, GetType(), "Message", "alert('Congratulations!! You have successfully registered..');", true); FC.FireRegister(new SignalRChat.User() { name = txtName.Value, enrollno = EnrollNo.Value }); Response.Redirect("Login.aspx"); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "Message", "alert('Email is already Exists!! Please Try Different Email..');", true); } } } else { lblmsg.ForeColor = Color.Red; lblmsg.Text = "Please select Image"; } }
protected void btnSignIn_Click(object sender, EventArgs e) { string Query = "select * from Users where Username='******' and Password='******'"; if (ConnC.IsExist(Query)) { string UserName = ConnC.GetColumnVal(Query, "UserName"); Session["UserName"] = UserName; Response.Redirect("Chat.aspx"); } else { //todo error message } }
protected void btnSendMsg_ServerClick(object sender, EventArgs e) { string Query = "Insert into tbl_History (UserName,Message) values ('" + UserName + "','" + txtMessage.Value + "' )"; ConnC.IsExist(Query); //if (ConnC.IsExist(Query)) //{ // string UserName = ConnC.GetColumnVal(Query, "UserName"); // Session["UserName"] = UserName; // Session["Message"] = Request.Form["Message"]; // Response.Redirect("Chat.aspx"); //} }
protected void btnSignIn_Click(object sender, EventArgs e) { string Query = "select * from tbl_Users where Email='" + txtEmail.Value + "' and Password='******'"; if (ConnC.IsExist(Query)) { string UserName = ConnC.GetColumnVal(Query, "UserName"); Session["UserName"] = UserName; Session["Email"] = txtEmail.Value; Response.Redirect("Chat.aspx"); } else { txtEmail.Value = "Invalid Email or Password!!"; } }
protected void btnRegister_ServerClick(object sender, EventArgs e) { string Query = "insert into tbl_Users(UserName,Email,Password)Values('" + txtName.Value + "','" + txtEmail.Value + "','" + txtPassword.Value + "')"; string ExistQ = "select * from tbl_Users where Email='" + txtEmail.Value + "'"; if (!ConnC.IsExist(ExistQ)) { if (ConnC.ExecuteQuery(Query)) { ScriptManager.RegisterStartupScript(this, GetType(), "Message", "alert('Congratulations!! You have successfully registered..');", true); Session["UserName"] = txtName.Value; Session["Email"] = txtEmail.Value; Response.Redirect("Chat.aspx"); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "Message", "alert('Email is already Exists!! Please Try Different Email..');", true); } }
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); } }
protected void btnSignIn_Click(object sender, EventArgs e) { string Query = "select * from tbl_Users where Email='" + txtEmail.Value + "' and Password='******'"; if (ConnC.IsExist(Query)) { string UserName = ConnC.GetColumnVal(Query, "UserName"); Session["UserName"] = UserName; string Badge = ConnC.GetColumnVal(Query, "Badge"); Session["UserBadge"] = Badge; string EnrollNo = ConnC.GetColumnVal(Query, "EnrollNo"); Session["UserEnrollNo"] = EnrollNo; string Department = ConnC.GetColumnVal(Query, "Department"); Session["UserDepartment"] = Department; Session["Pass"] = txtPassword.Value; Session["UserEmail"] = txtEmail.Value; Response.Redirect("NewForm.aspx"); } else { txtEmail.Value = "Invalid Email or Password!!"; } }