?? constunt.pas
字號:
unit ConstUnt;
interface
uses
Db, ADODB, Sysutils, Classes, Forms, IniFiles, Windows;
type
TFieldSq = 1..18;
TLogonInf = class
private
FdbJbda: TADOConnection;
FdbCkgl: TADOConnection;
FLogoned: Boolean;
FUserName: ShortString;
FPassWord: ShortString;
FTabNameIndex: Integer;
FFieldNameIndex: Integer;
FOpratorIndex: Integer;
FLinkIndex: Integer;
FNewPassWord: ShortString;
FFunctionLst: TStringList;
FFieldTypeLst: TStringList;
private
function DBConnection: Boolean;
function GetWorkPath: ShortString;
function GetAllUser: TStringList;
function GetPWDCorrect: Boolean;
function GetGhsLst: TStringList;
function GetJldwLst: TStringList;
function GetCklbLst: TStringList;
function GetHwlbLst: TStringList;
function GetPpcdLst: TStringList;
function GetKhmcLst: TStringList;
function GetShrmLst: TStringList;
function GetHwggLst: TStringList;
function GetYsfsLst: TStringList;
function GetShdzLst: TStringList;
function GetJhrmLst: TStringList;
function GetTabEnNameLst: TStringList;
function GetTabCnNameLst: TStringList;
function GetFieldCnNameLst: TStringList;
function GetOpratorCnLst: TStringList;
function GetLinkCnLst: TStringList;
function GetAllRecord(const TabName, FieldName: ShortString)
: TStringList;
function GetCnFieldName(const EnFieldName: ShortString)
: ShortString;
function GetChangePwd: Boolean;
procedure SetLogoned(Value: Boolean);
procedure SetUserName(Value: ShortString);
procedure SetPassWord(Value: ShortString);
procedure SetTabNameIndex(Value: Integer);
procedure SetFieldNameIndex(Value: Integer);
procedure SetOpratorIndex(Value: Integer);
procedure SetLinkIndex(Value: Integer);
procedure SetNewPassWord(Value: ShortString);
protected
constructor Create; virtual;
public
destructor Destroy; override;
published
property WorkPath: ShortString read GetWorkPath;
property Logoned: Boolean read FLogoned write SetLogoned;
property dbJbda: TADOConnection read FdbJbda;
property dbCkgl: TADOConnection read FdbCkgl;
property DBTryConnection: Boolean read DBConnection;
property AllUser: TStringList read GetAllUser;
property UserName: ShortString read FUserName write SetUserName;
property PassWord: ShortString read FPassWord write SetPassWord;
property PWDCorrect: Boolean read GetPWDCorrect;
property GhsLst: TStringList read GetGhsLst;
property JldwLst: TStringList read GetJldwLst;
property CklbLst: TStringList read GetCklbLst;
property HwlbLst: TStringList read GetHwlbLst;
property PpcdLst: TStringList read GetPpcdLst;
property KhmcLst: TStringList read GetKhmcLst;
property ShrmLst: TStringList read GetShrmLst;
property HwggLst: TStringList read GetHwggLst;
property YsfsLst: TStringList read GetYsfsLst;
property ShdzLst: TStringList read GetShdzLst;
property JhrmLst: TStringList read GetJhrmLst;
property TabEnNameLst: TStringList read GetTabEnNameLst;
property TabCnNameLst: TStringList read GetTabCnNameLst;
property CnOpratorLst: TStringList read GetOpratorCnLst;
property CnLinkLst: TStringList read GetLinkCnLst;
property TabNameIndex: Integer read FTabNameIndex write
SetTabNameIndex;
property FieldNameIndex: Integer read FFieldNameIndex write
SetFieldNameIndex;
property OpratorIndex: Integer read FOpratorIndex write
SetOpratorIndex;
property LinkIndex: Integer read FLinkIndex write SetLinkIndex;
property FieldNameLst: TStringList read GetFieldCnNameLst;
property FieldTypeLst: TStringList read FFieldTypeLst;
property ChangePwd: Boolean read GetChangePwd;
property NewPassWord: ShortString write SetNewPassWord;
property FunctionLst: TStringList read FFunctionLst;
public
function GetNextPzh(const TabName, VDate: ShortString)
: ShortString;
function UpdateLog(const Content: string): Boolean;
function UpdateKc(const Ck, Hwlb, Hwgg, Hwdw, Hwcd: string;
const Hwsl, Dj: Double): Boolean;
procedure Ckpd(const PdBeginTime, PdEndTime: string);//倉庫盤點(diǎn)
function Sjbf(const TargetDir: ShortString): Boolean; //數(shù)據(jù)備份
function Sjhf(const FileNames: TStringList): Boolean; //數(shù)據(jù)恢復(fù)
procedure DeletePdData(const TableName: string);
function GetEnFieldName(const CnFieldName: string): string;
end;
(*
- 字符串資源
*)
resourcestring
AppTitle = '倉庫管理系統(tǒng)';
DBConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0;'
+ 'Password="";Data Source=%s;'
+ 'Persist Security Info=True';
SaveError = '保存數(shù)據(jù)中發(fā)生錯(cuò)誤,請重試!';
FTPFailMsg = 'FTP站點(diǎn)連接不成功,請稍后重試!';
AbnormityError = '操作中異常出錯(cuò),請重試!';
UserNameIsEmptyError = '用戶名為空,請重輸!';
NotExistsUser = '用戶名不存在,請重新輸入!';
PassWordError = '輸入%s密碼不正確,請重試!';
PassWordNotSame = '兩次密碼輸入不一致!';
SendPrompt = '確認(rèn)將報(bào)告單報(bào)送[%s]嗎?';
GDateFormat = 'YYYYMMDD';
DateTimeFormat = 'YYYY-MM-DD HH24:MI:SS';
GSptStr = '__^#$%@';
NotFound = '沒有找到符合條件的!';
NotExistPrt = '打印模板文件%s不存在,請檢查!';
NotSaveInf = '是否保存對"%s"內(nèi)容的更改?';
DBConnectFail = '無法與數(shù)據(jù)庫服務(wù)器連接,請查看%s!';
ChnagePwdSuccess = '%s的密碼修改已經(jīng)修改,請記住新密碼!';
UserNameIsEmpty = '請選取用戶再進(jìn)行%s操作!';
SelLocation = '選取備份數(shù)據(jù)位置';
SjbfComplete = '數(shù)據(jù)備份完全無損完成!';
SjhfComplete = '數(shù)據(jù)恢復(fù)完全無損恢復(fù)!';
ReLogon = '您需要重新登陸系統(tǒng)嗎?';
CloseInf = '你真的退出倉庫管理系統(tǒng)嗎?';
NoFind = '對不起,沒有找到相關(guān)數(shù)據(jù)!';
ErrCondition = '請檢查您所選取的條件!';
const
MsgI = '提示';
MsgW = '警告';
MsgE = '錯(cuò)誤';
MsgQ = '詢問';
Msg1IBTN = MB_OK + MB_ICONINFORMATION;
Msg1WBTN = MB_OK + MB_ICONWARNING;
Msg2IBTN = MB_YESNO + MB_ICONINFORMATION;
Msg2QBTN = MB_YESNO + MB_ICONQUESTION;
Msg2WBTN = MB_YESNO + MB_ICONWARNING;
Msg3QBTN = MB_YESNOCANCEL + MB_ICONQUESTION;
Msg3WBTN = MB_YESNO + MB_ICONWARNING;
var
LogonInf: TLogonInf;
function GetTableMaxValue(const DBConnection: TADOConnection;
const TableName: ShortString; const FieldName: ShortString = 'bh')
: Word;
const
En_Oprator: array[0..5] of string =
(
'>',
'<',
'=',
'>=',
'<=',
'<>'
);
Cn_Oprator: array[0..5] of string =
(
'大于',
'小于',
'等于',
'大于等于',
'小于等于',
'不等于'
);
En_Link: array[0..2] of string =
(
' ',
'and',
'or '
);
Cn_Link: array[0..2] of string =
(
'無',
'與',
'或'
);
implementation
const
CkEnTab: array[0..6] of string =
(
'rk', 'ck', 'tk', 'dk', 'gh', 'pd', 'jc'
);
CkCNTab: array[0..6] of string =
(
'入庫', '出庫', '退庫', '調(diào)庫', '歸還', '盤點(diǎn)', '借出'
);
En_FieldName: array[0..47] of string =
(
'bh',
'shr',
'hplb',
'cd',
'gg',
'jldw',
'rkrq',
'pzh',
'ghs',
'cfck',
'rkdj',
'rksl',
'rkze',
'mem',
'czy',
'ckrq',
'khmz',
'chck',
'shdz',
'yxfs',
'ckdj',
'cksl',
'ckze',
'tkrq',
'ghbm',
'tkdj',
'tksl',
'tkze',
'dkrq',
'dcck',
'drck',
'dkdj',
'djsl',
'dkze',
'jcrq',
'jhr',
'jcck',
'jcsl',
'hhrq',
'hhr',
'ghck',
'ghsl',
'whsl',
'pdrq',
'pdck',
'pky',
'dj',
'ze'
);
Cn_FieldName: array[0..47] of string =
(
'編號',
'送貨人',
'貨品類別',
'品牌/產(chǎn)地',
'規(guī)格',
'計(jì)量單位',
'入庫日期',
'憑證號',
'供貨商',
'存放倉庫',
'入庫單價(jià)',
'入庫數(shù)量',
'入庫總額',
'備注',
'操作員',
'出庫日期',
'客戶名稱',
'出貨倉庫',
'收貨地址',
'運(yùn)輸方式',
'出庫單價(jià)',
'出庫數(shù)量',
'出庫總額',
'退庫日期',
'供貨部門',
'退庫單價(jià)',
'退庫數(shù)量',
'退庫總額',
'調(diào)庫日期',
'調(diào)出倉庫',
'調(diào)入倉庫',
'調(diào)庫單價(jià)',
'調(diào)庫數(shù)量',
'調(diào)庫總額',
'借貨日期',
'借貨人',
'借出倉庫',
'借出數(shù)量',
'還貨日期',
'還貨人',
'歸還倉庫',
'歸還數(shù)量',
'未還數(shù)量',
'盤點(diǎn)日期',
'盤點(diǎn)倉庫',
'盤虧/贏',
'單價(jià)',
'總額'
);
function GetTableMaxValue(const DBConnection: TADOConnection;
const TableName: ShortString; const FieldName: ShortString = 'bh')
: Word;
begin
with TADOQuery.Create(nil) do
try
Connection := DBConnection;
Close;
SQL.Clear;
SQL.Add('select max(%s) from %s');
SQL.Text := Format(SQL.Text, [FieldName, TableName]);
Open;
Result := Fields[0].AsInteger + 1;
Close;
finally
Free;
end;
end;
function TLogonInf.GetAllUser: TStringList;
begin
Result := TStringList.Create;
Result.Clear;
with TADOQuery.Create(nil) do
try
Connection := FdbJbda;
Close;
SQL.Clear;
SQL.Add('select name from czy');
Open;
while not Eof do
begin
Result.Add(Format('%s', [Fields[0].AsString]));
Next;
end;
Close;
finally
Free;
end;
end;
function TLogonInf.DBConnection: Boolean;
begin
Result := True;
with TIniFile.Create(WorkPath + 'infor.ini') do
try
try
FdbJbda := TADOConnection.Create(nil);
FdbCkgl := TADOConnection.Create(nil);
FdbJbda.ConnectionString := Format(DBConnectionString,
[workpath+'JBDA.MDB']);
FdbCkgl.ConnectionString := Format(DBConnectionString,
[workpath+'ckgl.mdb']);
FdbJbda.LoginPrompt := False;
FdbCkgl.LoginPrompt := False;
FdbJbda.Connected := True;
FdbCkgl.Connected := True;
except
MessageBox(0, PChar(Format(DBConnectFail, ['本地庫'])),
MsgI, Msg1IBTN);
FdbJbda.Free;
FdbCkgl.Free;
Result := False;
end;
finally
Free;
end;
end;
function TLogonInf.GetWorkPath: ShortString;
begin
Result := ExtractFilePath(Application.ExeName);
end;
procedure TLogonInf.SetLogoned(Value: Boolean);
begin
FLogoned := Value;
end;
constructor TLogonInf.Create;
begin
end;
destructor TLogonInf.Destroy;
begin
FdbJbda.Connected := False;
FdbCkgl.Connected := False;
FdbJbda.Free;
FdbCkgl.Free;
end;
procedure TLogonInf.SetUserName(Value: ShortString);
begin
FUserName := Value;
end;
procedure TLogonInf.SetPassWord(Value: ShortString);
begin
FPassWord := Value;
end;
function TLogonInf.GetPWDCorrect: Boolean;
var
I: Byte;
FieldSqStr,teststr: string;
begin
for I := Low(TFieldSq) to High(TFieldSq) do
FieldSqStr := FieldSqStr + '[' + IntToStr(I) + '], ';
FieldSqStr := Copy(FieldSqStr, 1, Length(FieldSqStr) - 2);
with TADOQuery.Create(nil) do
try
Connection := FdbJbda;
Close;
SQL.Clear;
SQL.Add('select name, mm, %s from czy where name = '''
+ FUserName + #39);
SQL.Text := Format(SQL.Text, [FieldSqStr]);
Open;
Result := Fields[1].AsString = FPassWord;
if Result then
begin
FFunctionLst := TStringList.Create;
FFunctionLst.Clear;
for I := 2 to FieldCount - 1 do begin
teststr:=Fields [i].AsString ;
FFunctionLst.Add(Fields[I].AsString);
end;
end;
Close;
finally
Free;
end;
end;
function TLogonInf.GetGhsLst: TStringList;
begin
Result := GetAllRecord('ghs', 'ghsname');
end;
function TLogonInf.GetJldwLst: TStringList;
begin
Result := GetAllRecord('jldw', 'jldw');
end;
function TLogonInf.GetCklbLst: TStringList;
begin
Result := GetAllRecord('cklb', 'cklb');
end;
function TLogonInf.GetHwlbLst: TStringList;
begin
Result := GetAllRecord('hwlb', 'hwlb');
end;
function TLogonInf.GetPpcdLst: TStringList;
begin
Result := GetAllRecord('ghs', 'dz');
end;
function TLogonInf.GetKhmcLst: TStringList;
begin
Result := GetAllRecord('kh', 'khname');
end;
function TLogonInf.GetShrmLst: TStringList;
begin
Result := TStringList.Create;
with TADOQuery.Create(nil) do
try
Connection := FdbCkgl;
Prepared;
Close;
SQL.Clear;
SQL.Add('select shr from rk group by shr');
Open;
while not Eof do
begin
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -