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

百货/超市行业

开发平台:

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.   private
  107.     { Private declarations }
  108.   public
  109.     { Public declarations }
  110.   end;
  111. var
  112.   Main_Form: TMain_Form;
  113. implementation
  114. uses about, datamodule, producetype, putproducet, saleunit, entergoo,
  115.   select, backup, UseLogin, admin_unit, help;
  116. {$R *.dfm}
  117. procedure TMain_Form.Help_AboutClick(Sender: TObject);
  118. begin
  119. AboutBox.show;
  120. end;
  121. procedure TMain_Form.Back_ManageClick(Sender: TObject);
  122. begin
  123. Put_Form.show;
  124. end;
  125. procedure TMain_Form.System_ExitClick(Sender: TObject);
  126. begin
  127. Application.Terminate;
  128. end;
  129. procedure TMain_Form.N1Click(Sender: TObject);
  130. begin
  131.   if N1.Checked then
  132.     begin
  133.          N1.Checked:=false;
  134.          Back_M.visible:=false;
  135.     end
  136.   else
  137.      begin
  138.           N1.Checked:=true;
  139.           Back_M.visible:=true;
  140.       end;
  141. end;
  142. procedure TMain_Form.N2Click(Sender: TObject);
  143. begin
  144.   if N2.Checked then
  145.     begin
  146.          N2.Checked:=false;
  147.          Front_S.visible:=false;
  148.     end
  149.   else
  150.      begin
  151.           N2.Checked:=true;
  152.           Front_S.visible:=true;
  153.       end;
  154. end;
  155. procedure TMain_Form.N3Click(Sender: TObject);
  156. begin
  157.   if N3.Checked then
  158.     begin
  159.          N3.Checked:=false;
  160.          Rave_C.visible:=false;
  161.     end
  162.   else
  163.      begin
  164.           N3.Checked:=true;
  165.           Rave_C.visible:=true;
  166.       end;
  167. end;
  168. procedure TMain_Form.N4Click(Sender: TObject);
  169. begin
  170.   if N4.Checked then
  171.     begin
  172.          N4.Checked:=false;
  173.          Person_M.visible:=false;
  174.     end
  175.   else
  176.      begin
  177.           N4.Checked:=true;
  178.           Person_M.visible:=true;
  179.       end;
  180. end;
  181. procedure TMain_Form.N5Click(Sender: TObject);
  182. begin
  183.   if N5.Checked then
  184.     begin
  185.          N5.Checked:=false;
  186.          Help.visible:=false;
  187.     end
  188.   else
  189.      begin
  190.           N5.Checked:=true;
  191.           Help.visible:=true;
  192.       end;
  193. end;
  194. procedure TMain_Form.Back_TypeClick(Sender: TObject);
  195. begin
  196. PType_Form.show;
  197. end;
  198. procedure TMain_Form.FormActivate(Sender: TObject);
  199. begin
  200.      with datamodule1 do
  201.          begin
  202.              if adoconnection1.connectionstring='' then
  203.                 begin
  204.                   adoconnection1.connectionstring:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+extractfilepath(application.exename)+'datesuper.mdb;Persist Security Info=False';
  205.                   adoconnection1.connected:=true;
  206.                   if not adoquery1.active then
  207.                   adoquery1.open;
  208.                   Login_Form.ShowModal;
  209.                 end;
  210.          end;
  211.      if Login_Form.UseType>1 then
  212.       admin_form.panel1.enabled:=false;
  213.      if Login_Form.UseType>2 then
  214.      begin
  215.      System_M.enabled:=false;
  216.      back_m.enabled:=false;
  217.      person_m.enabled:=false;
  218.      toolbar1.enabled:=false
  219.      end;
  220. end;
  221. procedure TMain_Form.Front_SellClick(Sender: TObject);
  222. begin
  223. Sale_Form.show;
  224. end;
  225. procedure TMain_Form.Back_inputClick(Sender: TObject);
  226. begin
  227. enterFrom.show;
  228. end;
  229. procedure TMain_Form.Back_SelectClick(Sender: TObject);
  230. begin
  231.  sel_From.show;
  232. end;
  233. procedure TMain_Form.Front_dayClick(Sender: TObject);
  234. begin
  235.  with datamodule1.adoquery1 do
  236.  begin
  237.   close;
  238.   SQL.Clear;
  239.   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())');
  240.   Open;
  241.   messagebox(handle,PChar('今日销售额为 '+FieldByName('TDResult').AsString+' 元。'),'今日盘点',MB_ICONinformation+mb_ok);
  242.  end;
  243. end;
  244. procedure TMain_Form.Rave_StoClick(Sender: TObject);
  245. begin
  246. with datamodule1 do
  247. begin
  248. adoquery3.close;
  249. adoquery3.open;
  250. rvproject1.projectfile:=extractfilepath(application.exename)+'Super_report.rav';
  251. rvproject1.execute;
  252. rvproject1.close;
  253. end;
  254. end;
  255. procedure TMain_Form.System_BackClick(Sender: TObject);
  256. begin
  257. backup_From.show;
  258. end;
  259. procedure TMain_Form.Person_SupClick(Sender: TObject);
  260. begin
  261. admin_form.show;
  262. end;
  263. procedure TMain_Form.N6Click(Sender: TObject);
  264. begin
  265.  with datamodule1.adoquery2 do
  266.  begin
  267.   close;
  268.   SQL.Clear;
  269.   SQL.Add('select sum(s_p_price) as TDResult from sell_back_t');
  270.   Open;
  271.   messagebox(handle,PChar('历史记录中共统计销售额: '+FieldByName('TDResult').AsString+' 元。'),'销售统计',MB_ICONinformation+mb_ok);
  272.  end;
  273.  if messagebox(handle,'历史记录删除后不能被恢复,销售数据将被置空!是否清除?','确定清空',mb_iconinformation+mb_yesno)=IDNo then exit;
  274.    with datamodule1.adocommand1 do
  275.     begin
  276.      commandtext:='delete from sell_back_t';
  277.       execute;
  278.       showmessage('清空历史记录的操作成功,为了防止数据库过大,建议您定期清空历史记录!!');
  279.     end;
  280. datamodule1.adoquery2.close;
  281. end;
  282. procedure TMain_Form.ToolButton12MouseMove(Sender: TObject;
  283.   Shift: TShiftState; X, Y: Integer);
  284. begin
  285.  toolbutton12.hint:='数据库备份';
  286. end;
  287. procedure TMain_Form.ToolButton18MouseMove(Sender: TObject;
  288.   Shift: TShiftState; X, Y: Integer);
  289. begin
  290.  toolbutton18.hint:='进货单';
  291. end;
  292. procedure TMain_Form.ToolButton1MouseMove(Sender: TObject;
  293.   Shift: TShiftState; X, Y: Integer);
  294. begin
  295.  toolbutton1.hint:='商品类型';
  296. end;
  297. procedure TMain_Form.ToolButton2MouseMove(Sender: TObject;
  298.   Shift: TShiftState; X, Y: Integer);
  299. begin
  300.  toolbutton2.hint:='商品查询';
  301. end;
  302. procedure TMain_Form.ToolButton3MouseMove(Sender: TObject;
  303.   Shift: TShiftState; X, Y: Integer);
  304. begin
  305.  toolbutton3.hint:='库存管理';
  306. end;
  307. procedure TMain_Form.ToolButton4MouseMove(Sender: TObject;
  308.   Shift: TShiftState; X, Y: Integer);
  309. begin
  310.  toolbutton4.hint:='销售库清理';
  311. end;
  312. procedure TMain_Form.ToolButton16MouseMove(Sender: TObject;
  313.   Shift: TShiftState; X, Y: Integer);
  314. begin
  315.  toolbutton16.hint:='帮助主题';
  316. end;
  317. procedure TMain_Form.ToolButton5MouseMove(Sender: TObject;
  318.   Shift: TShiftState; X, Y: Integer);
  319. begin
  320.  toolbutton5.hint:='关于软件';
  321. end;
  322. procedure TMain_Form.ToolButton8MouseMove(Sender: TObject;
  323.   Shift: TShiftState; X, Y: Integer);
  324. begin
  325.  toolbutton8.hint:='退出系统';
  326. end;
  327. procedure TMain_Form.ToolButton20MouseMove(Sender: TObject;
  328.   Shift: TShiftState; X, Y: Integer);
  329. begin
  330.  toolbutton20.hint:='收银台';
  331. end;
  332. procedure TMain_Form.ToolButton13MouseMove(Sender: TObject;
  333.   Shift: TShiftState; X, Y: Integer);
  334. begin
  335.  toolbutton13.hint:='今日盘点';
  336. end;
  337. procedure TMain_Form.ToolButton14MouseMove(Sender: TObject;
  338.   Shift: TShiftState; X, Y: Integer);
  339. begin
  340.  toolbutton14.hint:='库存报表';
  341. end;
  342. procedure TMain_Form.ToolButton15MouseMove(Sender: TObject;
  343.   Shift: TShiftState; X, Y: Integer);
  344. begin
  345.  toolbutton15.hint:='日销售报表';
  346. end;
  347. procedure TMain_Form.Rave_dayClick(Sender: TObject);
  348. begin
  349. with datamodule1 do
  350. begin
  351. adoquery4.close;
  352. adoquery4.open;
  353. rvproject2.projectfile:=extractfilepath(application.exename)+'Super_report2.rav';
  354. rvproject2.execute;
  355. rvproject2.close;
  356. end;
  357. end;
  358. procedure TMain_Form.Help_TopClick(Sender: TObject);
  359. begin
  360. help_form.show;
  361. end;
  362. end.