unit U_EmployeeInPut; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxMemo, cxRichEdit, ComCtrls, cxContainer, cxTextEdit, cxMaskEdit, cxButtonEdit, StdCtrls, ToolWin, DBClient, ADODB, ExtCtrls, BtnEdit, cxCalendar, StrUtils, cxDropDownEdit, jpeg, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP, cxPC, cxGridCustomPopupMenu, cxGridPopupMenu, Menus, ExtDlgs, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu; type TfrmYGInPut = class(TForm) ToolBar1: TToolBar; TBClose: TToolButton; ADOTemp: TADOQuery; ADOCmd: TADOQuery; TBSave: TToolButton; DataSource1: TDataSource; Order_Sub: TClientDataSet; ToolButton1: TToolButton; ToolButton2: TToolButton; cxGrid1: TcxGrid; Tv1: TcxGridDBTableView; v1YGName: TcxGridDBColumn; v1Column1: TcxGridDBColumn; v1GangWei: TcxGridDBColumn; v1YGSex: TcxGridDBColumn; v1Phone: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; v1RuZhiDate: TcxGridDBColumn; cxGridPopupMenu1: TcxGridPopupMenu; v1SFZNo: TcxGridDBColumn; v1YGNo: TcxGridDBColumn; Tv1Column1: TcxGridDBColumn; Tv1Column2: TcxGridDBColumn; Tv1Column3: TcxGridDBColumn; Tv1Column4: TcxGridDBColumn; Tv1Column5: TcxGridDBColumn; Tv1Column6: TcxGridDBColumn; procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBSaveClick(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure v1SYRNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure v1Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); private TPInt: Integer; procedure InitData(); function SaveData(): Boolean; function SaveMXData(Tv11: TcxGridDBTableView; CDS1: TClientDataSet; FMaxNo, FYOType: string): Boolean; procedure SaveImageOther(); procedure InitImage(); { Private declarations } public canshu1: string; PState, CopyInt: Integer; FMainId, FDPID, FDPName: string; { Public declarations } end; var frmYGInPut: TfrmYGInPut; implementation uses U_DataLink, U_ZDYHelp, U_RTFun; {$R *.dfm} procedure TfrmYGInPut.TBCloseClick(Sender: TObject); begin WriteCxGrid('员工档案录入2', Tv1, '管理'); Close; end; procedure TfrmYGInPut.InitData(); begin with ADOCmd do begin Close; sql.Clear; sql.Add('select * from SY_Employee where EEID=''' + Trim(FMainId) + ''''); Open; end; SCreateCDS(ADOCmd, Order_Sub); SInitCDSData(ADOCmd, Order_Sub); end; procedure TfrmYGInPut.FormShow(Sender: TObject); begin ReadCxGrid('员工档案录入2', Tv1, '管理'); InitData(); end; function TfrmYGInPut.SaveData(): Boolean; var maxno, FHZStatus: string; begin Result := False; try ADOCmd.Connection.BeginTrans; with Order_Sub do begin first; while not eof do begin if Trim(Order_Sub.fieldbyname('EEID').AsString) = '' then begin if GetLSNo(ADOCmd, maxno, 'OA', 'SY_Employee', 4, 1) = False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!', '提示', 0); Exit; end; end else begin maxno := Trim(Order_Sub.fieldbyname('EEID').AsString); end; with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from SY_Employee where EEID=''' + Trim(maxno) + ''''); Open; end; with ADOCmd do begin if ADOCmd.IsEmpty then begin Append; FieldByName('Filler').Value := Trim(DName); end else begin edit; FieldByName('Editer').Value := Trim(DName); FieldByName('Edittime').Value := SGetServerDateTime(ADOTemp); end; FieldByName('EEID').Value := Trim(maxno); FieldByName('EEType').Value := '正式'; fieldbyname('DPID').Value := Trim(FDPID); RTSetSaveDataCDS(ADOCmd, Tv1, Order_Sub, 'SY_Employee', 0); post; end; with ADOCmd do begin Close; SQL.Clear; sql.Add('select * from SY_Employee where EECode=''' + Trim(Order_Sub.fieldbyname('EECode').AsString) + ''''); Open; end; if ADOCmd.RecordCount > 1 then begin ADOCmd.Connection.RollbackTrans; application.MessageBox(PChar('员工编号' + trim(ADOCmd.fieldbyname('EECode').AsString) + '已存在'), '提示'); Exit; end; with Order_Sub do begin Edit; FieldByName('EEID').Value := Trim(maxno); end; with ADOCmd do begin Close; SQL.Clear; sql.Add('exec P_EE_in_Account @DataID=''' + Trim(maxno) + ''''); Open; end; if ADOCmd.FieldByName('intReturn').AsInteger = -1 then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox(PChar(ADOCmd.fieldbyname('ShowMsg').AsString), '提示', 0); exit; end; next; end; end; ADOCmd.Connection.CommitTrans; Result := True; except ; Result := False; ADOCmd.Connection.RollbackTrans; Application.MessageBox('保存失败!', '提示', 0); end; end; function TfrmYGInPut.SaveMXData(Tv11: TcxGridDBTableView; CDS1: TClientDataSet; FMaxNo, FYOType: string): Boolean; begin end; procedure TfrmYGInPut.InitImage(); begin end; procedure TfrmYGInPut.TBSaveClick(Sender: TObject); var FSFNO: string; begin ToolBar1.SetFocus; if Order_Sub.Locate('IdCard', '', []) = true then begin application.MessageBox('身份证不能为空', '提示'); exit; end; if SaveData() then begin Application.MessageBox('保存成功!', '提示', 0); ModalResult := 1; end; end; procedure TfrmYGInPut.SaveImageOther(); begin end; procedure TfrmYGInPut.ToolButton1Click(Sender: TObject); begin with Order_Sub do begin Append; fieldbyname('EntryDate').Value := SGetServerDate(ADOTemp); FieldByName('Dept').Value := Trim(FDPName); Post; end; end; procedure TfrmYGInPut.ToolButton2Click(Sender: TObject); begin if Order_Sub.IsEmpty then Exit; if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; if Trim(Order_Sub.fieldbyname('EEID').AsString) <> '' then begin with ADOCmd do begin Close; sql.Clear; sql.Add('delete SY_Employee where EEID=''' + Trim(Order_Sub.fieldbyname('EEID').AsString) + ''''); ExecSQL; end; with ADOCmd do begin Close; SQL.Clear; sql.Add('exec P_EE_in_Account @DataID=''' + Trim(Order_Sub.fieldbyname('EEID').AsString) + ''''); Open; end; if ADOCmd.FieldByName('intReturn').AsInteger = -1 then begin Application.MessageBox(PChar(ADOCmd.fieldbyname('ShowMsg').AsString), '提示', 0); exit; end; end; Order_Sub.Delete; end; procedure TfrmYGInPut.v1SYRNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin frmZDYHelp := TfrmZDYHelp.Create(self); with frmZDYHelp do begin flag := 'SYRName'; flagName := '车间'; if ShowModal = 1 then begin with Order_Sub do begin edit; FieldByName('SYRName').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; free; end; end; procedure TfrmYGInPut.v1Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'BZName'; flagname := '班组名称'; if ShowModal = 1 then begin with Order_Sub do begin Edit; FieldByName('BZName').Value := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString); end; end; end; finally frmZDYHelp.Free; end; end; end.