Solved

Delphi app

Posted on 2004-08-06
5
1,087 Views
Last Modified: 2008-03-10
can you guys tell me what does these code do. I have to make some modification to this application and I don't know where to begin since I m very new to Delphi . please any help will be appreciated.

fReview.ShowModal;
end;

procedure TfRequestMain.bbReportsClick(Sender: TObject);
begin
  If pgRequest.ActivePage <> tsCompleted Then
   Begin
    pgRequest.ActivePage := tsCompleted;
    pgRequestChange(Sender);
    Application.ProcessMessages;
   End;
  fReports.ShowModal;
end;

procedure TfRequestMain.pgRequestChange(Sender: TObject);
begin
  If pgRequest.ActivePage = tsActive Then
   Begin
    bbFind.Enabled := False;
   End
  Else
   Begin
    bbFind.Enabled := True;
   End;
end;

procedure TfRequestMain.FormShow(Sender: TObject);
begin
  If SecurityLevel = 0 Then
    PasswordForm.ShowModal;
{MessageDlg('Net Name: ' + NetName + Chr(13) +
           'Security: ' + IntToStr(SecurityLevel), mtInformation, [mbOK], 0);}
  Case User_Level Of
    0 : fRequestMain.Close;
    1 : OpenQueries;
    2 : OpenQueries;
    3 : OpenQueries;
  End;
{MessageDlg('Request Month: ' + IntToStr(RequestMonth) + Chr(13) +
           'Request Year:  ' + IntToStr(RequestYear), mtInformation, [mbOK], 0);}
end;


procedure TfRequestMain.bRequestNumberClick(Sender: TObject);
begin
  RequestNumber := dmRequest.adoqAllRequestsREQ_NUMBER.Value;
  dmRequest.adoqAllRequests.Close;
  dmRequest.adoqAllRequests.SQL.Clear;
  dmrequest.adoqAllRequests.SQL.Add('select Req_Number, REQUESTOR_COMPANY, ');
  dmrequest.adoqAllRequests.SQL.Add('REQUESTOR_Name, ASSIGNED_TO, REQUEST_TASK, ');
  dmrequest.adoqAllRequests.SQL.Add('RECEIVED_DATE, COMPLETED_DATE, REQUEST_DESC ');
  dmrequest.adoqAllRequests.SQL.Add('from request_sys ');
  dmrequest.adoqAllRequests.SQL.Add('Order by Req_Number ');
  dmRequest.adoqAllRequests.Open;
  dmRequest.adoqAllRequests.Locate('Req_Number', RequestNumber, [loCaseInsensitive]);
  bRequestNumber.Enabled := False;
  bCompanyName.Enabled := True;
  bRequestorName.Enabled := True;
  bAssignedTo.Enabled := True;
  bbFind.Caption := 'Find By: Request Number';
  IndexNumber := 1;
end;

procedure TfRequestMain.bCompanyNameClick(Sender: TObject);
begin
  RequestNumber := dmRequest.adoqAllRequestsREQ_NUMBER.Value;
  dmRequest.adoqAllRequests.Close;
  dmRequest.adoqAllRequests.SQL.Clear;
  dmrequest.adoqAllRequests.SQL.Add('select Req_Number, REQUESTOR_COMPANY, ');
  dmrequest.adoqAllRequests.SQL.Add('REQUESTOR_Name, ASSIGNED_TO, REQUEST_TASK, ');
  dmrequest.adoqAllRequests.SQL.Add('RECEIVED_DATE, COMPLETED_DATE, REQUEST_DESC ');
  dmrequest.adoqAllRequests.SQL.Add('from request_sys ');
  dmrequest.adoqAllRequests.SQL.Add('Order by REQUESTOR_COMPANY, Req_Number ');
  dmRequest.adoqAllRequests.Open;
  dmRequest.adoqAllRequests.Locate('Req_Number', RequestNumber, [loCaseInsensitive]);
  bRequestNumber.Enabled := True;
  bCompanyName.Enabled := False;
  bRequestorName.Enabled := True;
  bAssignedTo.Enabled := True;
  bbFind.Caption := 'Find By: Requestor Name';
  IndexNumber := 2;
end;

procedure TfRequestMain.bRequestorNameClick(Sender: TObject);
begin
  RequestNumber := dmRequest.adoqAllRequestsREQ_NUMBER.Value;
  dmRequest.adoqAllRequests.Close;
  dmRequest.adoqAllRequests.SQL.Clear;
  dmrequest.adoqAllRequests.SQL.Add('select Req_Number, REQUESTOR_COMPANY, ');
  dmrequest.adoqAllRequests.SQL.Add('REQUESTOR_Name, ASSIGNED_TO, REQUEST_TASK, ');
  dmrequest.adoqAllRequests.SQL.Add('RECEIVED_DATE, COMPLETED_DATE, REQUEST_DESC ');
  dmrequest.adoqAllRequests.SQL.Add('from request_sys ');
  dmrequest.adoqAllRequests.SQL.Add('Order by REQUESTOR_Name, Req_Number ');
  dmRequest.adoqAllRequests.Open;
  dmRequest.adoqAllRequests.Locate('Req_Number', RequestNumber, [loCaseInsensitive]);
  bRequestNumber.Enabled := True;
  bCompanyName.Enabled := True;
  bRequestorName.Enabled := False;
  bAssignedTo.Enabled := True;
  bbFind.Caption := 'Find By: Requestor Name';
  IndexNumber := 3;
end;

procedure TfRequestMain.bAssignedToClick(Sender: TObject);
begin
  RequestNumber := dmRequest.adoqAllRequestsREQ_NUMBER.Value;
  dmRequest.adoqAllRequests.Close;
  dmRequest.adoqAllRequests.SQL.Clear;
  dmrequest.adoqAllRequests.SQL.Add('select Req_Number, REQUESTOR_COMPANY, ');
  dmrequest.adoqAllRequests.SQL.Add('REQUESTOR_Name, ASSIGNED_TO, REQUEST_TASK, ');
  dmrequest.adoqAllRequests.SQL.Add('RECEIVED_DATE, COMPLETED_DATE, REQUEST_DESC ');
  dmrequest.adoqAllRequests.SQL.Add('from request_sys ');
  dmrequest.adoqAllRequests.SQL.Add('Order by ASSIGNED_TO, Req_Number ');
  dmRequest.adoqAllRequests.Open;
  dmRequest.adoqAllRequests.Locate('Req_Number', RequestNumber, [loCaseInsensitive]);
  bRequestNumber.Enabled := True;
  bCompanyName.Enabled := True;
  bRequestorName.Enabled := True;
  bAssignedTo.Enabled := False;
  bbFind.Caption := 'Find By: Requestor Name';
  IndexNumber := 4;
end;

procedure TfRequestMain.bbFindClick(Sender: TObject);
VAR
  QueryCaption : String;
  QueryPrompt : String;
  FindValue : String;
begin
  Case IndexNumber Of
    2 : Begin
         QueryCaption := 'Current Index: Company Name';
         QueryPrompt := 'Enter the company name that you want to find:';
        End;
    3 : Begin
         QueryCaption := 'Current Index: Requestor Name';
         QueryPrompt := 'Enter the requestor''s name that you want to find:';
        End;
    4 : Begin
         QueryCaption := 'Current Index: Assigned To';
         QueryPrompt := 'Enter the employees name that you want to find:';
        End;
  Else
   Begin
    QueryCaption := 'Current Index: Request Number';
    QueryPrompt := 'Enter the request number that you want to find:';
   End;
  End;
  InputQuery(QueryCaption, QueryPrompt, FindValue);
  Case IndexNumber Of
    2 : dmRequest.adoqAllRequests.Locate('Requestor_Company', FindValue, [loCaseInsensitive, loPartialKey]);
    3 : dmRequest.adoqAllRequests.Locate('Requestor_Name', FindValue, [loCaseInsensitive, loPartialKey]);
    4 : dmRequest.adoqAllRequests.Locate('Assigned_To', FindValue, [loCaseInsensitive, loPartialKey]);
  Else
    dmRequest.adoqAllRequests.Locate('Req_Number', FindValue, [loCaseInsensitive, loPartialKey]);
  End;
end;

procedure TfRequestMain.dbgActiveDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
    // return all parameters back to TDBGrid for it to draw
    // with our new color selections
end;

End
0
Comment
Question by:Imanmalik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:Imanmalik
ID: 11735568
I need help modifying this qury to retrun result for past three yrs only .

select Req_Number, REQUESTOR_COMPANY, REQUESTOR_Name, ASSIGNED_TO, REQUEST_TASK, RECEIVED_DATE, COMPLETED_DATE, REQUEST_DESC
from request_sys
and where completed_date is between
Where COMPLETED_DATE Is Null
Order by RECEIVED_DATE
0
 

Author Comment

by:Imanmalik
ID: 11735584
i m sorry .
i accedently added another question to this thread . i will open a another thread for this in oracle area.
0
 
LVL 4

Expert Comment

by:Colin_Dawson
ID: 11743790
I've added coments to the code, I think that anyone should be able to follow it....


procedure TfRequestMain.bbReportsClick(Sender: TObject);
begin
  //If The page control pgRequest isn't showing the tabsheet ts completed
  If pgRequest.ActivePage <> tsCompleted Then
   Begin
    //Set the current tab sheet to tsCompleted
    pgRequest.ActivePage := tsCompleted;
    //Execute pgRequest.OnChange event (this is the manual way, but It's more or less correct)
    pgRequestChange(Sender);
    //Force windows to process all messages waiting on the message queue.
    Application.ProcessMessages;
   End;

  //Forst the form fReports to show in Modal mode.
  fReports.ShowModal;
end;

procedure TfRequestMain.pgRequestChange(Sender: TObject);
begin
  //This enables bbFind depending on the page that's active.

  If pgRequest.ActivePage = tsActive Then
   Begin
    bbFind.Enabled := False;
   End
  Else
   Begin
    bbFind.Enabled := True;
   End;

   //There's a better way to do this..  Here's how...
   //bbFind.Enabled := not (pgRequest.ActivePage = tsActive);
end;

procedure TfRequestMain.FormShow(Sender: TObject);
begin
  //If SecurityLevel is 0, show the password form.
  If SecurityLevel = 0 Then
    PasswordForm.ShowModal;

{MessageDlg('Net Name: ' + NetName + Chr(13) +
           'Security: ' + IntToStr(SecurityLevel), mtInformation, [mbOK], 0);}

  //if User_Level =0 then Close the form fRequestMain, otherwise, call OpenQueries.
  Case User_Level Of
    0 : fRequestMain.Close;
    1 : OpenQueries;
    2 : OpenQueries;
    3 : OpenQueries;
  End;

  //This would be better written as
//  if User_Level = 0 then
//    fRequestMain.Close
//  else
//    OpenQueries;

{MessageDlg('Request Month: ' + IntToStr(RequestMonth) + Chr(13) +
           'Request Year:  ' + IntToStr(RequestYear), mtInformation, [mbOK], 0);}
end;


procedure TfRequestMain.bRequestNumberClick(Sender: TObject);
begin
  //Get the RequestNumber from an adoRecordSet
  RequestNumber := dmRequest.adoqAllRequestsREQ_NUMBER.Value;
  //Close the record set
  dmRequest.adoqAllRequests.Close;
  //Clear out it's SQL
  dmRequest.adoqAllRequests.SQL.Clear;
  //Create a new query to select the data
  dmrequest.adoqAllRequests.SQL.Add('select Req_Number, REQUESTOR_COMPANY, ');
  dmrequest.adoqAllRequests.SQL.Add('REQUESTOR_Name, ASSIGNED_TO, REQUEST_TASK, ');
  dmrequest.adoqAllRequests.SQL.Add('RECEIVED_DATE, COMPLETED_DATE, REQUEST_DESC ');
  dmrequest.adoqAllRequests.SQL.Add('from request_sys ');
  dmrequest.adoqAllRequests.SQL.Add('Order by Req_Number ');
  //Open the record set
  dmRequest.adoqAllRequests.Open;
  //Find the record for the request number using the locate command.  (see comment later)
  dmRequest.adoqAllRequests.Locate('Req_Number', RequestNumber, [loCaseInsensitive]);
  //Force some controls into a set state.
  bRequestNumber.Enabled := False;
  bCompanyName.Enabled := True;
  bRequestorName.Enabled := True;
  bAssignedTo.Enabled := True;
  bbFind.Caption := 'Find By: Request Number';
  IndexNumber := 1;

  //Looking at this, why bother with locate?  Just add a Where clause to the SQL and only get the information that's needed.
  //It's alot quicker.
end;

procedure TfRequestMain.bCompanyNameClick(Sender: TObject);
begin
  //This is almost identical to the procedure above.
  RequestNumber := dmRequest.adoqAllRequestsREQ_NUMBER.Value;
  dmRequest.adoqAllRequests.Close;
  dmRequest.adoqAllRequests.SQL.Clear;
  dmrequest.adoqAllRequests.SQL.Add('select Req_Number, REQUESTOR_COMPANY, ');
  dmrequest.adoqAllRequests.SQL.Add('REQUESTOR_Name, ASSIGNED_TO, REQUEST_TASK, ');
  dmrequest.adoqAllRequests.SQL.Add('RECEIVED_DATE, COMPLETED_DATE, REQUEST_DESC ');
  dmrequest.adoqAllRequests.SQL.Add('from request_sys ');
  dmrequest.adoqAllRequests.SQL.Add('Order by REQUESTOR_COMPANY, Req_Number ');
  dmRequest.adoqAllRequests.Open;
  dmRequest.adoqAllRequests.Locate('Req_Number', RequestNumber, [loCaseInsensitive]);
  bRequestNumber.Enabled := True;
  bCompanyName.Enabled := False;
  bRequestorName.Enabled := True;
  bAssignedTo.Enabled := True;
  bbFind.Caption := 'Find By: Requestor Name';
  IndexNumber := 2;
end;

procedure TfRequestMain.bRequestorNameClick(Sender: TObject);
begin
  //and again
  RequestNumber := dmRequest.adoqAllRequestsREQ_NUMBER.Value;
  dmRequest.adoqAllRequests.Close;
  dmRequest.adoqAllRequests.SQL.Clear;
  dmrequest.adoqAllRequests.SQL.Add('select Req_Number, REQUESTOR_COMPANY, ');
  dmrequest.adoqAllRequests.SQL.Add('REQUESTOR_Name, ASSIGNED_TO, REQUEST_TASK, ');
  dmrequest.adoqAllRequests.SQL.Add('RECEIVED_DATE, COMPLETED_DATE, REQUEST_DESC ');
  dmrequest.adoqAllRequests.SQL.Add('from request_sys ');
  dmrequest.adoqAllRequests.SQL.Add('Order by REQUESTOR_Name, Req_Number ');
  dmRequest.adoqAllRequests.Open;
  dmRequest.adoqAllRequests.Locate('Req_Number', RequestNumber, [loCaseInsensitive]);
  bRequestNumber.Enabled := True;
  bCompanyName.Enabled := True;
  bRequestorName.Enabled := False;
  bAssignedTo.Enabled := True;
  bbFind.Caption := 'Find By: Requestor Name';
  IndexNumber := 3;
end;

procedure TfRequestMain.bAssignedToClick(Sender: TObject);
begin
  //and again
  RequestNumber := dmRequest.adoqAllRequestsREQ_NUMBER.Value;
  dmRequest.adoqAllRequests.Close;
  dmRequest.adoqAllRequests.SQL.Clear;
  dmrequest.adoqAllRequests.SQL.Add('select Req_Number, REQUESTOR_COMPANY, ');
  dmrequest.adoqAllRequests.SQL.Add('REQUESTOR_Name, ASSIGNED_TO, REQUEST_TASK, ');
  dmrequest.adoqAllRequests.SQL.Add('RECEIVED_DATE, COMPLETED_DATE, REQUEST_DESC ');
  dmrequest.adoqAllRequests.SQL.Add('from request_sys ');
  dmrequest.adoqAllRequests.SQL.Add('Order by ASSIGNED_TO, Req_Number ');
  dmRequest.adoqAllRequests.Open;
  dmRequest.adoqAllRequests.Locate('Req_Number', RequestNumber, [loCaseInsensitive]);
  bRequestNumber.Enabled := True;
  bCompanyName.Enabled := True;
  bRequestorName.Enabled := True;
  bAssignedTo.Enabled := False;
  bbFind.Caption := 'Find By: Requestor Name';
  IndexNumber := 4;
end;

procedure TfRequestMain.bbFindClick(Sender: TObject);
VAR
  QueryCaption : String;
  QueryPrompt : String;
  FindValue : String;
begin
  //setup the QueryCaption and Query prompt depending on the value of IndexNumber
  Case IndexNumber Of
    2 : Begin
         QueryCaption := 'Current Index: Company Name';
         QueryPrompt := 'Enter the company name that you want to find:';
        End;
    3 : Begin
         QueryCaption := 'Current Index: Requestor Name';
         QueryPrompt := 'Enter the requestor''s name that you want to find:';
        End;
    4 : Begin
         QueryCaption := 'Current Index: Assigned To';
         QueryPrompt := 'Enter the employees name that you want to find:';
        End;
  Else
   Begin
    QueryCaption := 'Current Index: Request Number';
    QueryPrompt := 'Enter the request number that you want to find:';
   End;
  End;

  //Use an InputQuery to get a search string
  InputQuery(QueryCaption, QueryPrompt, FindValue);

  //Use the locate to find the requested value.
  Case IndexNumber Of
    2 : dmRequest.adoqAllRequests.Locate('Requestor_Company', FindValue, [loCaseInsensitive, loPartialKey]);
    3 : dmRequest.adoqAllRequests.Locate('Requestor_Name', FindValue, [loCaseInsensitive, loPartialKey]);
    4 : dmRequest.adoqAllRequests.Locate('Assigned_To', FindValue, [loCaseInsensitive, loPartialKey]);
  Else
    dmRequest.adoqAllRequests.Locate('Req_Number', FindValue, [loCaseInsensitive, loPartialKey]);
  End;
end;

procedure TfRequestMain.dbgActiveDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
  //This does nothing.
    // return all parameters back to TDBGrid for it to draw
    // with our new color selections
end;

End


I think that'll just about do it.

Regards
0
 

Author Comment

by:Imanmalik
ID: 11751495
THANKS
but i m still confused on the commnts can you give me little more details as per what these code do ?
0
 
LVL 4

Accepted Solution

by:
Colin_Dawson earned 500 total points
ID: 11755576
I went through the entire code listing as explained the whole lot!  I don't know what else you want.   What is it specifically that you need to know?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 105
Dev Express grid collapse 2 47
DBGrid or StringGrid ? 6 120
How to add columns to a RAD Studio FMX grid at design time 1 31
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question