UnitMain.pas
资源名称:东之源.rar [点击查看]
上传用户:zexin0769
上传日期:2010-01-19
资源大小:443k
文件大小:14k
源码类别:
百货/超市行业
开发平台:
Delphi
- unit UnitMain;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls, Menus, ImgList, ADODB, mmsystem;
- type
- TForm2 = class(TForm)
- ImageBack: TImage;
- Image2: TImage;
- Image3: TImage;
- Image4: TImage;
- Image1: TImage;
- Image6: TImage;
- Image7: TImage;
- Image111: TImage;
- Image112: TImage;
- Image121: TImage;
- Image122: TImage;
- Image131: TImage;
- Image132: TImage;
- Image142: TImage;
- Image141: TImage;
- Image151: TImage;
- Image152: TImage;
- PopupMenu5: TPopupMenu;
- N1: TMenuItem;
- N2: TMenuItem;
- N3: TMenuItem;
- ImageList1: TImageList;
- PopupMenu1: TPopupMenu;
- N9: TMenuItem;
- PopupMenu2: TPopupMenu;
- PopupMenu3: TPopupMenu;
- N15: TMenuItem;
- N16: TMenuItem;
- N19: TMenuItem;
- N20: TMenuItem;
- N21: TMenuItem;
- N7: TMenuItem;
- N23: TMenuItem;
- N4: TMenuItem;
- N5: TMenuItem;
- N6: TMenuItem;
- N8: TMenuItem;
- ImageBar31: TImage;
- ImageBar32: TImage;
- ImageBar33: TImage;
- ImageBar34: TImage;
- ImageBar11: TImage;
- ImageBar12: TImage;
- ImageBar21: TImage;
- ImageBar22: TImage;
- ImageBar41: TImage;
- procedure Image2Click(Sender: TObject);
- procedure ShowBar(BarNo:Integer);
- procedure ShowMenu(MenuNo:Integer);
- procedure Image3Click(Sender: TObject);
- procedure Image4Click(Sender: TObject);
- procedure Image1Click(Sender: TObject);
- procedure ImageBackMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure Image7Click(Sender: TObject);
- procedure Image6Click(Sender: TObject);
- procedure Image111MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure Image121MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure Image131MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure Image141MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure Image151MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure N3Click(Sender: TObject);
- procedure Image112Click(Sender: TObject);
- procedure Image122Click(Sender: TObject);
- procedure Image132Click(Sender: TObject);
- procedure Image152Click(Sender: TObject);
- procedure Image111Click(Sender: TObject);
- procedure Image121Click(Sender: TObject);
- procedure Image131Click(Sender: TObject);
- procedure Image151Click(Sender: TObject);
- procedure N7Click(Sender: TObject);
- procedure ShowFrame(FrameNo:Integer);
- procedure N23Click(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure FormCreate(Sender: TObject);
- procedure N15Click(Sender: TObject);
- procedure N19Click(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- procedure N9Click(Sender: TObject);
- procedure N20Click(Sender: TObject);
- procedure N5Click(Sender: TObject);
- procedure N16Click(Sender: TObject);
- procedure N6Click(Sender: TObject);
- procedure N2Click(Sender: TObject);
- procedure Image142Click(Sender: TObject);
- procedure ImageBar11Click(Sender: TObject);
- procedure ImageBar12Click(Sender: TObject);
- procedure ImageBar21Click(Sender: TObject);
- procedure ImageBar22Click(Sender: TObject);
- procedure ImageBar31Click(Sender: TObject);
- procedure ImageBar32Click(Sender: TObject);
- procedure ImageBar33Click(Sender: TObject);
- procedure ImageBar34Click(Sender: TObject);
- procedure ImageBar41Click(Sender: TObject);
- procedure N1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form2: TForm2;
- CurrBar: Integer;
- IsCreat: bool;
- implementation
- uses UnitLogin, UnitUserList, UnitProdList, UnitSell, UnitReportProd,
- UnitDbBuckup, UnitReportSell, UnitSellHistory, UnitAbout, UnitHelp;
- {$R *.dfm}
- procedure TForm2.Image2Click(Sender: TObject);
- begin
- ShowBar(2);
- end;
- procedure TForm2.ShowBar(BarNo:Integer);
- var
- i,j:integer;
- AImage:TComponent;
- begin
- if barno>currbar then
- begin
- for i := currbar+1 to barno do
- begin
- Aimage := Form2.FindComponent('Image' + IntToStr(i));
- if Aimage is Timage then TImage(AImage).top := TImage(AImage).top-134;
- end;
- end
- else
- begin
- for i := barno+1 to currbar do
- begin
- Aimage := Form2.FindComponent('Image' + IntToStr(i));
- if Aimage is Timage then TImage(AImage).top := TImage(AImage).top+134;
- end;
- end;
- for i:=1 to 4 do
- for j:=1 to 4 do
- begin
- Aimage := Form2.FindComponent('ImageBar' + IntToStr(i) + IntToStr(j));
- if Aimage is Timage then
- if i=BarNo then
- TImage(AImage).Visible := True
- else
- TImage(AImage).Visible := False;
- end;
- if CurrBar<>BarNo then sndplaysound(pchar(ExeRoot+'soundfolder.wav'),snd_async);
- CurrBar := BarNo;
- end;
- procedure TForm2.ShowMenu(MenuNo:Integer);
- var
- i: integer;
- AImage: TComponent;
- begin
- for i := 1 to 5 do
- begin
- Aimage := Form2.FindComponent('Image1' + IntToStr(i) + '2');
- if i<>MenuNo then
- begin
- TImage(AImage).Visible := False;
- end
- else
- TImage(AImage).Visible := True;
- end;
- end;
- procedure TForm2.Image3Click(Sender: TObject);
- begin
- ShowBar(3);
- end;
- procedure TForm2.Image4Click(Sender: TObject);
- begin
- ShowBar(4);
- end;
- procedure TForm2.Image1Click(Sender: TObject);
- begin
- ShowBar(1);
- end;
- procedure TForm2.ImageBackMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- begin
- ShowMenu(0);
- if (ssleft in shift) then
- begin
- releasecapture;
- perform(wm_syscommand, $f012, 0);
- end;
- end;
- procedure TForm2.Image7Click(Sender: TObject);
- begin
- application.Minimize;
- end;
- procedure TForm2.Image6Click(Sender: TObject);
- begin
- application.Terminate;
- end;
- procedure TForm2.Image111MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- begin
- ShowMenu(1);
- end;
- procedure TForm2.Image121MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- begin
- ShowMenu(2);
- end;
- procedure TForm2.Image131MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- begin
- ShowMenu(3);
- end;
- procedure TForm2.Image141MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- begin
- ShowMenu(4);
- end;
- procedure TForm2.Image151MouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- begin
- ShowMenu(5);
- end;
- procedure TForm2.N3Click(Sender: TObject);
- begin
- form2.Close;
- end;
- procedure TForm2.Image112Click(Sender: TObject);
- begin
- PopupMenu1.Popup(Form2.Left +Image112.Left ,Form2.Top + Image112.Top + Image112.Height + 1);
- end;
- procedure TForm2.Image122Click(Sender: TObject);
- begin
- PopupMenu2.Popup(Form2.Left +Image122.Left ,Form2.Top + Image122.Top + Image122.Height + 1);
- end;
- procedure TForm2.Image132Click(Sender: TObject);
- begin
- PopupMenu3.Popup(Form2.Left +Image132.Left ,Form2.Top + Image132.Top + Image132.Height + 1);
- end;
- procedure TForm2.Image152Click(Sender: TObject);
- begin
- PopupMenu5.Popup(Form2.Left +Image152.Left ,Form2.Top + Image152.Top + Image152.Height + 1);
- end;
- procedure TForm2.Image111Click(Sender: TObject);
- begin
- PopupMenu1.Popup(Form2.Left +Image112.Left ,Form2.Top + Image112.Top + Image112.Height + 1);
- end;
- procedure TForm2.Image121Click(Sender: TObject);
- begin
- PopupMenu2.Popup(Form2.Left +Image122.Left ,Form2.Top + Image122.Top + Image122.Height + 1);
- end;
- procedure TForm2.Image131Click(Sender: TObject);
- begin
- PopupMenu3.Popup(Form2.Left +Image132.Left ,Form2.Top + Image132.Top + Image132.Height + 1);
- end;
- procedure TForm2.Image151Click(Sender: TObject);
- begin
- PopupMenu5.Popup(Form2.Left +Image152.Left ,Form2.Top + Image152.Top + Image152.Height + 1);
- end;
- procedure TForm2.N23Click(Sender: TObject);
- begin
- {用户列表}ShowFrame(1);
- end;
- procedure TForm2.N7Click(Sender: TObject);
- begin
- {商品列表}ShowFrame(2);
- end;
- procedure TForm2.ShowFrame(FrameNo:Integer);
- var
- i: integer;
- begin
- if (UserType<>'管理员') and (FrameNo<>3) then
- begin
- messagebox(handle,'没有足够的权限!','权限不足',MB_ICONWARNING+mb_ok);
- exit;
- end;
- {清除所有的Frame}
- for i:=0 to self.ComponentCount-1 do
- if (self.Components[i] is Tframe) then (self.Components[i] as Tframe).Free;
- {建立相应的Frame}
- case FrameNo of
- 1:
- begin
- with TFrameUserList.Create(self) do
- begin
- Parent := Form2;
- Left := 220;
- Top := 195;
- ADOQuery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DataFile+';Persist Security Info=False';
- ADOQuery1.Active := True;
- Show;
- end;
- end;
- 2:
- begin
- with TFrameProdList.Create(self) do
- begin
- Parent := Form2;
- Left := 220;
- Top := 195;
- ADOQuery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DataFile+';Persist Security Info=False';
- ADOQuery1.Active := True;
- Show;
- end;
- end;
- 3:
- begin
- with TFrameSell.Create(self) do
- begin
- Parent := Form2;
- Left := 220;
- Top := 195;
- ADOQuery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DataFile+';Persist Security Info=False';
- Show;
- end;
- end;
- 4:
- begin
- with TFrameDbBuckup.Create(self) do
- begin
- Parent := Form2;
- Left := 220;
- Top := 195;
- Show;
- end;
- end;
- 5:
- begin
- with TFrameSellHistory.Create(self) do
- begin
- Parent := Form2;
- Left := 220;
- Top := 195;
- ADOQuery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DataFile+';Persist Security Info=False';
- ADOQuery1.Active := True;
- Show;
- end;
- end;
- end;
- end;
- procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- IsCreat := True;
- sndplaysound(pchar(ExeRoot+'soundlogout.wav'),snd_async);
- form1.Show;
- end;
- procedure TForm2.FormCreate(Sender: TObject);
- begin
- CurrBar := 3;
- IsCreat := True;
- end;
- procedure TForm2.N15Click(Sender: TObject);
- begin
- ShowFrame(3);
- end;
- procedure TForm2.N19Click(Sender: TObject);
- begin
- if (UserType<>'管理员') then
- begin
- messagebox(handle,'没有足够的权限!','权限不足',MB_ICONWARNING+mb_ok);
- exit;
- end;
- DbReportProd.ADOQuery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DataFile+';Persist Security Info=False;';
- DbReportProd.ADOQuery1.Active := True;
- DbRePortProd.QuickRep1.Refresh;
- DbReportProd.QuickRep1.Preview;
- end;
- procedure TForm2.FormActivate(Sender: TObject);
- begin
- if IsCreat then
- begin
- sndplaysound(pchar(ExeRoot+'soundlogin.wav'),snd_async);
- ShowBar(3);
- ShowFrame(3);
- IsCreat := False;
- end;
- end;
- procedure TForm2.N9Click(Sender: TObject);
- begin
- ShowFrame(4);
- end;
- procedure TForm2.N20Click(Sender: TObject);
- begin
- if (UserType<>'管理员') then
- begin
- messagebox(handle,'没有足够的权限!','权限不足',MB_ICONWARNING+mb_ok);
- exit;
- end;
- DbReportSell.ADOQuery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DataFile+';Persist Security Info=False;';
- DbReportSell.ADOQuery1.Active := True;
- DbRePortSell.QuickRep1.Refresh;
- DbReportSell.QuickRep1.Preview;
- end;
- procedure TForm2.N5Click(Sender: TObject);
- begin
- Application.Terminate;
- end;
- procedure TForm2.N16Click(Sender: TObject);
- var
- ADOQuery1: TADOQuery;
- begin
- if (UserType<>'管理员') then
- begin
- messagebox(handle,'没有足够的权限!','权限不足',MB_ICONWARNING+mb_ok);
- exit;
- end;
- ADOQuery1:= TADOQuery.Create(self);
- ADOQuery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DataFile+';Persist Security Info=False;';
- ADOQuery1.SQL.Clear;
- ADOQuery1.SQL.Add('select sum(sell_prod_price*sell_number) as TDResult from t_sell where year(sell_time)=year(now()) and month(sell_time)=month(now()) and day(sell_time)=day(now())');
- ADOQuery1.Open;
- messagebox(handle,PChar('今日销售额为 '+ADOQuery1.FieldByName('TDResult').AsString+' 元。'),'今日盘点',MB_ICONinformation+mb_ok);
- ADOQuery1.Free;
- end;
- procedure TForm2.N6Click(Sender: TObject);
- begin
- ShowFrame(5);
- end;
- procedure TForm2.N2Click(Sender: TObject);
- begin
- FormAbout.ShowModal;
- end;
- procedure TForm2.Image142Click(Sender: TObject);
- begin
- if (UserType<>'管理员') then
- begin
- messagebox(handle,'没有足够的权限!','权限不足',MB_ICONWARNING+mb_ok);
- exit;
- end;
- messagebox(handle,'共享版本不提供此功能,要升级软件,请与作者取得联系!','升级软件',MB_ICONinformation+mb_ok);
- end;
- procedure TForm2.ImageBar11Click(Sender: TObject);
- begin
- N23Click(Self);
- end;
- procedure TForm2.ImageBar12Click(Sender: TObject);
- begin
- N9Click(Self);
- end;
- procedure TForm2.ImageBar21Click(Sender: TObject);
- begin
- N7Click(Self);
- end;
- procedure TForm2.ImageBar22Click(Sender: TObject);
- begin
- N19Click(Self);
- end;
- procedure TForm2.ImageBar31Click(Sender: TObject);
- begin
- N15Click(Self);
- end;
- procedure TForm2.ImageBar32Click(Sender: TObject);
- begin
- N20Click(Self);
- end;
- procedure TForm2.ImageBar33Click(Sender: TObject);
- begin
- N6Click(Self);
- end;
- procedure TForm2.ImageBar34Click(Sender: TObject);
- begin
- N16Click(Self);
- end;
- procedure TForm2.ImageBar41Click(Sender: TObject);
- begin
- Image142Click(Self);
- end;
- procedure TForm2.N1Click(Sender: TObject);
- begin
- FormHelp.WebBrowser1.Navigate(ExeRoot+'helpindex.htm');
- FormHelp.ShowModal;
- end;
- end.