?
Solved

Delphi app

Posted on 2004-08-06
5
Medium Priority
?
1,095 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
  • 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Integration Management Part 2
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

809 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