Solved

Delphi app

Posted on 2004-08-06
5
1,085 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 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now