Vous êtes sur la page 1sur 7

Coding: Introduction: For Menu (Sitemap coding)

<?xml version="1.0" encoding="utf-8" ?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode title="Menu" description=""> <siteMapNode url="~/Introduction.aspx" title="Home" description="" /> <siteMapNode url="~/AboutUs.aspx" title="About us" description="" /> <siteMapNode url="~/ContactUs.aspx" title="Contact Us" description="" /> </siteMapNode> </siteMap>

Database Connection Coding:


In Web.config file:
<connectionStrings> <add name="MyAccessDBConnection" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=&quot; C:\Users\Azhar\Desktop\EyebankProject\EBdb.mdb&quot;" providerName="System.Data.OleDb" /> </connectionStrings>

In Class file:
using using using using using using using using System.Configuration; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Web.UI.HtmlControls; System.Data.OleDb;

public class DBcon { public static OleDbConnection getdata() { string connectionstring = ConfigurationManager.ConnectionStrings["MyAccessDBConnection"].Connecti onString; OleDbConnection connection = new OleDbConnection(connectionstring); return connection; } }

Database Structure:
Database Name: EBdb (Eye bank database) Table1: DrRegtab (Donor Registration table)

Table2: OrRegtab (Organization Registration table)

Table3: RpRegtab (Recipient Registration table)

Donor Module:

using using using using using using using using using using using

System; System.Data; System.Configuration; System.Collections; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Web.UI.HtmlControls; System.Data.OleDb;

public partial class DonorReg : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { rlabel.Text = ""; } protected void Button1_Click(object sender, EventArgs e) { string insertSQL; insertSQL = "INSERT INTO DrRegtab ("; insertSQL += "Fname, Lname,Age,Sex,DOB,Address,RAddress,MNumber,LLNumber,BGroup,Email,MHProb lem,RPath,Passwrd,CPass)"; insertSQL += "VALUES (@Fname,@Lname,Age,@Sex,@DOB,@Address,@RAddress,MNumber,LLNumber,@BGrou p,@Email,@MHProblem,@RPath,@Passwrd,@CPass)"; OleDbConnection con = DBcon.getdata(); OleDbCommand cmd = new OleDbCommand(insertSQL, con); cmd.Parameters.AddWithValue("@Fname", Fname.Text); cmd.Parameters.AddWithValue("@Lname", LName.Text); cmd.Parameters.AddWithValue("@Age", Agetb.Text); cmd.Parameters.AddWithValue("@Sex", sextb.Text); cmd.Parameters.AddWithValue("@DOB", Dobtb.Text); cmd.Parameters.AddWithValue("@Address", Addtb.Text); cmd.Parameters.AddWithValue("@RAddress", RAddtb.Text); cmd.Parameters.AddWithValue("@MNumber", Mobtb.Text); cmd.Parameters.AddWithValue("@LLNumber", Lltb.Text); cmd.Parameters.AddWithValue("@BGroup", Bgtb.Text); cmd.Parameters.AddWithValue("@Email", Midtb.Text); cmd.Parameters.AddWithValue("@MHProblem", hptb.Text); cmd.Parameters.AddWithValue("@RPath", "~/MedicalReports/" + Repup.FileName); cmd.Parameters.AddWithValue("@Passwrd", passtb.Text); cmd.Parameters.AddWithValue("@Cpass", cpasstb.Text);

string filePath = Server.MapPath("~/MedicalReports/" + Repup.FileName); Repup.SaveAs(filePath); try {

con.Open(); cmd.ExecuteNonQuery(); rlabel.Text = "Your details has been successfully registered."; Fname.Text = ""; LName.Text = ""; Agetb.Text = ""; sextb.Text = ""; Dobtb.Text = ""; Addtb.Text = ""; RAddtb.Text = ""; Mobtb.Text = ""; Lltb.Text = ""; Bgtb.Text = ""; Midtb.Text = ""; hptb.Text = ""; passtb.Text = ""; cpasstb.Text = "";

} catch (OleDbException) { rlabel.Text = "Registration failed."; } finally { con.Close(); } } }

Recipient Module:
using using using using using using using using using using using System; System.Data; System.Configuration; System.Collections; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Web.UI.HtmlControls; System.Data.OleDb;

public partial class RecepReg : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e)

string insertSQL; insertSQL = "INSERT INTO RpRegtab ("; insertSQL += "Fname, Lname,Age,Sex,DOB,Address,RAddress,MNumber,LLNumber,BGroup,Email,Passwr d,Cpass)"; insertSQL += "VALUES (@Fname,@Lname,@Age,@Sex,@DOB,@Address,@RAddress,@MNumber,@LLNumber,@BG roup,@Email,@Passwrd,@Cpass)"; OleDbConnection con = DBcon.getdata(); OleDbCommand cmd = new OleDbCommand(insertSQL, con); cmd.Parameters.AddWithValue("@Fname", Fname.Text); cmd.Parameters.AddWithValue("@Lname", LName.Text); cmd.Parameters.AddWithValue("@Age", Agetb.Text); cmd.Parameters.AddWithValue("@Sex", sextb.Text); cmd.Parameters.AddWithValue("@DOB", Dobtb.Text); cmd.Parameters.AddWithValue("@Address", Addtb.Text); cmd.Parameters.AddWithValue("@RAddress", RAddtb.Text); cmd.Parameters.AddWithValue("@MNumber", Mobtb.Text); cmd.Parameters.AddWithValue("@LLNumber", Lltb.Text); cmd.Parameters.AddWithValue("@BGroup", Bgtb.Text); cmd.Parameters.AddWithValue("@Email", Midtb.Text); cmd.Parameters.AddWithValue("@Passwrd", passtb.Text); cmd.Parameters.AddWithValue("@CPass", cpasstb.Text); try { con.Open(); cmd.ExecuteNonQuery(); rlabel.Text = "Your details has been successfully registered."; Fname.Text = ""; LName.Text = ""; Agetb.Text = ""; sextb.Text = ""; Dobtb.Text = ""; Addtb.Text = ""; RAddtb.Text = ""; Mobtb.Text = ""; Lltb.Text = ""; Bgtb.Text = ""; Midtb.Text = ""; passtb.Text = ""; cpasstb.Text = ""; } catch (OleDbException) { rlabel.Text = "Registration failed."; } finally { con.Close(); } } }

Recipient Module:

using using using using using using using using using using using

System; System.Data; System.Configuration; System.Collections; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Web.UI.HtmlControls; System.Data.OleDb;

public partial class OrgReg : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string insertSQL; insertSQL = "INSERT INTO OrRegtab ("; insertSQL += "OName,OType,OAddress,OMailid,OCNumber,Passwrd,CPass)"; insertSQL += "VALUES (@OName,@OType,@OAddress,@OMailid,@OCNumber,@Passwrd,@CPass)"; OleDbConnection con = DBcon.getdata(); OleDbCommand cmd = new OleDbCommand(insertSQL, con); cmd.Parameters.AddWithValue("@OName", Nametb.Text); cmd.Parameters.AddWithValue("@OType", Typeddlb.Text); cmd.Parameters.AddWithValue("@OAddress", Addressmltb.Text); cmd.Parameters.AddWithValue("@OMailid", mailidtb.Text); cmd.Parameters.AddWithValue("@OCNumber", contacttb.Text); cmd.Parameters.AddWithValue("@Passwrd", passtb.Text); cmd.Parameters.AddWithValue("@CPass", cpasstb.Text); try { con.Open(); cmd.ExecuteNonQuery(); rlabel.Text = "Your details has been successfully registered."; Nametb.Text = ""; Typeddlb.Text = ""; Addressmltb.Text = ""; mailidtb.Text = ""; contacttb.Text = ""; passtb.Text = ""; cpasstb.Text = ""; } catch (OleDbException) { rlabel.Text = "Registration failed.";

} }

} finally { con.Close(); }