Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 4 - Building Contact Detail Maintenance into a...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Building Contact Detail Maintenance into a Mailing List Program with Borland Delphi
By: Leidago
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2006-10-04

    Table of Contents:
  • Building Contact Detail Maintenance into a Mailing List Program with Borland Delphi
  • Breaking Down the Code
  • Creating a New Group
  • The Less Complicated Code Bits

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building Contact Detail Maintenance into a Mailing List Program with Borland Delphi - The Less Complicated Code Bits


    (Page 4 of 4 )

    Now that we have the main code of form2 out of the way, let's deal with the less complicated ones. When the user chooses the "Add Contact to a group" option, the drop down box that appears needs to be filled with the group names from the groups table. So go to radiobutton1 which we renamed "rb1"and on its onclick event add the following code:

    procedure TForm2.rb1Click(Sender: TObject);
    begin
    if rb1.Checked then begin
    cb.Visible:=true;
    ednewgroup.Visible:=false;
    form1.query1.Close;
     form1.query1.SQL.Text:='SELECT *from groups';
     form1.query1.Open;
     if form1.query1.fieldbyname('groupname').Text <> '' then begin
     while not form1.query1.Eof do
     begin
     cb.Items.Add(form1.query1.fieldbyname('groupname').AsString);
     form1.query1.Next;
     end;
    end
    else begin
    cb.Visible:=false;
    end;
    end;
    end;

    All that this code does is run a query to retrieve all the group names and then add them to the drop down box.

    Now go to radiobutton2's onclick event (we renamed it to rb2) and double click on it. Add the following code:

    procedure TForm2.rb2Click(Sender: TObject);
    begin
     if rb2.Checked then
    begin
    ednewgroup.Visible:=true;
    cb.Visible:=false;
    end
    else begin
    ednewgroup.Visible:=false;
    end;
    end;

    The code above ensures that no components are visible that should not be visible when this radio button is selected.

    Now we need to create a form that displays all the addresses on our mailing list. Add a new form to the project and save the unit as addresses. On the form, add a dbgrid component from the data controls tab and rename it dbgrid. Then double click on the dbgrid and add "Name" and "Email" as the column headers. Then add a button. The form should now look like this:

    On the form's oncreate event, add the following code:

    procedure TForm3.FormCreate(Sender: TObject);
    begin
    form1.ado1.TableName:='contacts';
    form1.datasource1.DataSet:=ado1;
    DBGrid1.DataSource:=form1.datasource1;
    form1.ado1.Active:=true;
    end;

    The code above basically displays all the contact details. You can edit these records simply by selecting a record and typing your changes. Let's add the ability to remove records. Add another button and then add the following code:

    procedure TForm3.BitBtn2Click(Sender: TObject);
    begin
    if messagedlg('Are you sure you want to remove '+dbgrid.SelectedField.Text+ ' ?',mtConfirmation, [mbYes, mbNo],
    0) = mrYes
    then
     begin
     form1.ado1.Delete;
    end;
    end;

    In the above code we confirm whether the user really wants to delete the selected record, and if so we simply call the "delete" method and the record will be removed from the database.

    Conclusion

    We have looked at how to built a fully functional mailing list application, complete with a database and working code. The application can of course always be improved, but it does cover the basics, which are to send email messages simultaneously to everyone on the mailing list and also to add and remove contacts from the "address book." Remember to add your email connection details before testing the program.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Please make sure that you use the latest version of Indy when compiling the sample...
     

    DELPHI-KYLIX ARTICLES

    - Delphi Wrapper Classes and XML
    - Delphi and the DOM
    - Delphi and XML
    - Internet Access: Client Service
    - Finishing the Client for an Internet Access ...
    - The Client for an Internet Access Control Ap...
    - User Management for an Internet Access Contr...
    - Important Procedures for an Internet Access ...
    - Server Code for an Internet Access Control A...
    - Constructing the Interface for an Internet A...
    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT