0% found this document useful (0 votes)
15 views15 pages

Source Code

The document contains code for an admin login page, adding new officers, user registration, adding flood reports, sending feedback, and viewing flood and fund details. The code connects to a database, inserts and selects data, handles file uploads, and sends emails.

Uploaded by

Gayatri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views15 pages

Source Code

The document contains code for an admin login page, adding new officers, user registration, adding flood reports, sending feedback, and viewing flood and fund details. The code connects to a database, inserts and selects data, handles file uploads, and sends emails.

Uploaded by

Gayatri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

SOURCE CODE

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.Data;

public partial class Admin : System.Web.UI.Page


{
public SqlConnection con;
public SqlCommand cmd;
public SqlDataReader dr;

public String id, lid, lpass;

protected void Page_Load(object sender, EventArgs e)


{

}
protected void Button1_Click(object sender, EventArgs e)
{
DatabaseConnect dcc = new DatabaseConnect();
con = dcc.connection();
cmd = new SqlCommand("select * from admin where lid='" + TextBox1.Text + "' and
lpass='" + TextBox2.Text + "'", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
id = dr["id"].ToString();
lid = dr["lid"].ToString();
lpass = dr["lpass"].ToString();

if (TextBox1.Text == lid && TextBox2.Text == lpass)


{

Session["id"] = id;
Session["lid"] = lid;
Session["lpass"] = lpass;

Response.Redirect("AHome.aspx");
}
else
{
//Label1.Text = "UserName OR Password Incorrect";
Response.Write("<script>alert('UserName OR Password Incorrect')</script>");
TextBox1.Text = "";
TextBox2.Text = "";

con.Close();
}
}
}
}

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.Text;
using System.Net;
using System.Net.Mail;

public partial class ANew_Officier : System.Web.UI.Page


{
public SqlConnection con;
public SqlCommand cmd;
public SqlDataReader dr;

string mailid = "[email protected]";


string pwd = "immaslm2021";
string to, subject = "Secret Key", message;
protected void Page_Load(object sender, EventArgs e)
{

}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
//con.Close();
DatabaseConnect dcc = new DatabaseConnect();
con = dcc.connection();

if (e.CommandName == "Select")
{
int x = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[x];
string email = row.Cells[2].Text;

Random rm = new Random();


int rno = rm.Next(11111, 99999);

byte[] getstring = Encoding.ASCII.GetBytes(rno.ToString());


string enckey = Convert.ToBase64String(getstring);

//con.Open();
SqlCommand cmd = new SqlCommand("update officer set status = 'YES',lpass = '" +
enckey + "' where email = '" + email + "' ", con);
cmd.ExecuteNonQuery();
con.Close();

mailSend(email, enckey);

Response.Redirect("ANew_Officier.aspx");
}

private void mailSend(string tomail, string seki)


{
try
{
to = tomail;

message = "<hr><br>" + "Secret Key:" + seki + "<br><br>";


NetworkCredential loginInformation = new NetworkCredential(mailid, pwd);
MailMessage msg = new MailMessage();
msg.From = new MailAddress(mailid);
msg.To.Add(new MailAddress(to));
msg.Subject = subject;
msg.Body = message;
msg.IsBodyHtml = true;

SmtpClient client = new SmtpClient();


client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInformation;
client.Send(msg);
}
catch { }
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;
using System.Data;
using System.IO;
using System.Data.SqlClient;
public partial class Newuser : System.Web.UI.Page
{
public SqlConnection con;
public SqlCommand cmd;
public SqlDataReader dr;

protected void Page_Load(object sender, EventArgs e)


{
Label2.Text = DateTime.Now.ToString();

}
protected void Button1_Click(object sender, EventArgs e)
{
DatabaseConnect dcc = new DatabaseConnect();
con = dcc.connection();

string strfilepath = Path.GetFileName(FileUpload1.PostedFile.FileName.ToString());


FileUpload1.SaveAs(Server.MapPath(@"~/Profile/User/" + strfilepath));

cmd = new SqlCommand("insert into User_reg values('" + TextBox1.Text + "','" +


DropDownList1.SelectedValue + "','" + TextBox2.Text + "','" + TextBox3.Text +
"','"+TextBox5.Text+"','" + DropDownList2.SelectedValue + "','" + TextBox4.Text + "','" +
"~/Profile/User/" + strfilepath + "','" + Label2.Text + "') ", con);
cmd.ExecuteNonQuery();
con.Close();

Label1.Visible = true;
Label2.Visible = false;

Response.Write("<script>alert('User Registration Successful!.')</script>");

Response.Redirect("User.aspx");

}
}
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.IO;
using System.Data.SqlClient;

public partial class OAddFloodReport : System.Web.UI.Page


{
public SqlConnection con;
public SqlCommand cmd;
public SqlDataReader dr;

protected void Page_Load(object sender, EventArgs e)


{
string date = DateTime.UtcNow.ToString("dd-MM-yyy");

}
protected void Button1_Click(object sender, EventArgs e)
{
DatabaseConnect dcc = new DatabaseConnect();
con = dcc.connection();

string[] validFileTypes = { "txt", "docx", "xls", "pdf" };


string ext = System.IO.Path.GetExtension(FileUpload2.PostedFile.FileName);

string strfilepath = Path.GetFileName(FileUpload2.PostedFile.FileName.ToString());

string mypath = Server.MapPath(@"~/Report/" + strfilepath);


FileUpload2.PostedFile.SaveAs(mypath);

string strfilepath1 = Path.GetFileName(FileUpload1.PostedFile.FileName.ToString());


FileUpload1.SaveAs(Server.MapPath(@"~/Profile/Officer/" + strfilepath1));

cmd = new SqlCommand("insert into flood values('" + DropDownList1.SelectedValue +


"','" + TextBox1.Text + "','" + TextBox2.Text + "','" + DropDownList2.Text + "','" +
TextBox3.Text + "','" + DropDownList3.SelectedValue + "','" + TextBox4.Text + "','" +
"~/Profile/Officer/" + strfilepath1 + "','" + "~/Report/" + strfilepath + "','" + TextBox5.Text + "','"
+ TextBox6.Text + "','" + TextBox7.Text + "','','','','','') ", con);
cmd.ExecuteNonQuery();
Label1.Visible = true;
Label2.Visible = false;
// Label1.Text = "Successfully Uploaded....";
Response.Write("<script>alert('Details Added Successfully!...')</script>");

}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox6.Visible = true;

TextBox6.Text = Calendar1.SelectedDate.ToShortDateString();
}
}
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.IO;
using System.Data.SqlClient;

public partial class USendFeedback : System.Web.UI.Page


{
public SqlConnection con;
public SqlCommand cmd;
public SqlDataReader dr;

protected void Page_Load(object sender, EventArgs e)


{
Label1.Text = Session["uname"].ToString();
Label2.Text = Session["uid"].ToString();
// Label3.Text = Session["email"].ToString();
Label4.Text = DateTime.Now.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
DatabaseConnect dcc = new DatabaseConnect();
con = dcc.connection();
cmd = new SqlCommand("insert into feedback values('" + Label2.Text + "','" + Label1.Text
+ "','" + TextBox1.Text + "','" + Label4.Text + "') ", con);
cmd.ExecuteNonQuery();
con.Close();

Response.Write("<script>alert('Feedback Send Successfull !....')</script>");


TextBox1.Text = "";

}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UViewFlood : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("USendFeedback.aspx");
}
}
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.IO;
using System.Data.SqlClient;

public partial class UViewFundDetails : System.Web.UI.Page


{
public SqlConnection con;
public SqlCommand cmd;
public SqlDataReader dr;

protected void Page_Load(object sender, EventArgs e)


{
Label1.Text = Session["uname"].ToString();
Label2.Text = Session["uid"].ToString();
Label3.Text = Session["email"].ToString();
Label4.Text = DateTime.Now.ToString();

}
protected void Button1_Click(object sender, EventArgs e)
{
DatabaseConnect dcc = new DatabaseConnect();
con = dcc.connection();
cmd = new SqlCommand("insert into flood_fund values('" + Label2.Text + "','" +
Label1.Text + "','" + Label3.Text + "','" + DropDownList1.SelectedValue + "','" +
DropDownList2.SelectedValue + "','" + TextBox1.Text + "','" + TextBox2.Text + "','" +
TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" +
Label4.Text + "') ", con);
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script>alert('Fund Transfered!....')</script>");

}
}

You might also like