Unit10.pas
上传用户:szyozho
上传日期:2013-04-13
资源大小:3688k
文件大小:12k
- unit Unit10;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ToolWin, ComCtrls, StdCtrls, Mask, DBCtrls, Buttons, ExtCtrls,
- DB, DBTables;
- type
- Tdefinepaperform = class(TForm)
- Panel1: TPanel;
- Label1: TLabel;
- Label2: TLabel;
- DBEdit1: TDBEdit;
- DBEdit2: TDBEdit;
- BitBtn3: TBitBtn;
- BitBtn4: TBitBtn;
- BitBtn5: TBitBtn;
- GroupBox1: TGroupBox;
- Label27: TLabel;
- Label5: TLabel;
- Label4: TLabel;
- Label3: TLabel;
- DBEdit3: TDBEdit;
- DBEdit4: TDBEdit;
- DBEdit5: TDBEdit;
- DBEdit15: TDBEdit;
- Label9: TLabel;
- Label8: TLabel;
- Label28: TLabel;
- Label7: TLabel;
- Label10: TLabel;
- Label11: TLabel;
- Label12: TLabel;
- Label29: TLabel;
- DBEdit16: TDBEdit;
- DBEdit8: TDBEdit;
- DBEdit7: TDBEdit;
- DBEdit6: TDBEdit;
- Label13: TLabel;
- Label14: TLabel;
- Label15: TLabel;
- Label30: TLabel;
- Label31: TLabel;
- DBEdit17: TDBEdit;
- Label32: TLabel;
- Label21: TLabel;
- DBEdit11: TDBEdit;
- Label18: TLabel;
- Label17: TLabel;
- Label16: TLabel;
- DBEdit9: TDBEdit;
- Label19: TLabel;
- Label20: TLabel;
- DBEdit10: TDBEdit;
- Label6: TLabel;
- DBEdit12: TDBEdit;
- DBEdit13: TDBEdit;
- DBEdit14: TDBEdit;
- Label22: TLabel;
- Label23: TLabel;
- Label24: TLabel;
- Label25: TLabel;
- Label26: TLabel;
- Label33: TLabel;
- DBEdit18: TDBEdit;
- DBNavigator1: TDBNavigator;
- Label34: TLabel;
- BitBtn1: TBitBtn;
- BitBtn2: TBitBtn;
- Query1: TQuery;
- procedure BitBtn4Click(Sender: TObject);
- procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
- function checknewshijuan:boolean;
- procedure FormCreate(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure DBEdit6Change(Sender: TObject);
- procedure DBEdit7Change(Sender: TObject);
- procedure DBEdit8Change(Sender: TObject);
- procedure DBEdit13Change(Sender: TObject);
- procedure DBEdit16Change(Sender: TObject);
- procedure DBEdit17Change(Sender: TObject);
- procedure DBEdit14Change(Sender: TObject);
- procedure DBEdit11Change(Sender: TObject);
- procedure DBEdit10Change(Sender: TObject);
- procedure DBEdit9Change(Sender: TObject);
- procedure DBEdit3Change(Sender: TObject);
- procedure DBEdit4Change(Sender: TObject);
- procedure DBEdit5Change(Sender: TObject);
- procedure DBEdit12Change(Sender: TObject);
- procedure DBEdit15Change(Sender: TObject);
- procedure BitBtn3Click(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- private
- { Private declarations }
- public
- choosenum,judgenum,filltextnum,readpronum,procedurenum:integer;
- updatejno:integer;
- { Public declarations }
- end;
- var
- definepaperform: Tdefinepaperform;
- addshijuan:Boolean;
- sum1,sum2,sum3,sum4,sum5,allsum,newshijuanhao:integer;
- implementation
- uses Unit4, Unit13, Unit18;
- {$R *.dfm}
- procedure Tdefinepaperform.BitBtn4Click(Sender: TObject);
- begin
- choosenum:=0;
- //showmessage(inttostr(choosenum));
- judgenum:=0;
- readpronum:=0;
- filltextnum:=0;
- procedurenum:=0;
- choosenum:=strtoint(DBEdit3.Text);
- //showmessage(inttostr(choosenum));
- judgenum:=strtoint(DBEdit4.Text);
- readpronum:=strtoint(DBEdit5.Text);
- filltextnum:=strtoint(DBEdit12.Text);
- procedurenum:=strtoint(DBEdit15.Text);
- choosepaperform.Label1.Caption:='';
- choosepaperform.Label4.Caption:='';
- choosepaperform.Label7.Caption:='';
- choosepaperform.Label10.Caption:='';
- choosepaperform.Label13.Caption:='';
- choosepaperform.Label2.Caption:='';
- choosepaperform.Label3.Caption:='';
- choosepaperform.Label5.Caption:='';
- choosepaperform.Label6.Caption:='';
- choosepaperform.Label8.Caption:='';
- choosepaperform.Label9.Caption:='';
- choosepaperform.Label11.Caption:='';
- choosepaperform.Label12.Caption:='';
- choosepaperform.Label14.Caption:='';
- choosepaperform.Label15.Caption:='';
- choosepaperform.Label1.Caption:='试卷共需要 '+inttostr(choosenum)+' 题. ';
- choosepaperform.Label4.Caption:='试卷共需要 '+inttostr(judgenum)+' 题. ';
- choosepaperform.Label7.Caption:='试卷共需要 '+inttostr(filltextnum)+' 题. ';
- choosepaperform.Label10.Caption:='试卷共需要 '+inttostr(readpronum)+' 题. ';
- choosepaperform.Label13.Caption:='试卷共需要 '+inttostr(procedurenum)+' 题. ';
- choosepaperform.ListBox1.Items.Text:='';
- choosepaperform.ListBox2.Items.Text:='';
- choosepaperform.ListBox3.Items.Text:='';
- choosepaperform.ListBox4.Items.Text:='';
- choosepaperform.ListBox5.Items.Text:='';
- choosepaperform.ListBox6.Items.Text:='';
- if definepaperform.DBEdit3.Text='0' then
- choosepaperform.TabSheet1.TabVisible:=false
- else
- choosepaperform.TabSheet1.TabVisible:=true;
- if definepaperform.DBEdit4.Text='0' then
- choosepaperform.TabSheet2.TabVisible:=false
- else
- choosepaperform.TabSheet2.TabVisible:=true;
- if definepaperform.DBEdit5.Text='0' then
- choosepaperform.TabSheet4.TabVisible:=false
- else
- choosepaperform.TabSheet4.TabVisible:=true;
- if definepaperform.DBEdit12.Text='0' then
- choosepaperform.TabSheet3.TabVisible:=false
- else
- choosepaperform.TabSheet3.TabVisible:=true;
- if definepaperform.DBEdit15.Text='0' then
- choosepaperform.TabSheet5.TabVisible:=false
- else
- choosepaperform.TabSheet5.TabVisible:=true;
- choosepaperform.show;
- definepaperform.Close;
- end;
- function Tdefinepaperform.checknewshijuan:boolean;
- var
- success:boolean;
- begin
- success:=true;
- with DataModule4.Table_shijuan do
- begin
- if DBEdit18.Text='' then
- success:=false;
- if DBEdit1.Text='' then
- success:=false;
- if DBEdit3.Text='' then
- success:=false;
- if DBEdit6.Text='' then
- success:=false;
- if DBEdit4.Text='' then
- success:=false;
- if DBEdit7.Text='' then
- success:=false;
- if DBEdit5.Text='' then
- success:=false;
- if DBEdit8.Text='' then
- success:=false;
- if DBEdit12.Text='' then
- success:=false;
- if DBEdit13.Text='' then
- success:=false;
- if DBEdit15.Text='' then
- success:=false;
- if DBEdit16.Text='' then
- success:=false;
- if not success then
- begin
- showmessage('红色项必须填写,请补上未填的红色项!');
- end;
- checknewshijuan:=success;
- end;
- end;
- procedure Tdefinepaperform.DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
- begin
- case button of
- nbInsert:
- begin
- BitBtn3.Enabled:=false;
- BitBtn4.Enabled:=false;
- addshijuan:=true;
- DBEdit18.Enabled:=true;
- DBEdit18.text:=inttostr(newshijuanhao);
- DBEdit18.enabled:=false;
- end;
- end;
- case button of
- nbDelete:
- begin
- query1.close;
- query1.sql.clear;
- query1.sql.text:='update shijuan set jno=jno-1 where jno>'''+inttostr(updatejno)+''' ';
- query1.ExecSQL;
- DataModule4.Table_shijuan.Close;
- DataModule4.Table_shijuan.open;
- end;
- end;
- end;
- procedure Tdefinepaperform.FormCreate(Sender: TObject);
- begin
- addshijuan:=false;
- end;
- procedure Tdefinepaperform.FormShow(Sender: TObject);
- begin
- DataModule4.Table_shijuan.Last;
- newshijuanhao:=DataModule4.Table_shijuan.FieldValues['jno']+1;
- DataModule4.Table_shijuan.First;
- end;
- procedure Tdefinepaperform.BitBtn1Click(Sender: TObject);
- begin
- if addshijuan then
- begin
- if checknewshijuan then
- begin
- DataModule4.Table_shijuan.Post;
- DataModule4.Table_shijuan.Close;
- DataModule4.Table_shijuan.Open;
- showmessage('新试卷添加成功!');
-
- addshijuan:=false;
- inc(newshijuanhao);
- // DataModule4.Table_shijuan.UpdateRecord;
- DBNavigator1.CanFocus;
- BitBtn3.Enabled:=true;
- BitBtn4.Enabled:=true;
- end
- else
- exit;
- end;
- end;
- procedure Tdefinepaperform.DBEdit6Change(Sender: TObject);
- begin
- sum1:=0;
- if (DBEdit3.Text<>'')and(DBEdit6.Text<>'') then
- begin
- sum1:=sum1+strtoint(DBEdit3.Text)*strtoint(DBEdit6.Text);
- DBEdit9.Text:=inttostr(sum1);
- end;
- end;
- procedure Tdefinepaperform.DBEdit7Change(Sender: TObject);
- begin
- sum2:=0;
- if (DBEdit4.Text<>'')and(DBEdit7.Text<>'') then
- begin
- sum2:=sum2+strtoint(DBEdit4.Text)*strtoint(DBEdit7.Text);
- DBEdit10.Text:=inttostr(sum2);
- end;
- end;
- procedure Tdefinepaperform.DBEdit8Change(Sender: TObject);
- begin
- sum3:=0;
- if (DBEdit5.Text<>'')and(DBEdit8.Text<>'') then
- begin
- sum3:=sum3+strtoint(DBEdit5.Text)*strtoint(DBEdit8.Text);
- DBEdit11.Text:=inttostr(sum3);
- end;
- end;
- procedure Tdefinepaperform.DBEdit13Change(Sender: TObject);
- begin
- sum4:=0;
- if (DBEdit12.Text<>'')and(DBEdit13.Text<>'') then
- begin
- sum4:=sum4+strtoint(DBEdit12.Text)*strtoint(DBEdit13.Text);
- DBEdit14.Text:=inttostr(sum4);
- end;
- end;
- procedure Tdefinepaperform.DBEdit16Change(Sender: TObject);
- begin
- sum5:=0;
- if (DBEdit15.Text<>'')and(DBEdit16.Text<>'') then
- begin
- sum5:=sum5+strtoint(DBEdit15.Text)*strtoint(DBEdit16.Text);
- DBEdit17.Text:=inttostr(sum5);
- end;
- end;
- procedure Tdefinepaperform.DBEdit17Change(Sender: TObject);
- begin
- allsum:=0;
- if (DBEdit9.Text<>'')and(DBEdit10.Text<>'')and(DBEdit11.Text<>'')and(DBEdit14.Text<>'')and(DBEdit17.Text<>'') then
- begin
- allsum:=allsum+sum1+sum2+sum3+sum4+sum5;
- DBEdit2.Text:=inttostr(allsum);
- end;
- end;
- procedure Tdefinepaperform.DBEdit14Change(Sender: TObject);
- begin
- allsum:=0;
- if (DBEdit9.Text<>'')and(DBEdit10.Text<>'')and(DBEdit11.Text<>'')and(DBEdit14.Text<>'')and(DBEdit17.Text<>'') then
- begin
- allsum:=allsum+sum1+sum2+sum3+sum4+sum5;
- DBEdit2.Text:=inttostr(allsum);
- end;
- end;
- procedure Tdefinepaperform.DBEdit11Change(Sender: TObject);
- begin
- allsum:=0;
- if (DBEdit9.Text<>'')and(DBEdit10.Text<>'')and(DBEdit11.Text<>'')and(DBEdit14.Text<>'')and(DBEdit17.Text<>'') then
- begin
- allsum:=allsum+sum1+sum2+sum3+sum4+sum5;
- DBEdit2.Text:=inttostr(allsum);
- end;
- end;
- procedure Tdefinepaperform.DBEdit10Change(Sender: TObject);
- begin
- allsum:=0;
- if (DBEdit9.Text<>'')and(DBEdit10.Text<>'')and(DBEdit11.Text<>'')and(DBEdit14.Text<>'')and(DBEdit17.Text<>'') then
- begin
- allsum:=allsum+sum1+sum2+sum3+sum4+sum5;
- DBEdit2.Text:=inttostr(allsum);
- end;
- end;
- procedure Tdefinepaperform.DBEdit9Change(Sender: TObject);
- begin
- allsum:=0;
- if (DBEdit9.Text<>'')and(DBEdit10.Text<>'')and(DBEdit11.Text<>'')and(DBEdit14.Text<>'')and(DBEdit17.Text<>'') then
- begin
- allsum:=allsum+sum1+sum2+sum3+sum4+sum5;
- DBEdit2.Text:=inttostr(allsum);
- end;
- end;
- procedure Tdefinepaperform.DBEdit3Change(Sender: TObject);
- begin
- sum1:=0;
- if (DBEdit3.Text<>'')and(DBEdit6.Text<>'') then
- begin
- sum1:=sum1+strtoint(DBEdit3.Text)*strtoint(DBEdit6.Text);
- DBEdit9.Text:=inttostr(sum1);
- end;
- end;
- procedure Tdefinepaperform.DBEdit4Change(Sender: TObject);
- begin
- sum2:=0;
- if (DBEdit4.Text<>'')and(DBEdit7.Text<>'') then
- begin
- sum2:=sum2+strtoint(DBEdit4.Text)*strtoint(DBEdit7.Text);
- DBEdit10.Text:=inttostr(sum2);
- end;
- end;
- procedure Tdefinepaperform.DBEdit5Change(Sender: TObject);
- begin
- sum3:=0;
- if (DBEdit5.Text<>'')and(DBEdit8.Text<>'') then
- begin
- sum3:=sum3+strtoint(DBEdit5.Text)*strtoint(DBEdit8.Text);
- DBEdit11.Text:=inttostr(sum3);
- end;
- end;
- procedure Tdefinepaperform.DBEdit12Change(Sender: TObject);
- begin
- sum4:=0;
- if (DBEdit12.Text<>'')and(DBEdit13.Text<>'') then
- begin
- sum4:=sum4+strtoint(DBEdit12.Text)*strtoint(DBEdit13.Text);
- DBEdit14.Text:=inttostr(sum4);
- end;
- end;
- procedure Tdefinepaperform.DBEdit15Change(Sender: TObject);
- begin
- sum5:=0;
- if (DBEdit15.Text<>'')and(DBEdit16.Text<>'') then
- begin
- sum5:=sum5+strtoint(DBEdit15.Text)*strtoint(DBEdit16.Text);
- DBEdit17.Text:=inttostr(sum5);
- end;
- end;
- procedure Tdefinepaperform.BitBtn3Click(Sender: TObject);
- var
- i,j:integer;
- begin
- paperautoform.ProgressBar1.Position:=0;
- for i:=1 to 800 do
- begin
- paperautoform.thao[i]:=0;
- paperautoform.havetake[i]:=0;
- end;
- for j:=1 to 5 do
- begin
- paperautoform.diff[i]:=0;;
- end;
- paperautoform.Memo1.Text:='';
- paperautoform.Show;
- end;
- procedure Tdefinepaperform.BitBtn2Click(Sender: TObject);
- begin
- DBNavigator1.BtnClick(nbCancel);
- BitBtn3.Enabled:=true;
- BitBtn4.Enabled:=true;
- end;
- end.