Click here to Skip to main content
Click here to Skip to main content

Multi User Contact Management System using Three Tier Architecture

, 1 Mar 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
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:

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.

...

// 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.

...
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:

...
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)

Share

About the Author

Zakaria Bin Abdur Rouf
Web Developer
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.
 
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

 
Questionrun PinmemberSanjay Kumawat21-Dec-12 1:47 
Questiondatabase is missing Pinmemberanuragblp18-Mar-12 3:46 
GeneralRe: database is missing PinmemberD K PATEL24-Aug-12 7:46 
Questionthree tier architecture Pinmembervivekanandhan8718-Mar-09 20:52 
GeneralLicence key... Pinmemberneelima devi10-Jan-09 11:37 
GeneralRe: Licence key... PinmemberZakaria Bin Abdur Rouf10-Jan-09 20:26 
Generalurgent Pinmemberaman_mohali2-Oct-08 0:15 
GeneralRe Start Page Pinmembersaini485-May-07 3:01 
GeneralVB.Net Version Required PinmemberRizwan Tahir17-Apr-07 5:10 
QuestionReg: Update option in grid Pinmembera_anand_kumar3-Apr-07 23:17 
AnswerRe: Reg: Update option in grid PinmemberZakaria Bin Abdur Rouf4-Apr-07 5:30 
QuestionRe: Reg: Update option in grid Pinmembera_anand_kumar4-Apr-07 6:16 
GeneralAmazing and Full example! PinmemberOneSoftware8-Mar-07 17:13 
Generalgood work body PinmemberPali.Sniper7-Mar-07 22:48 
GeneralRe: good work body PinmemberZakaria Bin Abdur Rouf7-Mar-07 23:21 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141220.1 | Last Updated 1 Mar 2007
Article Copyright 2007 by Zakaria Bin Abdur Rouf
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid