1.
UI LAYER
using
System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
public partial class Register : System.Web.UI.Page
{
BAL businesslayer
= new BAL();
DALlayer.Datalogic
objectdata = new DALlayer.Datalogic();
BALlayer.Businesslogic
objectBAL = new BALlayer.Businesslogic();
protected void Page_Load(object sender, EventArgs e)
{
if (!(IsPostBack))
{
}
}
protected void Button1_Click(object
sender, EventArgs
e)
{
int result;
objectBAL.LUSER_ID = TextBox1.Text;
objectBAL.LPASSWORD
= TextBox2.Text;
result = objectdata.login(objectBAL);
if
(result == 0)
{
objectBAL.RUSER_ID
= TextBox1.Text;
objectBAL.RUSERPASSWORD
= TextBox2.Text;
objectBAL.REMAIL
= TextBox3.Text;
objectdata.insertdata(objectBAL);
Response.Redirect("userlogin.aspx");
}
else
{
Label6.Text = "Already Registered";
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
}
}
2. BUSINESS LOGIC LAYER
using
System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
/// <summary>
/// Summary description for BAL
/// </summary>
public class BAL
{
DAL datalayer = new DAL();
int
tot=0;
public int insertdata(string USER_ID,string UPWD, string
EMAIL)
{
datalayer.insertdata(USER_ID,
UPWD, EMAIL);
return
tot;
}
public int inserttrans(string DetailsName, string DataTime, string MoneyTO, string MoneyFrom, string USER_ID)
{
datalayer.inserttrans(
DetailsName, DataTime, MoneyTO, MoneyFrom, USER_ID);
return
tot;
}
public int insertproject(string USER_ID, string
ProjectName, string TableName, string DataTime)
{
datalayer.insertproject(USER_ID,
ProjectName, TableName, DataTime);
return
tot;
}
public int insertcomdetails(string Name,string Phone,string Mobile,string Address,string Email,
string WebSite,string contactType,string Location,string USER_ID)
{
datalayer.insertcomdetails(Name,
Phone, Mobile, Address, Email, WebSite, contactType, Location, USER_ID);
return
tot;
}
public
BAL()
{
//
// TODO:
Add constructor logic here
//
}
public void Insert(persion persion)
{
DAL pDAL = new DAL();
try
{
// return pDAL.insert(persion);
pDAL.insert(persion);
}
catch
{
throw;
}
finally
{
pDAL = null;
}
}
}
3. DATA LAYER
using
System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;
using
System.IO;
using System.Drawing;
using System.ComponentModel;
using System.Web.UI.HtmlControls;
using System.Web.SessionState;
using Microsoft.VisualBasic;
using System.Collections;
using System.Diagnostics;
using System.Xml;
using System.Text;
using System.Security.Cryptography;
using System.Data.SqlClient;
/// <summary>
/// Summary description for DAL
/// </summary>
public class DAL
{
OleDbConnection
con;
OleDbCommand cmd;
SqlCommand com;
OleDbDataAdapter da;
DataSet ds = new DataSet();
int
mums;
private byte[] key = {
};
private byte[] IV = {
0x12,
0x34,
0x56,
0x78,
0x90,
0xab,
0xcd,
0xef
};
//sathish
SqlConnection
cons = new SqlConnection("Data Source=.; Initial Catalog=onlinedoc;Integrated
Security=True");
int
tot = 0;
public int insertdata(string USER_ID, string
UPWD, string EMAIL)
{
cons.Open();
com = new
SqlCommand("sp_userlogin", cons);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("USER_ID", USER_ID);
com.Parameters.AddWithValue("UPWD", UPWD);
com.Parameters.AddWithValue("EMAIL", EMAIL);
com.ExecuteNonQuery();
return tot;
}
public int inserttrans(string DetailsName, string DataTime, string MoneyTO, string MoneyFrom, string USER_ID)
{
cons.Open();
com = new
SqlCommand("sp_transaction", cons);
com.CommandType
= CommandType.StoredProcedure;
com.Parameters.AddWithValue("DetailsName",
DetailsName);
com.Parameters.AddWithValue("DataTime", DataTime);
com.Parameters.AddWithValue("MoneyTO", MoneyTO);
com.Parameters.AddWithValue("MoneyFrom", MoneyFrom);
com.Parameters.AddWithValue("USER_ID", USER_ID);
com.ExecuteNonQuery();
return
tot;
}
public int insertproject(string USER_ID, string
ProjectName, string TableName, string DataTime)
{
cons.Open();
com = new
SqlCommand("sp_project", cons);
com.CommandType
= CommandType.StoredProcedure;
com.Parameters.AddWithValue("USER_ID", USER_ID);
com.Parameters.AddWithValue("ProjectName",
ProjectName);
com.Parameters.AddWithValue("TableName", TableName);
com.Parameters.AddWithValue("DataTime", DataTime);
com.ExecuteNonQuery();
return
tot;
}
public int insertcomdetails(string Name, string
Phone, string Mobile, string
Address, string Email,
string WebSite, string contactType, string Location, string
USER_ID)
{
cons.Open();
com = new
SqlCommand("sp_comdetails", cons);
com.CommandType
= CommandType.StoredProcedure;
com.Parameters.AddWithValue("Name", Name);
com.Parameters.AddWithValue("Phone", Phone);
com.Parameters.AddWithValue("Mobile", Mobile);
com.Parameters.AddWithValue("Address", Address);
com.Parameters.AddWithValue("Email", Email);
com.Parameters.AddWithValue("WebSite", WebSite);
com.Parameters.AddWithValue("contactType",
contactType);
com.Parameters.AddWithValue("Location", Location);
com.Parameters.AddWithValue("USER_ID", USER_ID);
com.ExecuteNonQuery();
return
tot;
}
//
public string encryptQueryString(string strQueryString)
{
DAL oES = new DAL();
return oES.Encrypt(strQueryString, "!#$a54?3");
}
public string decryptQueryString(string strQueryString)
{
DAL oES = new DAL();
return oES.Decrypt(strQueryString, "!#$a54?3");
}
public string left(string skey, int
ikey)
{
return skey;
}
public string Decrypt(string
stringToDecrypt, string
sEncryptionKey)
{
byte[] inputByteArray = new byte[stringToDecrypt.Length
+ 1];
try
{
//key =
System.Text.Encoding.UTF8.GetBytes(Left(sEncryptionKey,
8));
key = System.Text.Encoding.UTF8.GetBytes(left(sEncryptionKey,
8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray
= Convert.FromBase64String(stringToDecrypt);
MemoryStream ms = new
MemoryStream();
CryptoStream cs =
new CryptoStream(ms,
des.CreateDecryptor(key, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
return
encoding.GetString(ms.ToArray());
}
catch (Exception e)
{
return
e.Message;
}
}
public string Encrypt(string
stringToEncrypt, string
SEncryptionKey)
{
try
{
key = System.Text.Encoding.UTF8.GetBytes(left(SEncryptionKey,
8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[]
inputByteArray = Encoding.UTF8.GetBytes(stringToEncrypt);
MemoryStream ms = new
MemoryStream();
CryptoStream cs =
new CryptoStream(ms,
des.CreateEncryptor(key, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return
Convert.ToBase64String(ms.ToArray());
}
catch (Exception e)
{
return
e.Message;
}
}
//Method for
storing image
public int saveDB(string imgname, byte[] imgbin, string imgcontenttype, string userid, string title, string photoname)
{
con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\web.mdb");
con.Open();
OleDbCommand
command = new OleDbCommand("insert into gallery_details(imgname,imgfile,imgtype,user_id,title,photoname) values (@img_name,@img_file,@img_type,@userid,@title,@photoname)",
con);
OleDbParameter
param0 = new OleDbParameter("@img_name", OleDbType.VarChar, 30);
param0.Value = imgname;
command.Parameters.Add(param0);
OleDbParameter
param1 = new OleDbParameter("@img_file", OleDbType.Binary);
param1.Value = imgbin;
command.Parameters.Add(param1);
OleDbParameter
param2 = new OleDbParameter("@img_type", OleDbType.VarChar, 30);
param2.Value = imgcontenttype;
command.Parameters.Add(param2);
OleDbParameter
param3 = new OleDbParameter("@userid", OleDbType.VarChar, 30);
param3.Value = userid;
command.Parameters.Add(param3);
OleDbParameter
param4 = new OleDbParameter("@title", OleDbType.VarChar,
30);
param4.Value = title;
command.Parameters.Add(param4);
OleDbParameter
param5 = new OleDbParameter("@photoname", OleDbType.VarChar, 30);
param5.Value = photoname;
command.Parameters.Add(param5);
//con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\web.mdb");
//con.Open();
int num = command.ExecuteNonQuery();
con.Close();
return
mums;
}
public void insert(persion persion)
{
string iname = persion.imgname;
byte[] ibin = persion.imgbin;
string
type = persion.imgcontenttype;
string uid = persion.userid;
string
tit = persion.title;
string pname = persion.photoname;
int result = saveDB(iname, ibin, type, uid, tit, pname);
}
public void addimage(string imgname, byte[] imgbin, string imgcontenttype, string userid, string title, string photoname)
{
int result = saveDB(imgname, imgbin, imgcontenttype, userid, title, photoname);
}
public
DAL()
{
//
// TODO: Add
constructor logic here
//
}
}
//Application["MyArray"] = new string[] { "help",
"me", "make", "an", "array" };
//// get
value back from Array
//string[]
myArray = Application["MyArray"]
as string[];
public class X : DAL
{
// Interface
examples
// What is an Interface?
//An interface is
defined by the key word interface. An interface has no implementation;
//it only has the
definition of the methods without the body. When we create an interface,
//we are
basically creating a set of methods without any implementation. A class implementing
an interface must provide the implementation of the interface members. All the
methods and properties defined in an interface are by default public and
abstract.
public interface IExample
{
void SomeMethod();
}
public class Whatever : IExample
{
public void SomeMethod()
{
int i = 0;
}
}
//**********************
//virtual signals
that it can be overridden via the override keyword
public virtual void A()
{
}
public void B()
{
}
//overloaded
methods
public void B(int
x)
{
}
//public override
void C()
//{
//}
//overrides a
base class method defined as
//public virtual
void C()
//{
//}
//Abstract class
// Abstract classes are Classes which cannot
be instantiated. This means one
//cannot make a
object of this class or in other way cannot create object by
//saying ClassAbs abs = new ClassAbs();
where ClassAbs is abstract class.
//Abstarct classes contains have one or more abstarct methods, ie method
//body only no
implementation.
// What is an Abstract class?
//An abstract
class only allows other classes to inherit from it and cannot
//be
instantiated. When we create an abstract class, it should have one or more
//completed
methods but at least one or more uncompleted methods and these must be preceded
by the key word abstract. If all the methods of an abstract class are
uncompleted then it is the same as an interface, but there is a restriction
that it cannot make a class inherit from it, which means it can
not work as a base class.
public abstract class EmployeeSalary
{
public abstract decimal
Salary
{
get;
}
public string Company
{
get
{
return
"FirstSource
Solutions";
}
}
public string Location
{
get
{
return
"RMZ";
}
}
}
public class SalesClass1
: EmployeeSalary
{
public override decimal
Salary
{
get
{
return
50000.23m;
}
}
}
}
No comments:
Post a Comment