Click here to Skip to main content
15,868,016 members
Articles / Desktop Programming / Windows Forms

Multi User Contact Management System using Three Tier Architecture

Rate me:
Please Sign up or sign in to vote.
4.08/5 (18 votes)
1 Mar 2007CPOL3 min read 73.8K   2.3K   56   17
A Simple Multi User Contact Management System that will help programmers to use some tricks
Screenshot - multicontact.gif

Introduction

Life is like a connection of strings. We stitch each and every thread to make the small bits and bytes of our life. Now and then, we all like to keep in contact with our friends, families, colleagues, partners and least of all, our enemies.

From the very beginning, many people have discovered numerous ways to remember contacts. Some used brains, some used paper and pencil and some used computers to do this simple task. Many contact management software are available out in the net that you have already figured out what there will be in this project. But do not stop reading. You might find something useful.

I thought it would be nice to share some useful tricks and trade for developers. So, I came up with a very simple contact management program in C#. I started with the design, development and last of all, implementation.

Everyone likes to invent. Some people copy, some people use previous experience, some people like to start with something to get something out of something. I used all of them.

It is a way of many programmers to get things done quickly. But doing something quickly ends up in more and more debugging and more errors come out from all over the program.

I tried to show a simple way of getting things done in an easy and understandable way. For these, I have three kinds of classes:

1. Info Classes

These classes hold the general information and properties about the classes.

2. Data Access Classes

The Objects of these Classes deal with databases which use Info & Business Objects to do a specific work.

3. Business Classes

The objects of these classes define what Info Objects are supposed to do. Maybe Insert Some Data. It does not know how to deal with databases.

So, what's the point of making the above classes. The answer is to make like easier. There is a common sentence that is used is to KISS which means, Keep It Simple Stupid.

The basic thing is to define some info classes. Make a list of works that these can do and make some business classes and let the data classes define how to deal with the databases to set and get data.

Point of Interests

  • Using Business Objects/Data Access/User Interface Layer
  • Using the Reporting with parameter values
  • Implementing to restrict users from using the software for specified days
  • Sending Emails via POP

Interesting and Useful

Invoking a Business class to populate an ArrayList:

C#
public void PopulateContacts(ListView lvw, int contactType)
{
        lvw.Items.Clear();
        BusinessLayerContacts b = new BusinessLayerContacts();
        ArrayList al = new ArrayList();
        Contacts c = new Contacts();
        c.ContactType = contactType;
        c.UserID = this.UserID;
        al = b.GetContacts(c);lvw.Columns.Add("Name", 300);
        lvwChoosen.Columns.Add("Name", 300);
        for (int i = 0; i < al.Count; i++)
        {
               Contacts ct = new Contacts();
               ct.ID = ((Contacts)al[i]).ID;
               ct.Name = ((Contacts)al[i]).Name;
               ct.Telephone = ((Contacts)al[i]).Telephone;
               ct.UserID = this.UserID;
               ListViewItem lvi = new ListViewItem();
               lvi.Tag = ct.ID.ToString();
               lvi.Text = ct.Name;
               lvw.Items.Add(lvi);
        }
}

Sending Parameters to the Report

Many times, new programmers find difficulties to send parameters to the report or bind the report at runtime. Here is a way to do it.

C#
...

// instantiate the report
Envelope ex = new Envelope();

// Connect to Datasource at runtime
CrystalDecisions.CrystalReports.Engine.ReportDocument r = 
new CrystalDecisions.CrystalReports.Engine.ReportDocument();
TableLogOnInfo t = new TableLogOnInfo();
t.ConnectionInfo.ServerName = Application.StartupPath + "\\ZSContacts.mdb";
r.FileName = Application.StartupPath + "\\" + "Envelope.rpt";
r.Database.Tables[0].ApplyLogOnInfo(t);
            
// set datasource
ex.SetDataSource(dt);
            
// set report source
crvReport.ReportSource = r;
            
ex.VerifyDatabase();

// report has one discrete value
ParameterDiscreteValue d = new ParameterDiscreteValue();
d.Value = this.userid;
crvReport.ParameterFieldInfo["userid"].CurrentValues.Add(d);

// report has discrete with multiple values
ParameterValues currentParameterValues = new ParameterValues();
for (int i = 0; i < al.Count; i++)
{
    ParameterDiscreteValue dd = new ParameterDiscreteValue();
        dd.Value = ct.ID = ((Contacts)al[i]).ID; ;
        currentParameterValues.Add(dd);
}
crvReport.ParameterFieldInfo["contactId"].CurrentValues = currentParameterValues;

...

Implementing a Simple License Trick

Simple registry entry can help you do the licensing if you want to make your product run as a shareware.

C#
...
ArrayList al = new ArrayList();
al.Add("AV32 FGHG RE23 FGHT ASW34");
al.Add("AV32 FDFG RE23 FEHT ASW34");
al.Add("AV32 FFHH RE43 FFHT ASW34");
al.Add("AV32 FFHG RER3 FGHT ASW34");
al.Add("AVS2 FGSG RFD3 FFHT ASWD4");
bool registerd = false;
for (int i = 0; i < al.Count; i++)
{
    if (txtLicense.Text == al[i].ToString())
    {
        RegistryKey rk = 
         Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("ZakaSoft", true);
        if (rk == null)
        {
            RegistryKey main = Registry.LocalMachine.OpenSubKey("Software", true);
            RegistryKey x = main.CreateSubKey("ZakaSoft");
            x.SetValue("STATUS", txtName.Text);
        }
        else
        {
            rk.SetValue("STATUS", txtName.Text.ToString());
            MessageBox.Show("Thanks for Registering!");
            frm.btnRegister.Visible = false;
            frm.lblUsed.Text = "This Software is Registerd to " + txtName.Text;
            registerd = true;
            this.Dispose();
        }
        break;
    }
}
if (registerd == false)
{
    MessageBox.Show("License key not valid!");
    txtLicense.Focus();
}

...

Sending Emails from Application

Here is a small snippet on how to send emails from your application:

C#
...
using System.Net.Mail;
...
private void SendMail()
{
    MailAddress from = new MailAddress("sales@zakasoft.com");
    MailAddress to = new MailAddress("zakaria7@gmail.com");
    MailMessage message = new MailMessage(from, to);
    message.Subject = "Using the SmtpClient class.";
    message.Body = @"Using this feature, 
    you can send an e-mail message from an application very easily.";
    SmtpClient client = new SmtpClient("mail.zakasoft.com");
    System.Net.NetworkCredential basicAuthenticationInfo = 
    new System.Net.NetworkCredential("sales@zakasoft.com", "1234567");
    client.UseDefaultCredentials = false;
    client.Credentials = basicAuthenticationInfo;
    client.Send(message);
}

Conclusion

I hope you liked this very simple project. I emphasized on using some basic methods and tricks that will help you write and design useful software.

History

  • 1st March, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO FastBikri.com
Bangladesh Bangladesh
Zakaria has a keen interest in developing new solutions and exploring new technologies. He has a wide experience in web technologies and business solutions.

Visit my works @ https://play.google.com/store/apps/dev?id=8713255821916123360

His latest project includes Library Management System for University of Dhaka using ASP.NET and Sql Server.

Zakaria completed Masters in Information Technology from Institute of Information Technology http://iit.univdhaka.edu/,
University of Dhaka, had his BSc in Computer Science from AIUB (www.aiub.edu).
School and college from SKBZBIS (www.skbzbis.com)

Latest Project : www.alamgroupae.com
for Alam Group of Companies, Abu Dhabi

Some of his Completed projects:

www.zakasoft.com
www.musaffah.info
www.shonpapri.com
www.skbzbis.com
www.bdembuae.org (The official website of Embassy of the People's Republic of Bangladesh, Abu Dhabi, United Arab Emirates)

Bangla Translation of the Holy Quran (C#/Access)
Library Management System (ASP.NET/C#/SQLServer)
Seat Reservation System (ASP.NET/C#/SQLServer)

Besides programming, he has published his first poetry book (na bola kothamala/Unspoken Words) and in the process of writing several new novels.

Founded ZakaSoft, a division of ZCom, Providing state-of-the-art solutions in United Arab Emirates.

Zakaria Lives in Abu Dhabi and enjoys his spare time in writing and music.

Comments and Discussions

 
QuestionSpecific requerimineto quote compiled in 2022 Pin
Victor Figueroa 202230-Jun-22 8:10
Victor Figueroa 202230-Jun-22 8:10 
QuestionSpecific requerimineto quote compiled in 2022 Pin
Victor Figueroa 202230-Jun-22 8:10
Victor Figueroa 202230-Jun-22 8:10 
Questionrun Pin
Sanjay Kumawat21-Dec-12 0:47
Sanjay Kumawat21-Dec-12 0:47 
Questiondatabase is missing Pin
anuragblp18-Mar-12 2:46
anuragblp18-Mar-12 2:46 
can you send me database to my id lion.login@gmail.com
GeneralRe: database is missing Pin
D K PATEL24-Aug-12 6:46
D K PATEL24-Aug-12 6:46 
Questionthree tier architecture Pin
vivekanandhan8718-Mar-09 19:52
vivekanandhan8718-Mar-09 19:52 
GeneralLicence key... Pin
neelima devi10-Jan-09 10:37
neelima devi10-Jan-09 10:37 
GeneralRe: Licence key... Pin
Zakaria Bin Abdur Rouf10-Jan-09 19:26
Zakaria Bin Abdur Rouf10-Jan-09 19:26 
Generalurgent Pin
aman_mohali1-Oct-08 23:15
aman_mohali1-Oct-08 23:15 
GeneralRe Start Page Pin
saini485-May-07 2:01
saini485-May-07 2:01 
GeneralVB.Net Version Required Pin
Rizwan Tahir17-Apr-07 4:10
Rizwan Tahir17-Apr-07 4:10 
QuestionReg: Update option in grid Pin
a_anand_kumar3-Apr-07 22:17
a_anand_kumar3-Apr-07 22:17 
AnswerRe: Reg: Update option in grid Pin
Zakaria Bin Abdur Rouf4-Apr-07 4:30
Zakaria Bin Abdur Rouf4-Apr-07 4:30 
QuestionRe: Reg: Update option in grid Pin
a_anand_kumar4-Apr-07 5:16
a_anand_kumar4-Apr-07 5:16 
GeneralAmazing and Full example! Pin
OneSoftware8-Mar-07 16:13
OneSoftware8-Mar-07 16:13 
Generalgood work body Pin
Pali.Sniper7-Mar-07 21:48
Pali.Sniper7-Mar-07 21:48 
GeneralRe: good work body Pin
Zakaria Bin Abdur Rouf7-Mar-07 22:21
Zakaria Bin Abdur Rouf7-Mar-07 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.