Escolar Documentos
Profissional Documentos
Cultura Documentos
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
}
protected void Button1_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("select *from UserDetails where Userid='" + txtuserid.Text + "'
and Mode='Active'", con);
dr = cmd.ExecuteReader();
{
if (dr.Read())
{
cmd1 = new SqlCommand("SelectData", new
SqlConnection(ConfigurationManager.ConnectionStrings["SECURE"].ToString()));
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue("@userid", txtuserid.Text);
cmd1.Parameters.AddWithValue("@username", txtusername.Text);
cmd1.Parameters.AddWithValue("@password", txtpassword.Text);
cmd1.Parameters.AddWithValue("@securitykey", txtsecuritykey.Text);
this.Session["Username"] = txtusername.Text;
cmd1.Connection.Open();
dr1 = cmd1.ExecuteReader();
int c = 1;
if (dr1.Read())
{
Response.Redirect("UserProfile.aspx");
else
{
Response.Write("<script>window.alert('Access Denied')</script>");
Session["counter"] = Convert.ToInt32(Session["counter"]) + c;
if (Convert.ToInt32(Session["counter"]) > 2)
{
Label11.Text = "More Than 3 times Failed - User blocked! Please Renewal your
account";
deactive();
Button1.Enabled = false;
Session.Abandon();
BtnRenew.Visible = true;
}
}
dr1.Close();
cmd1.Dispose();
cmd1.Connection.Close();
}
else
{
Response.Write("<script>window.alert('Access Denied Ur Account Was
Inactive')</script>");
}
dr.Close();
cmd.Dispose();
cmd.Connection.Close();
}
}
dr2 = cmd2.ExecuteReader();
if (dr2.Read())
{
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
}
public void deactive()
{
cmd.Dispose();
cmd1.Dispose();
dr.Close();
dr1.Close();
User Registration:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.IO;
using System.Net;
using System.Net.Mail;
}
protected void Button1_Click(object sender, EventArgs e)
{
SecurityKey();
cmd2 = new SqlCommand("spInsertData", new
SqlConnection(ConfigurationManager.ConnectionStrings["SECURE"].ToString()));
cmd2.CommandType = CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue("@userid", txtUid.Text);
cmd2.Parameters.AddWithValue("@username", txtUserName.Text);
cmd2.Parameters.AddWithValue("@password", txtPassword.Text);
cmd2.Parameters.AddWithValue("@confirmpassword", txtConfirmPassword.Text);
cmd2.Parameters.AddWithValue("@to", txtTo.Text);
cmd2.Parameters.AddWithValue("@emailpass", txtEmailPass.Text);
cmd2.Parameters.AddWithValue("@mobno", txtMobNo.Text);
cmd2.Parameters.AddWithValue("@securityqus", ddlSecurityQus.SelectedItem.Text);
cmd2.Parameters.AddWithValue("@securityans", txtSecurityAns.Text);
cmd2.Parameters.AddWithValue("@securitykey", lblSecurityKey.Text);
cmd2.Parameters.AddWithValue("@mode",CheckBox1.Text);
cmd2.Connection.Open();
cmd2.ExecuteNonQuery();
cmd2.Connection.Close();
sendmail();
txtUid.Text = "";
txtUserName.Text = "";
txtPassword.Text = "";
txtConfirmPassword.Text = "";
txtTo.Text = "";
txtEmailPass.Text = "";
txtSecurityAns.Text = "";
lblSecurityKey.Text = "";
}
protected void Button2_Click1(object sender, EventArgs e)
{
txtUid.Text = "";
txtUserName.Text = "";
txtPassword.Text = "";
txtConfirmPassword.Text = "";
txtTo.Text = "";
txtSecurityAns.Text = "";
lblSecurityKey.Text = "";
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
public void Auto()
{
int r;
cmd1 = new SqlCommand("Select max(Userid) from UserDetails", con);
dr1 = cmd1.ExecuteReader();
if (dr1.Read())
{
string d = dr1[0].ToString();
if (d == "")
{
txtUid.Text = "1001";
}
else
{
r = Convert.ToInt32(dr1[0].ToString());
r = r + 1;
txtUid.Text = r.ToString();
}
}
}
}
protected void SendEmail(object sender, EventArgs e)
{
}
protected void txtEmail_TextChanged(object sender, EventArgs e)
{
User Profile:
<%@ Page Title="" Language="C#" MasterPageFile="~/user4.master"
AutoEventWireup="true" CodeFile="UserProfile.aspx.cs" Inherits="UserProfile" %>
File Details:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
if (!IsPostBack)
{
BindGridviewData();
}
}
private void BindGridviewData()
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from FileInfo ", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
gvDetails.DataSource = ds;
gvDetails.DataBind();
}
protected void chk_Click(object sender, EventArgs e)
{
CheckBox chkbox = sender as CheckBox;
GridViewRow gvrow = chkbox.NamingContainer as GridViewRow;
if (chkbox.Checked == true)
{
}
protected void gvDetails_SelectedIndexChanged(object sender, EventArgs e)
{
}
public void chkStatus_OnCheckedChanged(object sender, EventArgs e)
{
CheckBox chkStatus = (CheckBox)sender;
GridViewRow row = (GridViewRow)chkStatus.NamingContainer;
con.Open();
com.ExecuteNonQuery();
con.Close();
BindGridviewData();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using System.Text;
using System.Security.Cryptography;
using System.Net;
using System.Net.Mail;
public partial class UploadFiles : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd, cmd1;
SqlDataReader dr, dr1;
}
private void PopulateUploadedFiles()
{
DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/UploadedFiles"));
List<UploadFile> uploadedFiles = new List<UploadFile>();
foreach (var file in di.GetFiles())
{
uploadedFiles.Add
(
new UploadFile
{
FileName = file.Name,
FileExtention = Path.GetExtension(file.Name),
FilePath = file.FullName,
Size = (file.Length / 1024), // For get size in KB
Icon = GetIconPath(Path.GetExtension(file.FullName)) // Need to Get Icon...
}
);
}
DataList1.DataSource = uploadedFiles;
DataList1.DataBind();
}
public string GetIconPath(string fileExtention)
{
string Iconpath = "\\Images";
string ext = fileExtention.ToLower();
switch (ext)
{
case ".txt":
Iconpath += "/txt.png";
break;
case ".doc":
case ".docx":
Iconpath += "/word.png";
break;
case ".xls":
case ".xlsx":
Iconpath += "/xls.png";
break;
case ".pdf":
Iconpath += "/pdf.png";
break;
case ".rar":
Iconpath += "/rar.png";
break;
case ".zip":
case ".7z":
Iconpath += "/zip.png";
break;
default:
break;
}
return Iconpath;
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "Download")
{
string filePath = e.CommandArgument.ToString();
// key for decryption
byte[] Key = Encoding.UTF8.GetBytes("asdf!@#$1234ASDF");
}
cs.Close();
fs.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
cs.Close();
fs.Close();
}
}
}
}
}
Client Login:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@clientid", txtusername.Text);
cmd.Parameters.AddWithValue("@password", txtpassword.Text);
cmd.Connection.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
}
cmd.Dispose();
cmd.Connection.Close();
}
protected void Button2_Click1(object sender, EventArgs e)
{
}
}
Client Registration:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.IO;
using System.Net;
using System.Net.Mail;
String connectionString =
ConfigurationManager.ConnectionStrings["SECURE"].ConnectionString;
con = new SqlConnection(connectionString);
con.Open();
Auto();
con.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
cmd2.CommandType = CommandType.StoredProcedure;
cmd2.Parameters.AddWithValue("@clientid", txtUid.Text);
cmd2.Parameters.AddWithValue("@Clientname", txtUserName.Text);
cmd2.Parameters.AddWithValue("@password", txtPassword.Text);
cmd2.Parameters.AddWithValue("@confirmpassword", txtConfirmPassword.Text);
cmd2.Parameters.AddWithValue("@to", txtTo.Text);
cmd2.Parameters.AddWithValue("@emailpass", txtEmailPass.Text);
cmd2.Parameters.AddWithValue("@mobno", txtMobNo.Text);
cmd2.Connection.Open();
cmd2.ExecuteNonQuery();
cmd2.Connection.Close();
txtUid.Text = "";
txtUserName.Text = "";
txtPassword.Text = "";
txtConfirmPassword.Text = "";
txtTo.Text = "";
txtEmailPass.Text = "";
}
protected void Button2_Click1(object sender, EventArgs e)
{
txtUid.Text = "";
txtUserName.Text = "";
txtPassword.Text = "";
txtConfirmPassword.Text = "";
txtTo.Text = "";
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
public void Auto()
{
int r;
cmd1 = new SqlCommand("Select max(Clientid) from ClientDetails", con);
dr1 = cmd1.ExecuteReader();
if (dr1.Read())
{
string d = dr1[0].ToString();
if (d == "")
{
txtUid.Text = "1001";
}
else
{
r = Convert.ToInt32(dr1[0].ToString());
r = r + 1;
txtUid.Text = r.ToString();
}
}
}
}
protected void txtEmail_TextChanged(object sender, EventArgs e)
{
File Upload :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using System.Text;
using System.Security.Cryptography;
String connectionString =
ConfigurationManager.ConnectionStrings["SECURE"].ConnectionString;
con = new SqlConnection(connectionString);
Auto();
}
private void PopulateUploadedFiles()
{
DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/UploadedFiles"));
List<UploadFile> uploadedFiles = new List<UploadFile>();
foreach (var file in di.GetFiles())
{
uploadedFiles.Add
(
new UploadFile
{
FileName = file.Name,
FileExtention = Path.GetExtension(file.Name),
FilePath = file.FullName,
Size = (file.Length / 1024), // For get size in KB
Icon = GetIconPath(Path.GetExtension(file.FullName)) // Need to Get Icon...
}
);
}
//DataList1.DataSource = uploadedFiles;
//DataList1.DataBind();
}
public void uploadsave()
{
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.SaveAs(Server.MapPath("Files/" + filename));
con.Open();
SqlCommand cmd = new SqlCommand("insert into
FileInfo(Userid,Fileid,FileName,FileDesc,FilePath,Approved)
values(@Userid,@Fileid,@Name,@FileDesc,@Path,@Approved)", con);
cmd.Parameters.AddWithValue("@userid", txtuserid.Text);
cmd.Parameters.AddWithValue("@Fileid",txtfileid.Text);
cmd.Parameters.AddWithValue("@Name", filename);
cmd.Parameters.AddWithValue("@FileDesc", txtFileDescription.Text);
cmd.Parameters.AddWithValue("@Path", "Files/" + filename);
cmd.Parameters.AddWithValue("@Approved","False");
cmd.ExecuteNonQuery();
ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script
language='javascript'>alert('Upload success')</script>");
con.Close();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
}
public void Auto()
{
con.Open();
int r;
cmd = new SqlCommand("Select max(Fileid) from FileInfo", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
string d = dr[0].ToString();
if (d == "")
{
txtfileid.Text = "01";
}
else
{
r = Convert.ToInt32(dr[0].ToString());
r = r + 1;
txtfileid.Text = r.ToString();
}
}
con.Close();
}
protected void btnUpload_Click(object sender, EventArgs e)
{
PopulateUploadedFiles();
}
catch
{
Response.Write("Encryption Failed! Please try again.");
}
uploadsave();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
if (!IsPostBack)
{
BindGridviewData();
}
}
private void BindGridviewData()
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from FileInfo ", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
gvDetails.DataSource = ds;
gvDetails.DataBind();
}
protected void chk_Click(object sender, EventArgs e)
{
CheckBox chkbox = sender as CheckBox;
GridViewRow gvrow = chkbox.NamingContainer as GridViewRow;
if (chkbox.Checked == true)
{
}
protected void gvDetails_SelectedIndexChanged(object sender, EventArgs e)
{
}
public void chkStatus_OnCheckedChanged(object sender, EventArgs e)
{
CheckBox chkStatus = (CheckBox)sender;
GridViewRow row = (GridViewRow)chkStatus.NamingContainer;
con.Open();
com.ExecuteNonQuery();
con.Close();
BindGridviewData();
}
}
Renewal Account:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
txtUid.Text = "";
txtUserName.Text = "";
txtPassword.Text = "";
txtTo.Text = "";
txtSecurityAns.Text = "";
lblSecurityKey.Text = "";
}
protected void Button2_Click1(object sender, EventArgs e)
{
txtUid.Text = "";
txtUserName.Text = "";
txtPassword.Text = "";
txtTo.Text = "";
txtSecurityAns.Text = "";
lblSecurityKey.Text = "";
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
Send File:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using System.Text;
using System.Security.Cryptography;
using System.Net;
using System.Net.Mail;
txtuserid.Text = "";
txtReceivemail.Text = "";
txtFileDesc.Text = "";
}
}
}
protected void ddlreceiver_SelectedIndexChanged(object sender, EventArgs e)
{
txtReceivemail.Text = string.Empty;
cmd1 = new SqlCommand("Select * From UserDetails WHERE Userid = " +
ddlreceiver.SelectedItem.Text, con);
dr1 = cmd1.ExecuteReader();
if (dr1.HasRows)
{
while (dr1.Read())
{
txtReceivemail.Text =dr1.GetString(4);
}
}
dr1.Close();
}
}
Receive File:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using System.Text;
using System.Security.Cryptography;
public partial class Receivemsg : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd1;
SqlDataReader dr;
btnDecrypt.Visible = false;
String connectionString =
ConfigurationManager.ConnectionStrings["SECURE"].ConnectionString;
con = new SqlConnection(connectionString);
con.Open();
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
btnDecrypt.Visible = true;
lblEncryptedText.Text = string.Empty;
cmd1 = new SqlCommand("Select * From msgdetails WHERE securekey
='"+txtkey.Text+"' and receiverid = " + txtuserid.Text, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
lblEncryptedText.Text = dr.GetString(5);
dr.Close();
}
else
{
ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script
language='javascript'>alert(' Access Denined , Invaild Security Key')</script>");
}
}
protected void Decrypt(object sender, EventArgs e)
{
lblDecryptedText.Text = this.Decrypt(lblEncryptedText.Text.Trim());
}
}
}