409 lines
10 KiB
ObjectPascal
409 lines
10 KiB
ObjectPascal
unit U_User10;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, strUtils,Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, Menus, cxLookAndFeelPainters, StdCtrls, cxButtons, DB, ADODB,
|
||
BtnEdit, ComCtrls, ExtCtrls, cxControls, cxContainer, cxEdit, cxImage,
|
||
cxDBEdit, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,ShellAPI,
|
||
IdFTP, cxGraphics, cxLookAndFeels, dxSkinsCore, dxSkinBlack, dxSkinBlue,
|
||
dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom,
|
||
dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle,
|
||
dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary,
|
||
dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin,
|
||
dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins,
|
||
dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
|
||
dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
|
||
dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
|
||
dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinPumpkin,
|
||
dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
|
||
dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
|
||
dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine,
|
||
dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue;
|
||
|
||
type
|
||
TfrmUser10 = class(TForm)
|
||
ADOQueryTmp: TADOQuery;
|
||
ADO_Cmd: TADOQuery;
|
||
Panel1: TPanel;
|
||
userID: TEdit;
|
||
Label1: TLabel;
|
||
sex: TComboBox;
|
||
Label7: TLabel;
|
||
Label9: TLabel;
|
||
InTime: TDateTimePicker;
|
||
Label10: TLabel;
|
||
idNo: TEdit;
|
||
edu: TComboBox;
|
||
Label8: TLabel;
|
||
Label2: TLabel;
|
||
userName: TEdit;
|
||
Udept: TEdit;
|
||
Label5: TLabel;
|
||
Label6: TLabel;
|
||
UType: TEdit;
|
||
cxOK: TcxButton;
|
||
cxClose: TcxButton;
|
||
newPassword: TEdit;
|
||
Label3: TLabel;
|
||
Label4: TLabel;
|
||
DnewPassword: TEdit;
|
||
Label11: TLabel;
|
||
Address: TEdit;
|
||
Label12: TLabel;
|
||
phone: TEdit;
|
||
Label13: TLabel;
|
||
position: TBtnEditC;
|
||
Label14: TLabel;
|
||
fstr1: TEdit;
|
||
Label15: TLabel;
|
||
note: TMemo;
|
||
Label16: TLabel;
|
||
valid: TComboBox;
|
||
Picture4: TcxDBImage;
|
||
FileName: TcxButton;
|
||
cxDBImage1: TcxDBImage;
|
||
FileName1: TcxButton;
|
||
DataSource1: TDataSource;
|
||
ADOQueryImage: TADOQuery;
|
||
IdFTP1: TIdFTP;
|
||
procedure cxCloseClick(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure cxOKClick(Sender: TObject);
|
||
procedure userIDKeyPress(Sender: TObject; var Key: Char);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure positionBtnUpClick(Sender: TObject);
|
||
procedure positionBtnDnClick(Sender: TObject);
|
||
procedure FileNameClick(Sender: TObject);
|
||
procedure Picture4DblClick(Sender: TObject);
|
||
private
|
||
fPassWord:string;
|
||
fIsYGCodezdsc:Boolean;
|
||
procedure DoQuery();
|
||
function SaveData():Boolean;
|
||
// procedure InitImage();
|
||
{ Private declarations }
|
||
public
|
||
formId:integer;
|
||
fuserID:string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmUser10: TfrmUser10;
|
||
|
||
implementation
|
||
uses U_DataLink,U_Fun10,U_ZDYHelp,U_PublicFunction, getpic;
|
||
{$R *.dfm}
|
||
{procedure TfrmUser10.InitImage();
|
||
begin
|
||
with ADOQueryImage do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from TP_File A');
|
||
sql.Add('where TFid='+quotedstr(trim(userID.Text)));
|
||
open;
|
||
end;
|
||
end;}
|
||
function TfrmUser10.SaveData():Boolean;
|
||
begin
|
||
result:=false;
|
||
ADO_Cmd.Connection.BeginTrans;
|
||
try
|
||
{ if trim(newPassword.Text)<>'' then
|
||
fPassWord:=trim(EncryptString(trim(newPassword.text),keys))
|
||
else }
|
||
fPassWord:='';
|
||
with ADO_Cmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' select * from BD_Staff ');
|
||
sql.Add(' where userID='+quotedstr(trim(fuserID)));
|
||
open;
|
||
|
||
if ADO_Cmd.IsEmpty then ADO_Cmd.Append
|
||
else ADO_Cmd.Edit;
|
||
SSetsaveSqlNew(ADO_Cmd,'BD_Staff',Panel1,2);
|
||
ADO_Cmd.FieldByName('userID').Value:=trim(fuserID);
|
||
// ADO_Cmd.FieldByName('username').Value:=trim(username.Text);
|
||
ADO_Cmd.FieldByName('passWord').Value:=trim(fPassWord);
|
||
// ADO_Cmd.FieldByName('Udept').Value:=trim(Udept.Text);
|
||
// ADO_Cmd.FieldByName('UType').Value:=trim(UType.Text);
|
||
if trim(valid.Text)='<27><>' then
|
||
ADO_Cmd.FieldByName('valid').Value:='N'
|
||
else
|
||
ADO_Cmd.FieldByName('valid').Value:='Y';
|
||
ADO_Cmd.FieldByName('isywy').Value:=false;
|
||
ADO_Cmd.Post;
|
||
end;
|
||
with ADO_Cmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' update SY_user SET ');
|
||
if trim(valid.Text)='<27><>' then
|
||
sql.Add(' valid=''N'' ')
|
||
else
|
||
sql.Add(' valid=''Y'' ');
|
||
sql.Add(' where userID='+quotedstr(trim(fuserID)));
|
||
execsql;
|
||
end;
|
||
|
||
ADO_Cmd.Connection.CommitTrans;
|
||
result:=true;
|
||
except
|
||
ADO_Cmd.Connection.RollbackTrans;
|
||
end;
|
||
end;
|
||
procedure TfrmUser10.DoQuery();
|
||
begin
|
||
with adoqueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' select * from BD_Staff A ');
|
||
sql.Add(' where userID='+quotedstr(trim(fuserID)));
|
||
open;
|
||
if not IsEmpty then
|
||
begin
|
||
SCSHDataNew(adoqueryTmp,Panel1,2);
|
||
// userID.Text:=trim(fieldbyname('userID').AsString);
|
||
// userName.Text:=trim(fieldbyname('userName').AsString);
|
||
// Udept.Text:=trim(fieldbyname('Udept').AsString);
|
||
// UType.Text:=trim(fieldbyname('UType').AsString);
|
||
{ if trim(fieldbyname('passWord').AsString)<>'' then
|
||
fPassWord:=trim(DecryptString(trim(fieldbyname('passWord').AsString),keys))
|
||
else }
|
||
fPassWord:='';
|
||
// newPassword.Text:=trim(fPassWord);
|
||
// DnewPassword.Text:=trim(fPassWord);
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmUser10.cxCloseClick(Sender: TObject);
|
||
begin
|
||
close;
|
||
end;
|
||
|
||
procedure TfrmUser10.FormCreate(Sender: TObject);
|
||
begin
|
||
Panel1.Align:=alclient;
|
||
{ with ADO_Cmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from SY_SET');
|
||
open;
|
||
if not IsEmpty then
|
||
begin
|
||
fIsYGCodezdsc:=fieldbyname('IsYGCodezdsc').AsBoolean;
|
||
end;
|
||
end; }
|
||
fIsYGCodezdsc:=true;
|
||
InTime.Date:=strtodate(formatdateTime('yyyy-MM-dd',DServerDate));
|
||
|
||
end;
|
||
|
||
procedure TfrmUser10.cxOKClick(Sender: TObject);
|
||
begin
|
||
if trim(userID.Text)='' then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ',MB_ICONERROR);
|
||
userName.Text;
|
||
exit;
|
||
end;
|
||
if trim(userName.Text)='' then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ',MB_ICONERROR);
|
||
userName.Text;
|
||
exit;
|
||
end;
|
||
if trim(newPassword.Text)<> trim(dnewPassword.Text) then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>벻һ<EBB2BB>£<EFBFBD>','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ',MB_ICONERROR);
|
||
newPassword.Text:='';
|
||
dnewPassword.Text:='';
|
||
exit;
|
||
end;
|
||
if formId=0 then
|
||
begin
|
||
if fIsYGCodezdsc then
|
||
begin
|
||
if not GetMaxBh(ADO_Cmd,fuserID,'BD_Staff','YG','0',3) then exit;
|
||
end
|
||
else
|
||
begin
|
||
fuserID:=trim(userID.Text);
|
||
end;
|
||
|
||
with ADO_Cmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add(' select * from BD_Staff');
|
||
sql.Add(' where userID='+quotedstr(trim(fuserID))) ;
|
||
open;
|
||
if not isempty then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ',MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
end;
|
||
end;
|
||
if SaveData() then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
|
||
ModalResult:=1;
|
||
end
|
||
else
|
||
application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
||
end;
|
||
|
||
procedure TfrmUser10.userIDKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
Key:=UpCase(Key);
|
||
if key=#13 then
|
||
begin
|
||
perform(WM_NEXTDLGCTL,0,0);
|
||
Key := #0;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmUser10.FormShow(Sender: TObject);
|
||
begin
|
||
if formId=0 then
|
||
begin
|
||
if fIsYGCodezdsc then
|
||
begin
|
||
userID.Enabled:=false;
|
||
userID.Text:='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
userID.Enabled:=false;
|
||
end;
|
||
DoQuery();
|
||
// InitImage();
|
||
end;
|
||
|
||
procedure TfrmUser10.positionBtnUpClick(Sender: TObject);
|
||
var
|
||
fsj:string;
|
||
FWZ:Integer;
|
||
begin
|
||
fsj:=Trim(TEdit(Sender).Hint);
|
||
FWZ:=Pos('/',fsj);
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:=Copy(fsj,1,FWZ-1);
|
||
flagname:=Copy(fsj,FWZ+1,Length(fsj)-fwz);
|
||
if Trim(flag)='OrdDefStr2' then
|
||
begin
|
||
V1Name.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
V1Note.Caption:='<27><>ע<EFBFBD><D7A2>Ϣ';
|
||
fnote:=true;
|
||
end;
|
||
if ShowModal=1 then
|
||
begin
|
||
TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmUser10.positionBtnDnClick(Sender: TObject);
|
||
begin
|
||
TBtnEditC(Sender).Text:='';
|
||
TBtnEditC(Sender).TxtCode:='';
|
||
end;
|
||
|
||
procedure TfrmUser10.FileNameClick(Sender: TObject);
|
||
begin
|
||
IF trim(userID.Text)='' then
|
||
begin
|
||
application.MessageBox('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
|
||
try
|
||
FormGetPic := TFormGetPic.Create(Application);
|
||
with FormGetPic do
|
||
begin
|
||
fkeyNO:=trim(userID.Text);
|
||
pat1:=TCXbutton(Sender).Name;
|
||
pic1:=TCXbutton(Sender).Hint;
|
||
FTFType:='Ա<><D4B1><EFBFBD><EFBFBD>Ϣ';
|
||
// pat1:='PatFile1';
|
||
// pic1:='Picture1';
|
||
IF ShowModal = 1 then
|
||
begin
|
||
// self.Timage(Tbutton(Sender).Hint).Picture.Assign(FormGetPic.Image2.Picture.Bitmap);
|
||
userID.Enabled:=false;
|
||
end;
|
||
|
||
Release;
|
||
end;
|
||
// Initimage();
|
||
except
|
||
if FormGetPic<>nil then FormGetPic.Release;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmUser10.Picture4DblClick(Sender: TObject);
|
||
var
|
||
sFieldName:string;
|
||
fileName:string;
|
||
begin
|
||
|
||
IF TcxDBImage(Sender).Picture.Height=0 then exit;
|
||
|
||
sFieldName:=LeftBstr(ExtractFilePath(Application.ExeName),1)+':\ͼƬ<CDBC>鿴';
|
||
|
||
if not DirectoryExists(pchar(sFieldName)) then
|
||
CreateDirectory(pchar(sFieldName),nil);
|
||
|
||
fileName:=adoqueryImage.fieldbyname(TcxDBImage(Sender).Hint).asstring;
|
||
|
||
sFieldName:=sFieldName+'\'+trim(fileName);
|
||
try
|
||
IdFTP1.Host := PicSvr;
|
||
IdFTP1.Username := 'three';
|
||
IdFTP1.Password := '641010';
|
||
IdFTP1.Connect();
|
||
except
|
||
;
|
||
end;
|
||
|
||
if IdFTP1.Connected then
|
||
begin
|
||
try
|
||
IdFTP1.Get('TP\'+ Trim(fileName), sFieldName,false, true);
|
||
except
|
||
Application.MessageBox('<27>ͻ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', MB_ICONWARNING);
|
||
IdFTP1.Quit;
|
||
Exit;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox('<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', MB_ICONWARNING);
|
||
IdFTP1.Quit;
|
||
Exit;
|
||
end;
|
||
if IdFTP1.Connected then IdFTP1.Quit;
|
||
ShellExecute(Handle, 'open',PChar(sFieldName),'', '', SW_SHOWNORMAL);
|
||
end;
|
||
|
||
|
||
end.
|