@jay,
Hi ,
how to write the business logic codes for an application..i had send some sample coding...pls generate business logic codes for the code..and briefly explain that the business logic codes..
thanx....bye
karthik.k
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
jaya kumarPosted Feb 22, 2011, 12:55 AM
i given some example to handle Business logic and DataLayer.
Create two class files,like BL.cs and ProductProperties.cs
*to write all Business related functionality in BL.cs
to write code for Login verification (Login Button Click event)
protected void Login_click(object sender, EventArgs e)
{
// to set properties
ProductProperties Obj=new ProductProperties();
Obj.UserName=TextBox1.text;
Obj.Password=TextBox2.text;
//to create Object for BL.cs
BL ObjBL=new BL()
if(ObjBL.isvalid())
{
//login sucessfully...
}
else
{
invalid username or password...
}
}
----------------------------------------------------------------
public class ProductProperties
{
private string userName,Password;
public string UserName
{
set{userName=value;}
get{return userName;}
}
public string Password
{
set{password=value;}
get{return password;}
}
// to write like this for all needed variables..
}
----------------------------------------------------------------
public class BL
{
public BL()
{
//to establish the connection...
}
//to call DB using DataSet or ExecuteScalar
public boolen isvalid(ProductProperties Obj)
{
//to validate username and password using Querystring or StoredProcedure if valid hten return true else return false here am using storedProcedure.
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add("@loginID", SqlDbType.VarChar).Value = TextBox1.Text;//loginID-procedure first argument
cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = TextBox2.Text;//Password-procedure second argument
cmd = new SqlCommand("submitrecord", con);//submitrecord-stored procedure name
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
isValidUser=(cmd.ExecuteScalar().Hasrow)
con.Close()
return (isValidUser);
}
// to insert any data use ExecuteNonquery method..
public int newData(ProductProperties Obj)
{
return(row affected or not..)
}
//to display all datas use Dataset.
public Dataset Alldatas(ProductProperties Obj)
{
return (dataset);
}
}
Karthik KPosted Oct 26, 2012, 7:20 AM
Karthik KPosted Oct 26, 2012, 7:19 AM
By
karthik.k
Felipe RamosPosted Feb 21, 2011, 10:41 AM
-Customer
-Supplier
-Product
You could further extend that by have
CustomerCollection : List
SuppllierCollection : List
etc.
You will also need your data access class
CustomerDAL
SupplierDAL
ProductDAL
example of Customer in vb since your code is on vb