Unit10.pas
上传用户:szyozho
上传日期:2013-04-13
资源大小:3688k
文件大小:12k
源码类别:

教育系统应用

开发平台:

Delphi

  1. unit Unit10;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, ToolWin, ComCtrls, StdCtrls, Mask, DBCtrls, Buttons, ExtCtrls,
  6.   DB, DBTables;
  7. type
  8.   Tdefinepaperform = class(TForm)
  9.     Panel1: TPanel;
  10.     Label1: TLabel;
  11.     Label2: TLabel;
  12.     DBEdit1: TDBEdit;
  13.     DBEdit2: TDBEdit;
  14.     BitBtn3: TBitBtn;
  15.     BitBtn4: TBitBtn;
  16.     BitBtn5: TBitBtn;
  17.     GroupBox1: TGroupBox;
  18.     Label27: TLabel;
  19.     Label5: TLabel;
  20.     Label4: TLabel;
  21.     Label3: TLabel;
  22.     DBEdit3: TDBEdit;
  23.     DBEdit4: TDBEdit;
  24.     DBEdit5: TDBEdit;
  25.     DBEdit15: TDBEdit;
  26.     Label9: TLabel;
  27.     Label8: TLabel;
  28.     Label28: TLabel;
  29.     Label7: TLabel;
  30.     Label10: TLabel;
  31.     Label11: TLabel;
  32.     Label12: TLabel;
  33.     Label29: TLabel;
  34.     DBEdit16: TDBEdit;
  35.     DBEdit8: TDBEdit;
  36.     DBEdit7: TDBEdit;
  37.     DBEdit6: TDBEdit;
  38.     Label13: TLabel;
  39.     Label14: TLabel;
  40.     Label15: TLabel;
  41.     Label30: TLabel;
  42.     Label31: TLabel;
  43.     DBEdit17: TDBEdit;
  44.     Label32: TLabel;
  45.     Label21: TLabel;
  46.     DBEdit11: TDBEdit;
  47.     Label18: TLabel;
  48.     Label17: TLabel;
  49.     Label16: TLabel;
  50.     DBEdit9: TDBEdit;
  51.     Label19: TLabel;
  52.     Label20: TLabel;
  53.     DBEdit10: TDBEdit;
  54.     Label6: TLabel;
  55.     DBEdit12: TDBEdit;
  56.     DBEdit13: TDBEdit;
  57.     DBEdit14: TDBEdit;
  58.     Label22: TLabel;
  59.     Label23: TLabel;
  60.     Label24: TLabel;
  61.     Label25: TLabel;
  62.     Label26: TLabel;
  63.     Label33: TLabel;
  64.     DBEdit18: TDBEdit;
  65.     DBNavigator1: TDBNavigator;
  66.     Label34: TLabel;
  67.     BitBtn1: TBitBtn;
  68.     BitBtn2: TBitBtn;
  69.     Query1: TQuery;
  70.     procedure BitBtn4Click(Sender: TObject);
  71.     procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
  72.   function checknewshijuan:boolean;
  73.     procedure FormCreate(Sender: TObject);
  74.     procedure FormShow(Sender: TObject);
  75.     procedure BitBtn1Click(Sender: TObject);
  76.     procedure DBEdit6Change(Sender: TObject);
  77.     procedure DBEdit7Change(Sender: TObject);
  78.     procedure DBEdit8Change(Sender: TObject);
  79.     procedure DBEdit13Change(Sender: TObject);
  80.     procedure DBEdit16Change(Sender: TObject);
  81.     procedure DBEdit17Change(Sender: TObject);
  82.     procedure DBEdit14Change(Sender: TObject);
  83.     procedure DBEdit11Change(Sender: TObject);
  84.     procedure DBEdit10Change(Sender: TObject);
  85.     procedure DBEdit9Change(Sender: TObject);
  86.     procedure DBEdit3Change(Sender: TObject);
  87.     procedure DBEdit4Change(Sender: TObject);
  88.     procedure DBEdit5Change(Sender: TObject);
  89.     procedure DBEdit12Change(Sender: TObject);
  90.     procedure DBEdit15Change(Sender: TObject);
  91.     procedure BitBtn3Click(Sender: TObject);
  92.     procedure BitBtn2Click(Sender: TObject);
  93.   private
  94.     { Private declarations }
  95.   public
  96.   choosenum,judgenum,filltextnum,readpronum,procedurenum:integer;
  97.    updatejno:integer;
  98.     { Public declarations }
  99.   end;
  100. var
  101.   definepaperform: Tdefinepaperform;
  102.    addshijuan:Boolean;
  103.    sum1,sum2,sum3,sum4,sum5,allsum,newshijuanhao:integer;
  104. implementation
  105. uses Unit4, Unit13, Unit18;
  106. {$R *.dfm}
  107. procedure Tdefinepaperform.BitBtn4Click(Sender: TObject);
  108. begin
  109. choosenum:=0;
  110. //showmessage(inttostr(choosenum));
  111. judgenum:=0;
  112. readpronum:=0;
  113. filltextnum:=0;
  114. procedurenum:=0;
  115. choosenum:=strtoint(DBEdit3.Text);
  116. //showmessage(inttostr(choosenum));
  117. judgenum:=strtoint(DBEdit4.Text);
  118. readpronum:=strtoint(DBEdit5.Text);
  119. filltextnum:=strtoint(DBEdit12.Text);
  120. procedurenum:=strtoint(DBEdit15.Text);
  121. choosepaperform.Label1.Caption:='';
  122. choosepaperform.Label4.Caption:='';
  123. choosepaperform.Label7.Caption:='';
  124. choosepaperform.Label10.Caption:='';
  125. choosepaperform.Label13.Caption:='';
  126. choosepaperform.Label2.Caption:='';
  127. choosepaperform.Label3.Caption:='';
  128. choosepaperform.Label5.Caption:='';
  129. choosepaperform.Label6.Caption:='';
  130. choosepaperform.Label8.Caption:='';
  131. choosepaperform.Label9.Caption:='';
  132. choosepaperform.Label11.Caption:='';
  133. choosepaperform.Label12.Caption:='';
  134. choosepaperform.Label14.Caption:='';
  135. choosepaperform.Label15.Caption:='';
  136. choosepaperform.Label1.Caption:='试卷共需要 '+inttostr(choosenum)+' 题.      ';
  137. choosepaperform.Label4.Caption:='试卷共需要 '+inttostr(judgenum)+' 题.      ';
  138. choosepaperform.Label7.Caption:='试卷共需要 '+inttostr(filltextnum)+' 题.      ';
  139. choosepaperform.Label10.Caption:='试卷共需要 '+inttostr(readpronum)+' 题.      ';
  140. choosepaperform.Label13.Caption:='试卷共需要 '+inttostr(procedurenum)+' 题.      ';
  141. choosepaperform.ListBox1.Items.Text:='';
  142. choosepaperform.ListBox2.Items.Text:='';
  143. choosepaperform.ListBox3.Items.Text:='';
  144. choosepaperform.ListBox4.Items.Text:='';
  145. choosepaperform.ListBox5.Items.Text:='';
  146. choosepaperform.ListBox6.Items.Text:='';
  147. if definepaperform.DBEdit3.Text='0' then
  148. choosepaperform.TabSheet1.TabVisible:=false
  149. else
  150. choosepaperform.TabSheet1.TabVisible:=true;
  151. if definepaperform.DBEdit4.Text='0' then
  152. choosepaperform.TabSheet2.TabVisible:=false
  153. else
  154. choosepaperform.TabSheet2.TabVisible:=true;
  155. if definepaperform.DBEdit5.Text='0' then
  156. choosepaperform.TabSheet4.TabVisible:=false
  157. else
  158. choosepaperform.TabSheet4.TabVisible:=true;
  159. if definepaperform.DBEdit12.Text='0' then
  160. choosepaperform.TabSheet3.TabVisible:=false
  161. else
  162. choosepaperform.TabSheet3.TabVisible:=true;
  163. if definepaperform.DBEdit15.Text='0' then
  164. choosepaperform.TabSheet5.TabVisible:=false
  165. else
  166. choosepaperform.TabSheet5.TabVisible:=true;
  167. choosepaperform.show;
  168. definepaperform.Close;
  169. end;
  170. function Tdefinepaperform.checknewshijuan:boolean;
  171. var
  172. success:boolean;
  173. begin
  174. success:=true;
  175. with DataModule4.Table_shijuan do
  176. begin
  177. if DBEdit18.Text='' then
  178. success:=false;
  179. if DBEdit1.Text='' then
  180. success:=false;
  181. if DBEdit3.Text='' then
  182. success:=false;
  183. if DBEdit6.Text='' then
  184. success:=false;
  185. if DBEdit4.Text='' then
  186. success:=false;
  187. if DBEdit7.Text='' then
  188. success:=false;
  189. if DBEdit5.Text='' then
  190. success:=false;
  191. if DBEdit8.Text='' then
  192. success:=false;
  193. if DBEdit12.Text='' then
  194. success:=false;
  195. if DBEdit13.Text='' then
  196. success:=false;
  197. if DBEdit15.Text='' then
  198. success:=false;
  199. if DBEdit16.Text='' then
  200. success:=false;
  201. if not success then
  202. begin
  203. showmessage('红色项必须填写,请补上未填的红色项!');
  204. end;
  205.   checknewshijuan:=success;
  206. end;
  207. end;
  208. procedure Tdefinepaperform.DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
  209. begin
  210. case button of
  211. nbInsert:
  212. begin
  213.  BitBtn3.Enabled:=false;
  214.  BitBtn4.Enabled:=false;
  215. addshijuan:=true;
  216. DBEdit18.Enabled:=true;
  217. DBEdit18.text:=inttostr(newshijuanhao);
  218. DBEdit18.enabled:=false;
  219. end;
  220. end;
  221. case button of
  222. nbDelete:
  223. begin
  224.  query1.close;
  225. query1.sql.clear;
  226. query1.sql.text:='update shijuan set jno=jno-1 where jno>'''+inttostr(updatejno)+''' ';
  227. query1.ExecSQL;
  228. DataModule4.Table_shijuan.Close;
  229. DataModule4.Table_shijuan.open;
  230. end;
  231. end;
  232. end;
  233. procedure Tdefinepaperform.FormCreate(Sender: TObject);
  234. begin
  235. addshijuan:=false;
  236. end;
  237. procedure Tdefinepaperform.FormShow(Sender: TObject);
  238. begin
  239. DataModule4.Table_shijuan.Last;
  240. newshijuanhao:=DataModule4.Table_shijuan.FieldValues['jno']+1;
  241. DataModule4.Table_shijuan.First;
  242. end;
  243. procedure Tdefinepaperform.BitBtn1Click(Sender: TObject);
  244. begin
  245.      if addshijuan then
  246.      begin
  247.        if checknewshijuan then
  248.        begin
  249.        DataModule4.Table_shijuan.Post;
  250.        DataModule4.Table_shijuan.Close;
  251.          DataModule4.Table_shijuan.Open;
  252.        showmessage('新试卷添加成功!');
  253.        
  254.        addshijuan:=false;
  255.        inc(newshijuanhao);
  256.      //  DataModule4.Table_shijuan.UpdateRecord;
  257.        DBNavigator1.CanFocus;
  258.        BitBtn3.Enabled:=true;
  259.       BitBtn4.Enabled:=true;
  260.         end
  261.     else
  262.     exit;
  263. end;
  264. end;
  265. procedure Tdefinepaperform.DBEdit6Change(Sender: TObject);
  266. begin
  267.   sum1:=0;
  268. if   (DBEdit3.Text<>'')and(DBEdit6.Text<>'') then
  269. begin
  270. sum1:=sum1+strtoint(DBEdit3.Text)*strtoint(DBEdit6.Text);
  271. DBEdit9.Text:=inttostr(sum1);
  272. end;
  273. end;
  274. procedure Tdefinepaperform.DBEdit7Change(Sender: TObject);
  275. begin
  276.   sum2:=0;
  277. if   (DBEdit4.Text<>'')and(DBEdit7.Text<>'') then
  278. begin
  279. sum2:=sum2+strtoint(DBEdit4.Text)*strtoint(DBEdit7.Text);
  280. DBEdit10.Text:=inttostr(sum2);
  281. end;
  282. end;
  283. procedure Tdefinepaperform.DBEdit8Change(Sender: TObject);
  284. begin
  285.   sum3:=0;
  286. if   (DBEdit5.Text<>'')and(DBEdit8.Text<>'') then
  287. begin
  288. sum3:=sum3+strtoint(DBEdit5.Text)*strtoint(DBEdit8.Text);
  289. DBEdit11.Text:=inttostr(sum3);
  290. end;
  291. end;
  292. procedure Tdefinepaperform.DBEdit13Change(Sender: TObject);
  293. begin
  294.   sum4:=0;
  295. if   (DBEdit12.Text<>'')and(DBEdit13.Text<>'') then
  296. begin
  297. sum4:=sum4+strtoint(DBEdit12.Text)*strtoint(DBEdit13.Text);
  298. DBEdit14.Text:=inttostr(sum4);
  299. end;
  300. end;
  301. procedure Tdefinepaperform.DBEdit16Change(Sender: TObject);
  302. begin
  303.   sum5:=0;
  304. if   (DBEdit15.Text<>'')and(DBEdit16.Text<>'') then
  305. begin
  306. sum5:=sum5+strtoint(DBEdit15.Text)*strtoint(DBEdit16.Text);
  307. DBEdit17.Text:=inttostr(sum5);
  308. end;
  309. end;
  310. procedure Tdefinepaperform.DBEdit17Change(Sender: TObject);
  311. begin
  312. allsum:=0;
  313. if (DBEdit9.Text<>'')and(DBEdit10.Text<>'')and(DBEdit11.Text<>'')and(DBEdit14.Text<>'')and(DBEdit17.Text<>'')  then
  314.    begin
  315.    allsum:=allsum+sum1+sum2+sum3+sum4+sum5;
  316.      DBEdit2.Text:=inttostr(allsum);
  317.    end;
  318. end;
  319. procedure Tdefinepaperform.DBEdit14Change(Sender: TObject);
  320. begin
  321. allsum:=0;
  322. if (DBEdit9.Text<>'')and(DBEdit10.Text<>'')and(DBEdit11.Text<>'')and(DBEdit14.Text<>'')and(DBEdit17.Text<>'')  then
  323.    begin
  324.    allsum:=allsum+sum1+sum2+sum3+sum4+sum5;
  325.      DBEdit2.Text:=inttostr(allsum);
  326.    end;
  327. end;
  328. procedure Tdefinepaperform.DBEdit11Change(Sender: TObject);
  329. begin
  330. allsum:=0;
  331. if (DBEdit9.Text<>'')and(DBEdit10.Text<>'')and(DBEdit11.Text<>'')and(DBEdit14.Text<>'')and(DBEdit17.Text<>'')  then
  332.    begin
  333.    allsum:=allsum+sum1+sum2+sum3+sum4+sum5;
  334.      DBEdit2.Text:=inttostr(allsum);
  335.    end;
  336. end;
  337. procedure Tdefinepaperform.DBEdit10Change(Sender: TObject);
  338. begin
  339. allsum:=0;
  340. if (DBEdit9.Text<>'')and(DBEdit10.Text<>'')and(DBEdit11.Text<>'')and(DBEdit14.Text<>'')and(DBEdit17.Text<>'')  then
  341.    begin
  342.    allsum:=allsum+sum1+sum2+sum3+sum4+sum5;
  343.      DBEdit2.Text:=inttostr(allsum);
  344.    end;
  345. end;
  346. procedure Tdefinepaperform.DBEdit9Change(Sender: TObject);
  347. begin
  348. allsum:=0;
  349. if (DBEdit9.Text<>'')and(DBEdit10.Text<>'')and(DBEdit11.Text<>'')and(DBEdit14.Text<>'')and(DBEdit17.Text<>'')  then
  350.    begin
  351.    allsum:=allsum+sum1+sum2+sum3+sum4+sum5;
  352.      DBEdit2.Text:=inttostr(allsum);
  353.    end;
  354. end;
  355. procedure Tdefinepaperform.DBEdit3Change(Sender: TObject);
  356. begin
  357.   sum1:=0;
  358. if   (DBEdit3.Text<>'')and(DBEdit6.Text<>'') then
  359. begin
  360. sum1:=sum1+strtoint(DBEdit3.Text)*strtoint(DBEdit6.Text);
  361. DBEdit9.Text:=inttostr(sum1);
  362. end;
  363. end;
  364. procedure Tdefinepaperform.DBEdit4Change(Sender: TObject);
  365. begin
  366.   sum2:=0;
  367. if   (DBEdit4.Text<>'')and(DBEdit7.Text<>'') then
  368. begin
  369. sum2:=sum2+strtoint(DBEdit4.Text)*strtoint(DBEdit7.Text);
  370. DBEdit10.Text:=inttostr(sum2);
  371. end;
  372. end;
  373. procedure Tdefinepaperform.DBEdit5Change(Sender: TObject);
  374. begin
  375.   sum3:=0;
  376. if   (DBEdit5.Text<>'')and(DBEdit8.Text<>'') then
  377. begin
  378. sum3:=sum3+strtoint(DBEdit5.Text)*strtoint(DBEdit8.Text);
  379. DBEdit11.Text:=inttostr(sum3);
  380. end;
  381. end;
  382. procedure Tdefinepaperform.DBEdit12Change(Sender: TObject);
  383. begin
  384.   sum4:=0;
  385. if   (DBEdit12.Text<>'')and(DBEdit13.Text<>'') then
  386. begin
  387. sum4:=sum4+strtoint(DBEdit12.Text)*strtoint(DBEdit13.Text);
  388. DBEdit14.Text:=inttostr(sum4);
  389. end;
  390. end;
  391. procedure Tdefinepaperform.DBEdit15Change(Sender: TObject);
  392. begin
  393.   sum5:=0;
  394. if   (DBEdit15.Text<>'')and(DBEdit16.Text<>'') then
  395. begin
  396. sum5:=sum5+strtoint(DBEdit15.Text)*strtoint(DBEdit16.Text);
  397. DBEdit17.Text:=inttostr(sum5);
  398. end;
  399. end;
  400. procedure Tdefinepaperform.BitBtn3Click(Sender: TObject);
  401. var
  402. i,j:integer;
  403. begin
  404.   paperautoform.ProgressBar1.Position:=0;
  405. for i:=1 to 800 do
  406. begin
  407. paperautoform.thao[i]:=0;
  408.       paperautoform.havetake[i]:=0;
  409.       end;
  410.       for j:=1 to 5 do
  411.       begin
  412.       paperautoform.diff[i]:=0;;
  413.       end;
  414.       paperautoform.Memo1.Text:='';
  415. paperautoform.Show;
  416. end;
  417. procedure Tdefinepaperform.BitBtn2Click(Sender: TObject);
  418. begin
  419. DBNavigator1.BtnClick(nbCancel);
  420. BitBtn3.Enabled:=true;
  421.  BitBtn4.Enabled:=true;
  422. end;
  423. end.