📄 mainu.pas
字号:
unit mainu;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, SUISideChannel, ComCtrls, StdCtrls, SUIButton, SUIForm,
Grids, DBGrids, SUIDBCtrls, SUIPageControl, SUIStatusBar, SUITabControl,
SUIImagePanel, Buttons,datau, DB, ADODB, DBCtrls,myvar,allvar,datefmu, Menus,
SUIProgressBar,reportfmu;
type
Tmainfm = class(TForm)
suiFM: TsuiForm;
mainPan: TsuiPanel;
suiPageControl1: TsuiPageControl;
clientDBGrid: TsuiDBGrid;
Splitter1: TSplitter;
clientDS: TDataSource;
clientADOQ: TADOQuery;
ADOConnection: TADOConnection;
clientDBNavi: TDBNavigator;
StatusBar: TPanel;
suiTabSheet1: TsuiTabSheet;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label14: TLabel;
Label19: TLabel;
Label23: TLabel;
Label26: TLabel;
Label40: TLabel;
CB1: TComboBox;
CB2: TComboBox;
CB3: TComboBox;
CB4: TComboBox;
CB5: TComboBox;
CB6: TComboBox;
CB13: TComboBox;
CB16: TComboBox;
CB17: TComboBox;
CB22: TMemo;
Label15: TLabel;
CB7: TComboBox;
Label16: TLabel;
CB8: TComboBox;
Label17: TLabel;
CB14: TComboBox;
Label12: TLabel;
Label13: TLabel;
CB15: TComboBox;
suiSideChannel2: TsuiSideChannel;
suiButton1: TsuiButton;
GroupBox2: TGroupBox;
suiButton2: TsuiButton;
suiButton3: TsuiButton;
suiButton4: TsuiButton;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
CB18: TComboBox;
CB19: TComboBox;
CB20: TComboBox;
CB21: TComboBox;
Label5: TLabel;
Label6: TLabel;
Label27: TLabel;
Label28: TLabel;
CB9: TComboBox;
CB10: TComboBox;
CB11: TComboBox;
CB12: TComboBox;
Label18: TLabel;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
Label24: TLabel;
Label25: TLabel;
zdvedit: TEdit;
CBselete: TComboBox;
CBRange: TComboBox;
CBsort: TComboBox;
Panel2: TPanel;
CK2: TsuiCheckBox;
CK4: TsuiCheckBox;
CK3: TsuiCheckBox;
RB2: TsuiRadioButton;
RB3: TsuiRadioButton;
RB4: TsuiRadioButton;
RB5: TsuiRadioButton;
RB6: TsuiRadioButton;
RB7: TsuiRadioButton;
RB1: TsuiRadioButton;
CK1: TsuiCheckBox;
RB8: TsuiRadioButton;
suiImageButton2: TsuiImageButton;
suiImageButton1: TsuiImageButton;
operationtimeLb: TLabel;
minCB: TComboBox;
maxCB: TComboBox;
sortconvertRB: TsuiRadioButton;
sortRB: TsuiRadioButton;
minbt: TSpeedButton;
maxbt: TSpeedButton;
bt16: TSpeedButton;
ToButsv: TSpeedButton;
ToButla: TSpeedButton;
mcdy: TSpeedButton;
OpenDlgtxt: TOpenDialog;
SaveDlgtxt: TSaveDialog;
suiProgressBar: TsuiProgressBar;
findADOQ: TADOQuery;
allCkB: TsuiCheckBox;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure CBox_setList(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure BTselectallClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BTselectnoClick(Sender: TObject);
procedure ImageDblClick(Sender: TObject);
procedure ImageClick(Sender: TObject);
procedure CBox_loadList(Sender: TObject);
procedure clientaddbutClick(Sender: TObject);
procedure clientmodifybutClick(Sender: TObject);
procedure clientdeletebutClick(Sender: TObject);
procedure clientDBGridMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure selectBtClick(Sender: TObject);
procedure CBRangeChange(Sender: TObject);
procedure databtClick(Sender: TObject);
procedure dbBtClick(Sender: TObject);
procedure mcdyClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
mainfm: Tmainfm;
CK : array[1..4] of TsuiCheckBox;
RB : array[1..8] of TsuiRadioButton;
zdvalue: array[0..30] of string;
zdrange: array[0..5] of string;
zdsort: array[0..10] of string;
select_sentence :string;
clientid :integer;
implementation
uses cmboxsetu , GraphWinu ;
{$R *.dfm}
procedure Tmainfm.FormCreate(Sender: TObject);
var ConnectionString:widestring ;
var i:integer;
begin
clientid:=0;
CK[1]:=ck1; CK[2]:=ck2; CK[3]:=ck3; CK[4]:=ck4; //级别
RB[1]:=rb1; RB[2]:=rb2; RB[3]:=rb3; RB[4]:=rb4;
RB[5]:=rb5; RB[6]:=rb6; RB[7]:=rb7; RB[8]:=rb8;
clientADOQ.Active:=false;
ADOConnection.Connected:=false;
ConnectionString:='Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=';
ConnectionString:=ConnectionString+'"DBQ='+ExtractFilePath( Application.ExeName)+'client.mdb; ';
ConnectionString:=ConnectionString+'Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;"';
ADOConnection.ConnectionString:=ConnectionString;
ADOConnection.Connected:=true;
clientADOQ.Active:=true;
dbgridtitle :=',类型,水平,序号,姓名,年龄,性别,职业,学历,手机,办公电话,宅电,'+
'培训否,回访否,身份证,单位,E-mail,其他,日期,接待人,'+
'预留1,预留2,预留3,预留4,备注,,';
mysetdbgrid(dbgridtitle,clientDBGrid);
i:=0;
CBselete.Items.Add(''); zdvalue[i]:=''; i:=i+1;
CBselete.Items.Add('序号'); zdvalue[i]:='myid'; i:=i+1;
CBselete.Items.Add('姓名'); zdvalue[i]:='name'; i:=i+1;
CBselete.Items.Add('性别'); zdvalue[i]:='sex'; i:=i+1;
CBselete.Items.Add('职业'); zdvalue[i]:='vocation'; i:=i+1;
CBselete.Items.Add('学历'); zdvalue[i]:='education'; i:=i+1; //$$
CBselete.Items.Add('培训否'); zdvalue[i]:='iftrain'; i:=i+1;
CBselete.Items.Add('回访否'); zdvalue[i]:='ifrevert'; i:=i+1;
CBselete.Items.Add('接待人'); zdvalue[i]:='destclerk'; i:=i+1;
i:=0;
CBRange.Items.Add(''); zdrange[i]:=''; i:=i+1;
CBRange.Items.Add('年龄'); zdrange[i]:='age'; i:=i+1;
CBRange.Items.Add('访问日期'); zdrange[i]:='data'; i:=i+1;
i:=0;
CBsort.Items.Add(''); zdsort[i]:='id'; i:=i+1;
CBsort.Items.Add('序号'); zdsort[i]:='myid'; i:=i+1;
CBsort.Items.Add('姓名'); zdsort[i]:='name'; i:=i+1;
CBsort.Items.Add('年龄'); zdsort[i]:='age'; i:=i+1;
CBsort.Items.Add('访问日期'); zdsort[i]:='data'; i:=i+1;
CB16.Text:=mygetdatefu; //日期
CB1.Text:=mygetdatefu; //日期
end;
procedure Tmainfm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
application.Terminate;
end;
procedure Tmainfm.CBox_setList(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if ((Sender as TComboBox).Style<>csSimple) and (key = windows.VK_F1)
then begin
Application.CreateForm(Tcmboxsetfm, cmboxsetfm);
cmboxsetfm.listvalue := (Sender as TComboBox).Items;
cmboxsetfm.filename := (Sender as TComboBox).Name;
cmboxsetfm.ShowModal;
if FileExists(ExtractFilePath(Application.ExeName)+'zd\'+(Sender as TComboBox).Name) then
(Sender as TComboBox).Items.LoadFromFile(ExtractFilePath(Application.ExeName)+'zd\'+(Sender as TComboBox).Name);
end;
end;
procedure Tmainfm.databtClick(Sender: TObject);
begin
getdate:='';
Application.CreateForm(Tdatefm,datefm);
datefm.ShowModal;
if sender=minbt then minCB.Text:= getdate;
if sender=maxbt then maxCB.Text:= getdate;
if sender=bt16 then CB16.Text := getdate;
end;
procedure Tmainfm.CBox_loadList(Sender: TObject);
begin
if ((Sender as TComboBox).Style<>csSimple) and ((Sender as TComboBox).Items.Count=0) then
if FileExists(ExtractFilePath(Application.ExeName)+'zd\'+(Sender as TComboBox).Name) then
(Sender as TComboBox).Items.LoadFromFile(ExtractFilePath(Application.ExeName)+'zd\'+(Sender as TComboBox).Name);
end;
procedure Tmainfm.BTselectallClick(Sender: TObject);
var i:integer;
begin
for i:=1 to length(CK) do
ck[i].Checked:=true;
end;
procedure Tmainfm.BTselectnoClick(Sender: TObject);
var i:integer;
begin
for i:=1 to length(CK) do
ck[i].Checked:=false;
end;
procedure Tmainfm.ImageDblClick(Sender: TObject);
begin
{ Application.CreateForm(TGraphWinfm, GraphWinfm);
GraphWinfm.Image.Picture := (Sender as Timage).Picture;
GraphWinfm.ShowModal ;
(Sender as Timage).Picture := GraphWinfm.Image.Picture }
end;
procedure Tmainfm.ImageClick(Sender: TObject);
begin
//Imageshow.Picture:= (Sender as Timage).Picture;
end;
procedure deldatenoaskpd(quy : TADOQuery; sn , s1,s2:string);
begin
quy.Close;
quy.SQL.Clear;
quy.SQL.Add(' delete from ' + sn + ' where ' + s1 + ' = '+ s2 +' ' ); //id 都是整数
quy.ExecSQL;
end;
procedure selectonepd(quy : TADOQuery; sn , s1,s2:string);
begin
quy.Close;
quy.SQL.Clear;
quy.SQL.Add(' select * from ' + sn + ' where ' + s1 + ' = '+ s2 +' ' ); //id 都是整数
quy.Active := true;
quy.First;
end;
procedure selectallpd(quy : TADOQuery; sn :string);
begin
quy.Close;
quy.SQL.Clear;
quy.SQL.Add(' select * from ' + sn ); //id 都是整数
quy.Active := true;
quy.First;
end;
procedure selectpd(quy : TADOQuery; sn , tj :string);
begin
quy.Close;
quy.SQL.Clear;
quy.SQL.Add(' select * from ' + sn + ' where ' + ' tj ' ); //id 都是整数
quy.Active := true;
quy.First;
end;
procedure Tmainfm.clientaddbutClick(Sender: TObject);
var i,j:integer;
var kind:string;
var level:integer;
var valuest:string;
var DateTime : TDateTime;
begin
clientDBGrid.DataSource.DataSet.Active:=false;
clientDBGrid.DataSource.DataSet.Active:=true;
j:=0;
for i:=1 to length(RB) do
if rb[i].Checked =true
then begin
j:=i;
kind:= rb[i].Caption;
break;
end;
if j=0
then begin
MessageDLG('首先选择培训类型.',mtCONfirmation,[mbok],0);
exit;
end;
j:=0;
for i:=1 to length(CK) do
if ck[i].Checked =true
then begin
j:=i;
level:=j;
break;
end;
if j=0
then begin
MessageDLG('首先选择培训水平.',mtCONfirmation,[mbok],0);
exit;
end;
if not (MessageDLG('确定要加入"'+kind+'"记录吗?',mtCONfirmation,[mbYes,mbNo],0) = mrYes)
then Exit;
DateTime := Time; // store the current date and time
valuest:= kind+','+inttostr(level); //类型 级别
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -