window application in 3 tier Architecture


Posted Date:     Total Responses: 0    Posted By: raj kumar sahu   Member Level: Silver   Points/Cash: 8   


How to make project in .net 3 tier architecture

Step1 > Make a blank solution by New?project?Other Project Type?Visual Studio Solution?Blank
Solution. Then provide eg, Name :- test
Location:-d:

Step2> Go to the location you will found that there is a folder test and when you double click on it you
Will find test solution. Then add two new folder function and application
Function:- folder will contain class library and .dll
Application;- folder will contain web form or window form and so on..

Step3> Go to studio Solution Explorer and add three class library
Solution(R-Click)?Add?New Project
Language?c#
Templates?Class Library
Location?d:\test\function
Name of class library are BOclass, BALclass, DALclass

Step4> Go to studio Solution Explorer and add window form
Solution(R-Click)?Add?New Project
Language?c#
Templates?form
Location?d:\test\application
Name?testform

Step5>Build each project BOclass,BALclass,DALclass,testform

Step6>BALclass(R-Click)?Addrefference?Project {BOclass,DALclass}

Step7>DALclass(R-Click)?Addrefference?Project {BOclass,DALclass}

Step8>testform(R-Click)?Addrefference?Project {BOclass,BALclass,DALclass}
Step9>Build Solution
Step10>Add app.config for database access
now there is code for boclass,balclass,dalclass,windowform

App.config







BOclass

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BOclass
{
public class boaddclient
{
public string c_name { get; set; }
public string c_add { get; set; }
public string c_mobile { get; set; }
}
}

DALclass

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using BOclass;

namespace DALclass
{
public class daladdclient
{
public int dalclient(boaddclient boinfo)
{
string str = ConfigurationSettings.AppSettings["mycon"];
OleDbConnection con = new OleDbConnection(str);
string qry = "insert into client(c_name,c_address,c_mobileno) values('" + boinfo.c_name + "','" + boinfo.c_add + "','" + boinfo.c_mobile + "')";
//string qry1="select count(*) from client where c_name='"+boinfo.c_name+"' and c_mobileno='"+boinfo.c_mobile+"'";
//string qry2 = "select c_id from client where c_name='" + boinfo.c_name + "' and c_mobileno='" + boinfo.c_mobile + "'";
OleDbCommand cmd = new OleDbCommand(qry, con);
//OleDbCommand cmd1 = new OleDbCommand(qry1, con);
//OleDbCommand cmd2 = new OleDbCommand(qry2, con);
try
{
con.Open();
//int rt1 =Convert.ToInt32( cmd1.ExecuteScalar());
//if (rt1 > 0)
//{
// int rt2=Convert.ToInt32(cmd2.ExecuteScalar());
// return rt2;
//}
//else
//{
int rt = cmd.ExecuteNonQuery();
return rt;
//}

}
catch
{
throw;
}
finally
{
con.Close();
con.Dispose();
}
}
}
}



BALclass

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BOclass;
using DALclass;


namespace BALclass
{
public class baladdclient
{
public int balclient(boaddclient boinfo)
{
daladdclient dalinfo = new daladdclient();
return dalinfo.dalclient(boinfo);
}
}
}

Testform.cs(Design)

savebtn and close btn


Testform.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BOclass;
using BALclass;
using DALclass;

namespace digital
{
public partial class client : Form
{
public client()
{
InitializeComponent();
}

private void btnclose_Click(object sender, EventArgs e)
{
foreach (Form f in Application.OpenForms)
{
if (f.GetType() == typeof(newsale))
{
f.Activate();
return;
}
}
Form newform = new newsale();
newform.MdiParent = this.MdiParent;
newform.Dock = DockStyle.Fill;
newform.Show();
newform.Focus();
this.Close();
}

private void btnsave_Click(object sender, EventArgs e)
{
if (txtcname.Text.Trim().Length == 0)
{
MessageBox.Show("Enter Client name....");
}
else if (txtcaddress.Text.Trim().Length == 0)
{
MessageBox.Show("Enter Client address....");

}
else if (txtcmobile.Text.Trim().Length == 0)
{
MessageBox.Show("Enter Client Mobile no....");

}
else
{
try
{
baladdclient balinfo = new baladdclient();
boaddclient boinfo = new boaddclient();
boinfo.c_name = txtcname.Text.Trim();
boinfo.c_add = txtcaddress.Text.Trim();
boinfo.c_mobile = txtcmobile.Text.Trim();
int rt = balinfo.balclient(boinfo);
if (rt > 0)
{
MessageBox.Show("Client Inserted Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtcname.Text = ""; txtcaddress.Text = ""; txtcmobile.Text = "";

}
else
{
MessageBox.Show("Some Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

}
catch (Exception p)
{
MessageBox.Show(p.Message.ToString());
}

}
}

private void mobile_keypress(object sender, KeyPressEventArgs e)
{
char ch = e.KeyChar;

if (!char.IsDigit(ch) && ch != 8)
{
e.Handled = true;
}
}


}
}







Project Feedbacks

Author: Member Level: BronzeRevenue Score: 2 out of 52 out of 5
Sir please send me attachment and document,where is the attachment
my mail ID mukkamula.ashokkumar@gmail.com


Author: Member Level: BronzeRevenue Score: 5 out of 55 out of 55 out of 55 out of 55 out of 5
Let me first introduce i am student of Msc(ca & it) at k.skv kutch university,bhuj-kutch,we have no enough faculty so i need your help for vb.net.
i am using dev express control for windows based application,Generally we do programming by click and load event of any control but now i want to do programming as 3 tier architecture
create one class file in vb.net and do coding in class file and create function in class file and do programming in function and in click or load event only,so reduce reusability,but i dont know that what is actually 3 tier architecture so pls guide me about that.


in dev express we take dev express form but there are one other item that dev express user control v8.3 what is use for windows based system.?
what is use of try catch finally?
what is use of set get property?

i use back end as a sql server 2005

thanks


Author: Member Level: BronzeRevenue Score: 1 out of 5
where is the attachment


Author: Member Level: BronzeRevenue Score: 2 out of 52 out of 5
sir could you please send the attachment......to my mail id ...Xavier were@gmail.com..............thnx in advance...



Author: Member Level: BronzeRevenue Score: Revenue Score: 0



rps.rar
Author: Member Level: BronzeRevenue Score: 3 out of 53 out of 53 out of 5
Its a very worst explanation... its not absolutly for freshers... no naming conventions.. no clarity in the explanation..

Please take care in the next post .. that will be save energy and time for the freshers..

Many thanks,
KPR


Author: Member Level: BronzeRevenue Score: 3 out of 53 out of 53 out of 5
Hi I am new in windows application in C#. so kindly provide me this application because it should be really very helpful for me to learn about how windows application development actually has.............my email id is llsuvedll@gmail.com


Author: Member Level: BronzeRevenue Score: 1 out of 5
plz attached the file



Author: Member Level: SilverRevenue Score: 1 out of 5
where is the attachement code .. attach it na


Author: Member Level: GoldRevenue Score: 2 out of 52 out of 5
hi,
Your Project Was Very good.ican understand it very clearly.but ihav a sugession,that is please improve your project design.
Thanks and Regards
Sivasreenath



Post Feedback
You must Sign In to post a feedback.
Next Project: Simple Admission Form
Previous Project: online examination system

Return to Project Index

Post New Project


Related Projects


Top Contributors
Today
    Last 7 Daysmore...

    Awards & Gifts
     
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India