Main.pas
上传用户:bjkrmsxy
上传日期:2010-01-31
资源大小:9004k
文件大小:11k
源码类别:

百货/超市行业

开发平台:

Delphi

  1. unit Main;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, Menus, Grids, DBGrids, DB, ADODB, ToolWin, ComCtrls, ExtCtrls,
  6.   ImgList, WinSkinData;
  7. type
  8.   TMain_Form = class(TForm)
  9.     Menu1: TMainMenu;
  10.     System_M: TMenuItem;
  11.     Back_M: TMenuItem;
  12.     Front_S: TMenuItem;
  13.     Rave_C: TMenuItem;
  14.     Person_M: TMenuItem;
  15.     Help: TMenuItem;
  16.     System_Tool: TMenuItem;
  17.     System_Back: TMenuItem;
  18.     System_Exit: TMenuItem;
  19.     Back_input: TMenuItem;
  20.     Back_Type: TMenuItem;
  21.     Back_Select: TMenuItem;
  22.     Back_Manage: TMenuItem;
  23.     Front_Sell: TMenuItem;
  24.     Front_day: TMenuItem;
  25.     Rave_Sto: TMenuItem;
  26.     Rave_day: TMenuItem;
  27.     Person_Sup: TMenuItem;
  28.     Person_Comm: TMenuItem;
  29.     Help_Top: TMenuItem;
  30.     Help_About: TMenuItem;
  31.     N1: TMenuItem;
  32.     N2: TMenuItem;
  33.     N3: TMenuItem;
  34.     N4: TMenuItem;
  35.     N5: TMenuItem;
  36.     N6: TMenuItem;
  37.     CoolBar1: TCoolBar;
  38.     ToolBar1: TToolBar;
  39.     ToolBar2: TToolBar;
  40.     ToolBar3: TToolBar;
  41.     Image1: TImage;
  42.     ImageList1: TImageList;
  43.     ToolButton18: TToolButton;
  44.     ImageList2: TImageList;
  45.     ToolButton1: TToolButton;
  46.     ToolButton2: TToolButton;
  47.     ToolButton3: TToolButton;
  48.     ToolButton4: TToolButton;
  49.     ToolButton6: TToolButton;
  50.     ToolButton12: TToolButton;
  51.     ToolButton20: TToolButton;
  52.     ToolButton13: TToolButton;
  53.     ToolButton14: TToolButton;
  54.     ToolButton15: TToolButton;
  55.     ToolButton16: TToolButton;
  56.     ToolButton5: TToolButton;
  57.     ToolButton7: TToolButton;
  58.     ToolButton8: TToolButton;
  59.     SkinData1: TSkinData;
  60.     procedure Help_AboutClick(Sender: TObject);
  61.     procedure Back_ManageClick(Sender: TObject);
  62.     procedure System_ExitClick(Sender: TObject);
  63.     procedure N1Click(Sender: TObject);
  64.     procedure N2Click(Sender: TObject);
  65.     procedure N3Click(Sender: TObject);
  66.     procedure N4Click(Sender: TObject);
  67.     procedure N5Click(Sender: TObject);
  68.     procedure Back_TypeClick(Sender: TObject);
  69.     procedure FormActivate(Sender: TObject);
  70.     procedure Front_SellClick(Sender: TObject);
  71.     procedure Back_inputClick(Sender: TObject);
  72.     procedure Back_SelectClick(Sender: TObject);
  73.     procedure Front_dayClick(Sender: TObject);
  74.     procedure Rave_StoClick(Sender: TObject);
  75.     procedure System_BackClick(Sender: TObject);
  76.     procedure Person_SupClick(Sender: TObject);
  77.     procedure N6Click(Sender: TObject);
  78.     procedure ToolButton12MouseMove(Sender: TObject; Shift: TShiftState; X,
  79.       Y: Integer);
  80.     procedure ToolButton18MouseMove(Sender: TObject; Shift: TShiftState; X,
  81.       Y: Integer);
  82.     procedure ToolButton1MouseMove(Sender: TObject; Shift: TShiftState; X,
  83.       Y: Integer);
  84.     procedure ToolButton2MouseMove(Sender: TObject; Shift: TShiftState; X,
  85.       Y: Integer);
  86.     procedure ToolButton3MouseMove(Sender: TObject; Shift: TShiftState; X,
  87.       Y: Integer);
  88.     procedure ToolButton4MouseMove(Sender: TObject; Shift: TShiftState; X,
  89.       Y: Integer);
  90.     procedure ToolButton16MouseMove(Sender: TObject; Shift: TShiftState; X,
  91.       Y: Integer);
  92.     procedure ToolButton5MouseMove(Sender: TObject; Shift: TShiftState; X,
  93.       Y: Integer);
  94.     procedure ToolButton8MouseMove(Sender: TObject; Shift: TShiftState; X,
  95.       Y: Integer);
  96.     procedure ToolButton20MouseMove(Sender: TObject; Shift: TShiftState; X,
  97.       Y: Integer);
  98.     procedure ToolButton13MouseMove(Sender: TObject; Shift: TShiftState; X,
  99.       Y: Integer);
  100.     procedure ToolButton14MouseMove(Sender: TObject; Shift: TShiftState; X,
  101.       Y: Integer);
  102.     procedure ToolButton15MouseMove(Sender: TObject; Shift: TShiftState; X,
  103.       Y: Integer);
  104.     procedure Rave_dayClick(Sender: TObject);
  105.     procedure Help_TopClick(Sender: TObject);
  106.     procedure Person_CommClick(Sender: TObject);
  107.   private
  108.     { Private declarations }
  109.   public
  110.     { Public declarations }
  111.   end;
  112. var
  113.   Main_Form: TMain_Form;
  114. implementation
  115. uses about, datamodule, producetype, putproducet, saleunit, entergoo,
  116.   select, backup, UseLogin, admin_unit, help;
  117. {$R *.dfm}
  118. procedure TMain_Form.Help_AboutClick(Sender: TObject);
  119. begin
  120. AboutBox.show;
  121. end;
  122. procedure TMain_Form.Back_ManageClick(Sender: TObject);
  123. begin
  124. Put_Form.show;
  125. end;
  126. procedure TMain_Form.System_ExitClick(Sender: TObject);
  127. begin
  128. Application.Terminate;
  129. end;
  130. procedure TMain_Form.N1Click(Sender: TObject);
  131. begin
  132.   if N1.Checked then
  133.     begin
  134.          N1.Checked:=false;
  135.          Back_M.visible:=false;
  136.     end
  137.   else
  138.      begin
  139.           N1.Checked:=true;
  140.           Back_M.visible:=true;
  141.       end;
  142. end;
  143. procedure TMain_Form.N2Click(Sender: TObject);
  144. begin
  145.   if N2.Checked then
  146.     begin
  147.          N2.Checked:=false;
  148.          Front_S.visible:=false;
  149.     end
  150.   else
  151.      begin
  152.           N2.Checked:=true;
  153.           Front_S.visible:=true;
  154.       end;
  155. end;
  156. procedure TMain_Form.N3Click(Sender: TObject);
  157. begin
  158.   if N3.Checked then
  159.     begin
  160.          N3.Checked:=false;
  161.          Rave_C.visible:=false;
  162.     end
  163.   else
  164.      begin
  165.           N3.Checked:=true;
  166.           Rave_C.visible:=true;
  167.       end;
  168. end;
  169. procedure TMain_Form.N4Click(Sender: TObject);
  170. begin
  171.   if N4.Checked then
  172.     begin
  173.          N4.Checked:=false;
  174.          Person_M.visible:=false;
  175.     end
  176.   else
  177.      begin
  178.           N4.Checked:=true;
  179.           Person_M.visible:=true;
  180.       end;
  181. end;
  182. procedure TMain_Form.N5Click(Sender: TObject);
  183. begin
  184.   if N5.Checked then
  185.     begin
  186.          N5.Checked:=false;
  187.          Help.visible:=false;
  188.     end
  189.   else
  190.      begin
  191.           N5.Checked:=true;
  192.           Help.visible:=true;
  193.       end;
  194. end;
  195. procedure TMain_Form.Back_TypeClick(Sender: TObject);
  196. begin
  197. PType_Form.show;
  198. end;
  199. procedure TMain_Form.FormActivate(Sender: TObject);
  200. begin
  201.      with datamodule1 do
  202.          begin
  203.              if adoconnection1.connectionstring='' then
  204.                 begin
  205.                   adoconnection1.connectionstring:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+extractfilepath(application.exename)+'datesuper.mdb;Persist Security Info=False';
  206.                   adoconnection1.connected:=true;
  207.                   if not adoquery1.active then
  208.                   adoquery1.open;
  209.                   Login_Form.ShowModal;
  210.                 end;
  211.          end;
  212.      if Login_Form.UseType>1 then
  213.      begin
  214.       admin_form.panel1.enabled:=false;
  215.       person_sup.enabled:=false;
  216.      end;
  217.      if Login_Form.UseType>2 then
  218.      begin
  219.      System_M.enabled:=false;
  220.      back_m.enabled:=false;
  221.      person_m.enabled:=false;
  222.      toolbar1.enabled:=false
  223.      end;
  224. end;
  225. procedure TMain_Form.Front_SellClick(Sender: TObject);
  226. begin
  227. Sale_Form.show;
  228. end;
  229. procedure TMain_Form.Back_inputClick(Sender: TObject);
  230. begin
  231. enterFrom.show;
  232. end;
  233. procedure TMain_Form.Back_SelectClick(Sender: TObject);
  234. begin
  235.  sel_From.show;
  236. end;
  237. procedure TMain_Form.Front_dayClick(Sender: TObject);
  238. begin
  239.  with datamodule1.adoquery1 do
  240.  begin
  241.   close;
  242.   SQL.Clear;
  243.   SQL.Add('select sum(s_p_price) as TDResult from sell_back_t where year(s_time)=year(now()) and month(s_time)=month(now()) and day(s_time)=day(now())');
  244.   Open;
  245.   messagebox(handle,PChar('今日销售额为 '+FieldByName('TDResult').AsString+' 元。'),'今日盘点',MB_ICONinformation+mb_ok);
  246.  end;
  247. end;
  248. procedure TMain_Form.Rave_StoClick(Sender: TObject);
  249. begin
  250. with datamodule1 do
  251. begin
  252. adoquery3.close;
  253. adoquery3.open;
  254. rvproject1.projectfile:=extractfilepath(application.exename)+'Super_report.rav';
  255. rvproject1.execute;
  256. rvproject1.close;
  257. end;
  258. end;
  259. procedure TMain_Form.System_BackClick(Sender: TObject);
  260. begin
  261. backup_From.show;
  262. end;
  263. procedure TMain_Form.Person_SupClick(Sender: TObject);
  264. begin
  265. admin_form.show;
  266. end;
  267. procedure TMain_Form.N6Click(Sender: TObject);
  268. begin
  269.  with datamodule1.adoquery2 do
  270.  begin
  271.   close;
  272.   SQL.Clear;
  273.   SQL.Add('select sum(s_p_price) as TDResult from sell_back_t');
  274.   Open;
  275.   messagebox(handle,PChar('历史记录中共统计销售额: '+FieldByName('TDResult').AsString+' 元。'),'销售统计',MB_ICONinformation+mb_ok);
  276.  end;
  277.  if messagebox(handle,'历史记录删除后不能被恢复,销售数据将被置空!是否清除?','确定清空',mb_iconinformation+mb_yesno)=IDNo then exit;
  278.    with datamodule1.adocommand1 do
  279.     begin
  280.      commandtext:='delete from sell_back_t';
  281.       execute;
  282.       showmessage('清空历史记录的操作成功,为了防止数据库过大,建议您定期清空历史记录!!');
  283.     end;
  284. datamodule1.adoquery2.close;
  285. end;
  286. procedure TMain_Form.ToolButton12MouseMove(Sender: TObject;
  287.   Shift: TShiftState; X, Y: Integer);
  288. begin
  289.  toolbutton12.hint:='数据库备份';
  290. end;
  291. procedure TMain_Form.ToolButton18MouseMove(Sender: TObject;
  292.   Shift: TShiftState; X, Y: Integer);
  293. begin
  294.  toolbutton18.hint:='进货单';
  295. end;
  296. procedure TMain_Form.ToolButton1MouseMove(Sender: TObject;
  297.   Shift: TShiftState; X, Y: Integer);
  298. begin
  299.  toolbutton1.hint:='商品类型';
  300. end;
  301. procedure TMain_Form.ToolButton2MouseMove(Sender: TObject;
  302.   Shift: TShiftState; X, Y: Integer);
  303. begin
  304.  toolbutton2.hint:='商品查询';
  305. end;
  306. procedure TMain_Form.ToolButton3MouseMove(Sender: TObject;
  307.   Shift: TShiftState; X, Y: Integer);
  308. begin
  309.  toolbutton3.hint:='库存管理';
  310. end;
  311. procedure TMain_Form.ToolButton4MouseMove(Sender: TObject;
  312.   Shift: TShiftState; X, Y: Integer);
  313. begin
  314.  toolbutton4.hint:='销售库清理';
  315. end;
  316. procedure TMain_Form.ToolButton16MouseMove(Sender: TObject;
  317.   Shift: TShiftState; X, Y: Integer);
  318. begin
  319.  toolbutton16.hint:='帮助主题';
  320. end;
  321. procedure TMain_Form.ToolButton5MouseMove(Sender: TObject;
  322.   Shift: TShiftState; X, Y: Integer);
  323. begin
  324.  toolbutton5.hint:='关于软件';
  325. end;
  326. procedure TMain_Form.ToolButton8MouseMove(Sender: TObject;
  327.   Shift: TShiftState; X, Y: Integer);
  328. begin
  329.  toolbutton8.hint:='退出系统';
  330. end;
  331. procedure TMain_Form.ToolButton20MouseMove(Sender: TObject;
  332.   Shift: TShiftState; X, Y: Integer);
  333. begin
  334.  toolbutton20.hint:='收银台';
  335. end;
  336. procedure TMain_Form.ToolButton13MouseMove(Sender: TObject;
  337.   Shift: TShiftState; X, Y: Integer);
  338. begin
  339.  toolbutton13.hint:='今日盘点';
  340. end;
  341. procedure TMain_Form.ToolButton14MouseMove(Sender: TObject;
  342.   Shift: TShiftState; X, Y: Integer);
  343. begin
  344.  toolbutton14.hint:='库存报表';
  345. end;
  346. procedure TMain_Form.ToolButton15MouseMove(Sender: TObject;
  347.   Shift: TShiftState; X, Y: Integer);
  348. begin
  349.  toolbutton15.hint:='日销售报表';
  350. end;
  351. procedure TMain_Form.Rave_dayClick(Sender: TObject);
  352. begin
  353. with datamodule1 do
  354. begin
  355. adoquery4.close;
  356. adoquery4.open;
  357. rvproject2.projectfile:=extractfilepath(application.exename)+'Super_report2.rav';
  358. rvproject2.execute;
  359. rvproject2.close;
  360. end;
  361. end;
  362. procedure TMain_Form.Help_TopClick(Sender: TObject);
  363. begin
  364. help_form.show;
  365. end;
  366. procedure TMain_Form.Person_CommClick(Sender: TObject);
  367. begin
  368. admin_form.show;
  369. end;
  370. end.