Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 17.34 KB | None | 0 0
  1. unit QEP;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  7.   System.Classes, Vcl.Graphics,
  8.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, System.Actions, Vcl.ActnList,
  9.   Vcl.StdCtrls, Vcl.Buttons, Vcl.Menus, Vcl.Imaging.jpeg, Vcl.ExtCtrls,
  10.   SignUpPG;
  11.  
  12. type
  13.   TfrmMainMenu = class(TForm)
  14.     lblQuadraticEquationProgram: TLabel;
  15.     lblEnterValues: TLabel;
  16.     lbla: TLabel;
  17.     edtAvalue: TEdit;
  18.     lblb: TLabel;
  19.     edtBvalue: TEdit;
  20.     lblc: TLabel;
  21.     edtCvalue: TEdit;
  22.     btnProduce_Graph: TButton;
  23.     btnProduce_Solution: TButton;
  24.     cboxA: TComboBox;
  25.     cboxB: TComboBox;
  26.     cboxC: TComboBox;
  27.     lblEquation: TLabel;
  28.     imgFormula: TImage;
  29.     LoginButton: TButton;
  30.     edtUsername: TEdit;
  31.     edtPassword: TEdit;
  32.     SignUpButton: TButton;
  33.     Label1: TLabel;
  34.     Label2: TLabel;
  35.     lblQE: TLabel;
  36.     lblP: TLabel;
  37.     procedure btnProduce_SolutionClick(Sender: TObject);
  38.     procedure btnProduce_GraphClick(Sender: TObject);
  39.     procedure edtAvalueChange(Sender: TObject);
  40.     procedure edtBvalueChange(Sender: TObject);
  41.     procedure edtCvalueChange(Sender: TObject);
  42.     procedure cboxAChange(Sender: TObject);
  43.     procedure cboxBChange(Sender: TObject);
  44.     procedure cboxCChange(Sender: TObject);
  45.     procedure edtAvalueClick(Sender: TObject);
  46.     procedure edtBvalueClick(Sender: TObject);
  47.     procedure edtCvalueClick(Sender: TObject);
  48.     procedure LoginButtonClick(Sender: TObject);
  49.     procedure edtPasswordClick(Sender: TObject);
  50.     procedure edtUsernameClick(Sender: TObject);
  51.     procedure FormCreate(Sender: TObject);
  52.     procedure SignUpButtonClick(Sender: TObject);
  53.  
  54.   private
  55.     { Private declarations }
  56.   public
  57.     { Public declarations }
  58.     UserFile: TextFile;
  59.     PSS: boolean;
  60.     TextString, FileName: string;
  61.  
  62.   end;
  63.  
  64. var
  65.   frmMainMenu: TfrmMainMenu;
  66.  
  67. implementation
  68.  
  69. {$R *.dfm}
  70.  
  71. uses Produce_Graph, Produce_Solution;
  72.  
  73. procedure TfrmMainMenu.edtAvalueChange(Sender: TObject);
  74. var
  75.   boxa, boxb, boxc: string;
  76. begin
  77.  
  78.   boxa := cboxA.text;                                                           //set the variable boxa the same as the text in CboxA
  79.  
  80.   if (boxa = '+') then                                                          //if the sign in CboxA is '+' then
  81.     boxa := ''                                                                  //set boxa as blank ''
  82.   else
  83.     boxa := cboxA.text;                                                         //else, show the -ve sign
  84.  
  85.   boxb := cboxB.text;                                                           //set the variable boxb the same as the text in CboxB
  86.  
  87.   if (boxb = '+') then                                                          //if the sign in CboxB is '+' then
  88.     boxb := ''                                                                  //set boxb as blank ''
  89.   else
  90.     boxb := cboxB.text;                                                         //else, show the -ve sign
  91.  
  92.   boxc := cboxC.text;                                                           //set the variable boxc the same as the text in CboxC
  93.  
  94.   if (boxc = '+') then                                                          //if the sign in CboxC is '+' then
  95.     boxc := ''                                                                  //set boxc as blank ''
  96.   else
  97.     boxc := cboxC.text;                                                         //else, show the -ve sign
  98.  
  99.   lblEquation.Caption := 'The equation is: ' + boxa + edtAvalue.text + 'x² ' +  //for lblEquation print : 'The Equation is: (+/- edtAvalue)x² (+/- edtBvalue)x (+/- edtCvalue)
  100.     boxb + edtBvalue.text + 'x ' + boxc + edtCvalue.text + '';
  101. end;
  102.  
  103. procedure TfrmMainMenu.edtAvalueClick(Sender: TObject);
  104. begin
  105.   edtAvalue.SelectAll;                                                          //select all of the contents of edtAvalue
  106. end;
  107.  
  108. procedure TfrmMainMenu.edtBvalueChange(Sender: TObject);
  109. var
  110.   boxa, boxb, boxc: string;
  111. begin
  112.  
  113.   boxa := cboxA.text;                                                           //set the variable boxa the same as the text in CboxA
  114.  
  115.   if (boxa = '+') then                                                          //if the sign in CboxA is '+' then
  116.     boxa := ''                                                                  //set boxa as blank ''
  117.   else
  118.     boxa := cboxA.text;                                                         //else, show the -ve sign
  119.  
  120.   boxb := cboxB.text;                                                           //set the variable boxb the same as the text in CboxB
  121.  
  122.   if (boxb = '+') then                                                          //if the sign in CboxB is '+' then
  123.     boxb := ''                                                                  //set boxb as blank ''
  124.   else
  125.     boxb := cboxB.text;                                                         //else, show the -ve sign
  126.  
  127.   boxc := cboxC.text;                                                           //set the variable boxc the same as the text in CboxC
  128.  
  129.   if (boxc = '+') then                                                          //if the sign in CboxC is '+' then
  130.     boxc := ''                                                                  //set boxc as blank ''
  131.   else
  132.     boxc := cboxC.text;                                                         //else, show the -ve sign
  133.  
  134.   lblEquation.Caption := 'The equation is: ' + boxa + edtAvalue.text + 'x² ' +  //for lblEquation print : 'The Equation is: (+/- edtAvalue)x² (+/- edtBvalue)x (+/- edtCvalue)
  135.     boxb + edtBvalue.text + 'x ' + boxc + edtCvalue.text + '';
  136. end;
  137.  
  138. procedure TfrmMainMenu.edtBvalueClick(Sender: TObject);
  139. begin
  140.   edtBvalue.SelectAll;                                                          //select all of the contents of edtAvalue
  141. end;
  142.  
  143. procedure TfrmMainMenu.edtCvalueChange(Sender: TObject);
  144. var
  145.   boxa, boxb, boxc: string;
  146. begin
  147.  
  148.   boxa := cboxA.text;                                                           //set the variable boxa the same as the text in CboxA
  149.  
  150.   if (boxa = '+') then                                                          //if the sign in CboxA is '+' then
  151.     boxa := ''                                                                  //set boxa as blank ''
  152.   else
  153.     boxa := cboxA.text;                                                         //else, show the -ve sign
  154.  
  155.   boxb := cboxB.text;                                                           //set the variable boxb the same as the text in CboxB
  156.  
  157.   if (boxb = '+') then                                                          //if the sign in CboxB is '+' then
  158.     boxb := ''                                                                  //set boxb as blank ''
  159.   else
  160.     boxb := cboxB.text;                                                         //else, show the -ve sign
  161.  
  162.   boxc := cboxC.text;                                                           //set the variable boxc the same as the text in CboxC
  163.  
  164.   if (boxc = '+') then                                                          //if the sign in CboxC is '+' then
  165.     boxc := ''                                                                  //set boxc as blank ''
  166.   else
  167.     boxc := cboxC.text;                                                         //else, show the -ve sign
  168.  
  169.   lblEquation.Caption := 'The equation is: ' + boxa + edtAvalue.text + 'x² ' + //for lblEquation print : 'The Equation is: (+/- edtAvalue)x² (+/- edtBvalue)x (+/- edtCvalue)
  170.     boxb + edtBvalue.text + 'x ' + boxc + edtCvalue.text + '';
  171. end;
  172.  
  173. procedure TfrmMainMenu.edtCvalueClick(Sender: TObject);
  174. begin
  175.   edtCvalue.SelectAll;                                                          //select all of the contents of edtAvalue
  176. end;
  177.  
  178. procedure TfrmMainMenu.FormCreate(Sender: TObject);
  179. begin                                                                           //when then the program is opened
  180.   frmMainMenu.Width := 292;                                                     //set the width to 292
  181.   frmMainMenu.Height := 401;                                                    //set the height to 401
  182.   btnProduce_Solution.Hide;                                                     //hide all with .hide
  183.   btnProduce_Graph.Hide;
  184.   cboxA.Hide;
  185.   cboxB.Hide;
  186.   cboxC.Hide;
  187.   edtAvalue.Hide;
  188.   edtBvalue.Hide;
  189.   edtCvalue.Hide;
  190.   imgFormula.Hide;
  191.   lbla.Hide;
  192.   lblb.Hide;
  193.   lblc.Hide;
  194.   lblEnterValues.Hide;
  195.   lblEquation.Hide;
  196.   lblQuadraticEquationProgram.Hide;
  197.   LoginButton.Show;                                                             //show all with .show
  198.   edtUsername.Show;
  199.   edtPassword.Show;
  200.   SignUpButton.Show;
  201.   Label1.Show;
  202.   Label2.Show;
  203. end;
  204.  
  205. procedure TfrmMainMenu.LoginButtonClick(Sender: TObject);                       //Procedure to let the user into the program
  206. var
  207.   UserName1, Password1: string;                                                 //variables Username1 and Password1
  208.   found, done: boolean;
  209. begin
  210.   AssignFile(UserFile, 'UserNames.txt');                                        //assign the UserFile to the text file Usernames.txt
  211.   Reset(UserFile);                                                              //when button is pressed, reset the UserFile
  212.   Done := False;
  213.   UserName1 := edtUsername.text;                                                //set Username1 to the contents of edtUsername
  214.   Password1 := edtPassword.text;                                                //set Password1 to the contents of edtPassword
  215.   while ((Done = False) AND (EOF(UserFile) = False)) do                         //while both done=false and end.of.file+false do
  216.   begin
  217.     readln(UserFile, TextString);                                               //read the UserFile
  218.     if (TextString = UserName1) then                                            //if the first textstring is the same as Username1 then
  219.     begin
  220.       readln(UserFile, TextString);                                             //read the UserFile
  221.       if (TextString = Password1) then                                          //if the first textstring is the same as Password then
  222.         begin
  223.           frmMainMenu.Width := 488;                                             //set width as 488
  224.           frmMainMenu.Height := 385;                                            //set height as 385
  225.           btnProduce_Solution.Show;                                             //from procedure TfrmMainMenu.FormCreate(Sender: TObject)
  226.           btnProduce_Graph.Show;                                                //show the Produce_Graph form
  227.           cboxA.Show;                                                           //show all with .show
  228.           cboxB.Show;
  229.           cboxC.Show;
  230.           edtAvalue.Show;
  231.           edtBvalue.Show;
  232.           edtCvalue.Show;
  233.           imgFormula.Show;
  234.           lbla.Show;
  235.           lblb.Show;
  236.           lblc.Show;
  237.           lblEnterValues.Show;
  238.           lblEquation.Show;
  239.           lblQuadraticEquationProgram.Show;
  240.           LoginButton.Hide;                                                     //hide all with .hide
  241.           edtUsername.Hide;
  242.           edtPassword.Hide;
  243.           SignUpButton.Hide;
  244.           lblQE.Hide;
  245.           lblP.Hide;
  246.           Label1.Hide;
  247.           Label2.Hide;
  248.           Done := true;
  249.         end;
  250.     end;
  251.  
  252.      if ((eof(UserFile)= true) AND (Done = false)) then                         //if the End.Of.File has been reached and done=false
  253.       begin                                                                     //
  254.         showmessage('Incorrect Username or Password');
  255.       end;
  256.  
  257.   end;
  258.   closefile(UserFile);
  259. end;
  260.  
  261. procedure TfrmMainMenu.SignUpButtonClick(Sender: TObject);
  262. begin
  263.   SignUpPG.frmSignUp_Page.Show;                                                 //Shows the SignUp Page
  264.   frmSignUp_Page.edtName.Clear;                                                 //Clears the edtNAme box
  265.   frmSignUp_Page.edtPassword.Clear;                                             //CLears the edtPassword box
  266.   frmSignUp_Page.edtComfPassword.Clear;                                         //Clears the edtComfPassword box
  267. end;
  268.  
  269. procedure TfrmMainMenu.btnProduce_GraphClick(Sender: TObject);
  270. begin
  271.   frmProduce_Graph.Show;                                                        //shows the Produce_Graph form
  272. end;
  273.  
  274. procedure TfrmMainMenu.btnProduce_SolutionClick(Sender: TObject);
  275. var
  276.   boxa, boxb, boxc: string;                                                     //declares the variable boxa, boxb and boxc
  277. begin                                                                           //
  278.   frmProduce_Solutions.Show;                                                    //shows the Produce_Solutions form
  279.  
  280.   boxa := cboxA.text;                                                           //sets the variable boxa to the text of CboxA
  281.  
  282.   if (boxa = '+') then                                                          //if the sign of CboxA is a '+' then
  283.     frmProduce_Solutions.lblEquationIs.Caption := edtAvalue.text                //in the form Produce_Solutions print out the text that is in edtAvalue
  284.   else
  285.     frmProduce_Solutions.lblEquationIs.Caption := cboxA.text + edtAvalue.text;  //else, if the sign is a '-' then print the -ve sign with what is in the edtAvalue box
  286.  
  287.   begin
  288.     frmProduce_Solutions.lbl_aIs.Caption := cboxA.text + edtAvalue.text + '';   //in the form Produce_Solutions print the text of CboxA and edtAvalue to the label lbl_aIs
  289.     frmProduce_Graph.lblPG_a.Caption := cboxA.text + edtAvalue.text + '';       //in the form Produce_Graph prin the text of CboxA and edtAvalue to the label lblPG_a
  290.   end;
  291.  
  292.   boxb := cboxB.text;                                                           //sets the variable boxa to the text of CboxB
  293.  
  294.   if (boxb = '+') then                                                          //if the sign of CboxB is a '+' then
  295.     frmProduce_Solutions.lblEquationIs.Caption := edtBvalue.text                //in the form Produce_Solutions print out the text that is in edtBvalue
  296.   else
  297.     frmProduce_Solutions.lblEquationIs.Caption := cboxB.text + edtBvalue.text;  //else, if the sign is a '-' then print the -ve sign with what is in the edtBvalue box
  298.  
  299.   begin
  300.     frmProduce_Solutions.lbl_bIs.Caption := cboxB.text + edtBvalue.text + '';   //in the form Produce_Solutions print the text of CboxB and edtBvalue to the label lbl_bIs
  301.     frmProduce_Graph.lblPG_b.Caption := cboxB.text + edtBvalue.text + '';       //in the form Produce_Graph prin the text of CboxB and edtBvalue to the label lblPG_b
  302.   end;
  303.  
  304.   boxc := cboxC.text;                                                           //sets the variable boxa to the text of CboxC
  305.  
  306.   if (boxc = '+') then                                                          //if the sign of CboxC is a '+' then
  307.     frmProduce_Solutions.lblEquationIs.Caption := edtCvalue.text                //in the form Produce_Solutions print out the text that is in edtCvalue
  308.   else
  309.     frmProduce_Solutions.lblEquationIs.Caption := cboxC.text + edtCvalue.text;  //else, if the sign is a '-' then print the -ve sign with what is in the edtCvalue box
  310.  
  311.   begin
  312.     frmProduce_Solutions.lbl_cIs.Caption := cboxC.text + edtCvalue.text + '';   //in the form Produce_Solutions print the text of CboxC and edtCvalue to the label lbl_cIs
  313.     frmProduce_Graph.lblPG_c.Caption := cboxC.text + edtCvalue.text + '';       //in the form Produce_Graph prin the text of CboxC and edtCvalue to the label lblPG_c
  314.   end;
  315.  
  316.   begin
  317.     frmProduce_Solutions.lblEquationIs.Caption := lblEquation.Caption;          //set lblEquationIs in Produce_Solutions the same as lblEquation
  318.     frmProduce_Graph.lblPG_Eq.Caption := lblEquation.Caption;                   //set lblPG_Eq in Produce_Graph the same as lblEquation
  319.   end;
  320.  
  321. end;
  322.  
  323. procedure TfrmMainMenu.cboxAChange(Sender: TObject);
  324. var
  325.   boxa, boxb, boxc: string;
  326. begin
  327.  
  328.   boxa := cboxA.text;
  329.  
  330.   if (boxa = '+') then
  331.     boxa := ''
  332.   else
  333.     boxa := cboxA.text;
  334.  
  335.   boxb := cboxB.text;
  336.  
  337.   if (boxb = '+') then
  338.     boxb := cboxB.text;
  339.  
  340.   boxc := cboxC.text;
  341.  
  342.   if (boxc = '+') then
  343.     boxc := cboxC.text;
  344.  
  345.   lblEquation.Caption := 'The equation is: ' + boxa + edtAvalue.text + 'x² ' +
  346.     boxb + edtBvalue.text + 'x ' + boxc + edtCvalue.text + '';
  347. end;
  348.  
  349. procedure TfrmMainMenu.cboxBChange(Sender: TObject);
  350. var
  351.   boxa, boxb, boxc: string;
  352. begin
  353.  
  354.   boxa := cboxA.text;
  355.  
  356.   if (boxa = '+') then
  357.     boxa := ''
  358.   else
  359.     boxa := cboxA.text;
  360.  
  361.   boxb := cboxB.text;
  362.  
  363.   if (boxb = '+') then
  364.     boxb := cboxB.text;
  365.  
  366.   boxc := cboxC.text;
  367.  
  368.   if (boxc = '+') then
  369.     boxc := cboxC.text;
  370.  
  371.   lblEquation.Caption := 'The equation is: ' + boxa + edtAvalue.text + 'x² ' +
  372.     boxb + edtBvalue.text + 'x ' + boxc + edtCvalue.text + '';
  373. end;
  374.  
  375. procedure TfrmMainMenu.cboxCChange(Sender: TObject);
  376. var
  377.   boxa, boxb, boxc: string;
  378. begin
  379.  
  380.   boxa := cboxA.text;
  381.  
  382.   if (boxa = '+') then
  383.     boxa := ''
  384.   else
  385.     boxa := cboxA.text;
  386.  
  387.   boxb := cboxB.text;
  388.  
  389.   if (boxb = '+') then
  390.     boxb := cboxB.text;
  391.  
  392.   boxc := cboxC.text;
  393.  
  394.   if (boxc = '+') then
  395.     boxc := cboxC.text;
  396.  
  397.   lblEquation.Caption := 'The equation is: ' + boxa + edtAvalue.text + 'x² ' +
  398.     boxb + edtBvalue.text + ' x ' + boxc + edtCvalue.text + '';
  399. end;
  400.  
  401. procedure TfrmMainMenu.edtUsernameClick(Sender: TObject);
  402. begin
  403.   edtUsername.SelectAll;
  404. end;
  405.  
  406. procedure TfrmMainMenu.edtPasswordClick(Sender: TObject);
  407. begin
  408.   edtPassword.SelectAll;
  409. end;
  410.  
  411. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement