Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 3 - 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 - Creating a New Group


    (Page 3 of 4 )

    Section two of the code checks to see if you selected the "create new group" option. If you did, an edit text box will appear waiting to take your input. Before it does anything else, it will check to see if you entered a group name and then add the group name to the database:

      if rb2.Checked then
      begin
    //check that the new name is entered
      if ednewgroup.Text <> '' then begin
    //add the new groupname to the groups table and get its ID
      form1.query1.Close;
      form1.query1.SQL.Text:='INSERT INTO groups (groupname) values
    (:edval)';
      form1.query1.Parameters.ParamByName
    ('edval').Value:=ednewgroup.Text;
      form1.query1.ExecSQL;

    It then runs another query using the newly created groupname to find its groupID:

      //now get the group id
      form1.query1.close;
      form1.query1.SQL.Text:='SELECT groupID from groups WHERE
    groupname=:thename';
      form1.query1.Parameters.ParamByName
    ('thename').Value:=form2.ednewgroup.Text;
      form1.query1.Open;
      new_id:=form1.query1.fieldbyname('groupID').AsInteger;

    Once it has the groupID, the next step is to insert the contact details into the contacts table and inform the user that the contact details have been added.

     //insert the new contact details...
      form1.query1.Close;
      form1.query1.SQL.Text:='INSERT INTO contacts (name,email,gid)
    values (:aname,:aemail,:agid)';
      form1.query1.Parameters.ParamByName
    ('aname').Value:=edname.Text;
      form1.query1.Parameters.ParamByName
    ('aemail').Value:=edemail.text;
      form1.query1.Parameters.ParamByName('agid').Value:=new_id;
      form1.query1.ExecSQL;
      showmessage('Both the new group: '+ednewgroup.Text+ ' and
    contact: '+inttostr(new_id)+' has been added.');
      end

    If the user has not entered a groupname, then it will display the appropriate error message and stop the code from executing:

      else
      begin
      showmessage('Please enter a groupname.');
      exit;
      end;
      end;

    Next, we need to tell the program what to do if the user did not select any of the aforementioned options. If the user does not want to add the new contact to a group or if the user does not want to create a new groupname, then the program should simply add the contact details to the database and set the groupID column to zero. After doing this it should inform the user that the operation was successful:

      if not (rb1.Checked) and not (rb2.Checked) then
      begin
      form1.query1.Close;
      form1.query1.SQL.Text:='INSERT INTO contacts (name,email,gid)
    values (:aname,:aemail,:agid)';
      form1.query1.Parameters.ParamByName
    ('aname').Value:=edname.Text;
      form1.query1.Parameters.ParamByName
    ('aemail').Value:=edemail.text;
      form1.query1.Parameters.ParamByName('agid').Value:=0;
      form1.query1.ExecSQL;
      showmessage('New contact has been added.');
      end;
      end;

    More Delphi-Kylix Articles
    More By Leidago


       · 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 4 hosted by Hostway
    Stay green...Green IT