⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 u_emp.pas

📁 中控800型号考勤机的自动采集数据程序。能够手动采集
💻 PAS
📖 第 1 页 / 共 2 页
字号:
      continue;
      end;
     end;
     frm_info.CloseInfo;
     application.MessageBox('上传完毕!','提示',MB_OK);
   end;
 end;
end;

procedure TFrm_Emp.cxButton7Click(Sender: TObject);
var aEmpID:integer;
    aErrorID: integer;
    dwMachineNumber: Integer;
    dwEnrollNumber: Integer;
    CardNo: string;
    i: integer;
    aMsg1,aMsg2: string;
begin

 CurDevID := GetMainFormCheckItem;
 if CurDevID<=0 then
 begin
  //exit;
  application.MessageBox('请选择设备并下载其员工信息!','提示',MB_OK);
  exit;
 end;
 if dm.GetDeviceInfo(CurDevID,CurDevIP,CurDevPort,CurDevPW,CurSpec) then
 begin
  if not frm_ChildLoadData.DeviceConnected(2,CurDevID,0,CurDevIP,CurDevPort,CurDevPW,0,aErrorID) then
   begin
    application.MessageBox('连接设备失败!请检查网络!','提示',MB_OK);
    exit;
   end
  else
   begin
     dwMachineNumber := CurDevID;
     if Application.MessageBox(Pchar('确定要从机器上删除所有选择的员工信息?'),'警告',MB_ICONWARNING+MB_YESNO)=IDYES then
     begin
      try
     for i:=CDevList.Items.Count-1 downto 0  do
     begin
       if CDevList.Items.Item[i].Checked then
        begin
         aMsg1 := '删除['+CDevList.Items.Item[i].SubItems[1]+']的信息成功';
         aMsg2 := '删除['+CDevList.Items.Item[i].SubItems[1]+']的信息失败';
         aEmpID := StrToInt(CDevList.Items.Item[i].SubItems[0]);
         dwEnrollNumber := aEmpID;
         //frm_ChildLoadData.CZKEM1.CardNumber[0] := 0;
         if not frm_ChildLoadData.CZKEM1.DeleteEnrollData(dwMachineNumber,dwEnrollNumber,dwMachineNumber,0) then
         begin
          CDevList.Items.Delete(i);
          frm_info.RefreshInfo(aMsg1);
         end
         else
         begin
          frm_info.RefreshInfo(aMsg2);
          continue;
         end;
         end;// end checked;
       end;  //end for
     frm_info.CloseInfo;
     CDevList.Items.BeginUpdate;
     CDevList.Items.EndUpdate;
     //RefreshDevUserInfo;
     except
     application.MessageBox('删除员工失败!','提示',MB_OK);
     end;
    end;  //end if yes
  end; //end else
  end;
end;

procedure TFrm_Emp.cxButton5Click(Sender: TObject);
begin
RefreshDevUserInfo;
end;

procedure TFrm_Emp.cxButton6Click(Sender: TObject);
var aErrorID: integer;
    dwMachineNumber: Integer;
    dwEnrollNumber: Integer;
    aName: WideString;
    aPassword: WideString;
    aPrivilege: Integer;
    aEnabled: WordBool;
    dwPassWord: integer;
    dwEnrollCardNumber: integer;
    CardNo: string;
    aMsg:string;
begin
 CurDevID := GetMainFormCheckItem;
 if CurDevID<=0 then
 begin
 application.MessageBox('请选择设备!','提示',MB_OK);
 exit;
 end;
 if dm.GetDeviceInfo(CurDevID,CurDevIP,CurDevPort,CurDevPW,CurSpec) then
 begin
  if not frm_ChildLoadData.DeviceConnected(2,CurDevID,0,CurDevIP,CurDevPort,CurDevPW,0,aErrorID) then
   begin
    application.MessageBox('连接设备失败!请检查网络!','提示',MB_OK);
    exit;
   end
  else
   begin
    if Application.MessageBox(Pchar('确定要清空IP为'+CurDevIP+'机器上的所有用户信息?'),'警告',MB_ICONWARNING+MB_YESNO)=IDYES then
    begin
    dwMachineNumber := CurDevID;
    if  frm_ChildLoadData.CZKEM1.ReadAllUserID(dwMachineNumber) then
    while frm_ChildLoadData.CZKEM1.GetAllUserInfo(dwMachineNumber,
     dwEnrollNumber,
     aName,
     aPassWord,
     aPrivilege,
     aEnabled) do
     begin
      frm_info.RefreshInfo('正在删除员工编号为:'+IntToStr(dwEnrollNumber)+'的信息!');
      frm_ChildLoadData.CZKEM1.CardNumber[0] := 0;
      if not frm_ChildLoadData.CZKEM1.DeleteEnrollData(dwMachineNumber,dwEnrollNumber,dwMachineNumber,0) then
      begin
       frm_info.RefreshInfo('删除员工编号为:'+IntToStr(dwEnrollNumber)+'成功!');
      end
      else
      begin
       frm_info.RefreshInfo('删除员工编号为:'+IntToStr(dwEnrollNumber)+'失败!');
       continue;
      end;
     end;
    CDevList.Items.Clear;
    frm_info.CloseInfo;
    application.MessageBox('清空成功!','提示',MB_OK);
    end;
   end;
 end;
end;


procedure TFrm_Emp.cxButton12Click(Sender: TObject);
var i,j: integer;
    ifExists: boolean;
    curj: integer;
    HaveUpdate:boolean;
begin
for i:=0 to CEmpList.Items.Count-1 do
begin
 ifExists := false;
 if CEmpList.Items.Item[i].checked then
 begin
  for j:=0 to CDevList.Items.Count-1 do
  begin
   if trim(CDevList.Items.Item[j].SubItems[0])=trim(CEmpList.Items.Item[i].Caption) then
   begin
    ifExists := true;
    curj := j;
    break;
   end;
  end;
 if not ifExists then
  begin
   with CDevList.Items.Add do
   begin
    Caption := '待上传';
    Subitems.Add(CEmpList.Items.Item[i].Caption);
    Subitems.Add(CEmpList.Items.Item[i].SubItems[0]);
    Subitems.Add(CEmpList.Items.Item[i].SubItems[1]);
    imageindex := 3;
   end;
  end
  else
  begin
   with CDevList.Items.Item[curj] do
   begin
    HaveUpdate := false;
    if Subitems[0]<>CEmpList.Items.Item[i].Caption then
    begin
    //Caption := '待上传';
    Subitems[0] := CEmpList.Items.Item[i].Caption;
    HaveUpdate := true;
    end;
    if Subitems[1]<>CEmpList.Items.Item[i].SubItems[0] then
    begin
    Subitems[1] := CEmpList.Items.Item[i].SubItems[0];
    HaveUpdate := true;
    end;
    if Subitems[2]<>CEmpList.Items.Item[i].SubItems[1] then
    begin
    Subitems[2] := CEmpList.Items.Item[i].SubItems[1];
    HaveUpdate := true;
    end;
    if HaveUpdate then
    begin
    imageindex := 3;
    Caption := '待上传';
    end;
   end;//end with
  end;//end exists
 end; //end checked
end; //end for
end;

procedure TFrm_Emp.cxButton11Click(Sender: TObject);
var i,j: integer;
    ifExists: boolean;
    curj: integer;
    HaveUpdate:boolean;
begin
for i:=0 to CEmpList.Items.Count-1 do
begin
 ifExists := false;
 //if CEmpList.Items.Item[i].checked then
 //begin
  for j:=0 to CDevList.Items.Count-1 do
  begin
   if trim(CDevList.Items.Item[j].SubItems[0])=trim(CEmpList.Items.Item[i].Caption) then
   begin
    ifExists := true;
    curj := j;
    break;
   end;
  end;
 if not ifExists then
  begin
   with CDevList.Items.Add do
   begin
    Caption := '待上传';
    Subitems.Add(CEmpList.Items.Item[i].Caption);
    Subitems.Add(CEmpList.Items.Item[i].SubItems[0]);
    Subitems.Add(CEmpList.Items.Item[i].SubItems[1]);
    imageindex := 3;
   end;
  end
  else
  begin
   with CDevList.Items.Item[curj] do
   begin
    HaveUpdate := false;
    if Subitems[0]<>CEmpList.Items.Item[i].Caption then
    begin
    //Caption := '待上传';
    Subitems[0] := CEmpList.Items.Item[i].Caption;
    HaveUpdate := true;
    end;
    if Subitems[1]<>CEmpList.Items.Item[i].SubItems[0] then
    begin
    Subitems[1] := CEmpList.Items.Item[i].SubItems[0];
    HaveUpdate := true;
    end;
    if Subitems[2]<>CEmpList.Items.Item[i].SubItems[1] then
    begin
    Subitems[2] := CEmpList.Items.Item[i].SubItems[1];
    HaveUpdate := true;
    end;
    if HaveUpdate then
    begin
    imageindex := 3;
    Caption := '待上传';
    end;
   end;//end with
  end;//end exists
 //end; //end checked
end; //end for
end;

procedure TFrm_Emp.cxButton9Click(Sender: TObject);
var aEmpID:integer;
    aEmpName: string;
    aCardNo: string;
    i,j: integer;
    ifExists: boolean;
    aPos: integer;
begin
 for i:=0 to CDevList.Items.Count-1 do
 begin
  if CDevList.Items.Item[i].Checked then
  begin
   aEmpID := StrToInt(CDevList.Items.Item[i].SubItems[0]);
   apos := Pos(#0,trim(CDevList.Items.Item[i].SubItems[1]));
   if apos>0 then
    aEmpName := Copy(trim(CDevList.Items.Item[i].SubItems[1]),1,length(trim(CDevList.Items.Item[i].SubItems[1]))-2)
   else
   aEmpName := trim(CDevList.Items.Item[i].SubItems[1]);
   aCardNo := CDevList.Items.Item[i].SubItems[2];
   ifExists := false;
   {for j:=0 to CEmpList.Items.Count-1 do
   begin
    if CEmpList.Items.Item[j].Caption=CDevList.Items.Item[i].SubItems[0] then
    begin
     ifExists := true;
     break;
    end; //end if
   end; //end for  }
   with dm.temp do
   begin
    if active then close;
    sql.Text := 'select count(*) from employee where empid='+IntToStr(aEmpID);
    Open;
    if Fields[0].AsInteger>0 then ifExists := true;
    close;
   end;
   if not ifExists then
   begin
   frm_info.RefreshInfo('正在导入'+aEmpName+'的数据请稍后........');
    with dm.temp do
    begin
     if active then close;
      SQL.Text := 'Insert Employee(EmpID,EmpName,CardNo) values ('+IntToStr(aEmpID)+','+''''+trim(aEmpName)+''''+','+''''+trim(aCardNo)+''''+')';
      try
      ExecSqL;
      except
      end;
    end; //end with
   end; //end not ifexists
  end;//end check
 end;//end for
 frm_info.CloseInfo;
 RefreshDBUserInfo;
end;

procedure TFrm_Emp.cxButton10Click(Sender: TObject);
var aEmpID:integer;
    aEmpName: string;
    aCardNo: string;
    i,j: integer;
    ifExists: boolean;
    apos: integer;
    aSQL: string;
begin
 for i:=0 to CDevList.Items.Count-1 do
 begin
  //if CDevList.Items.Item[i].Checked then
  //begin
   aEmpID := StrToInt(CDevList.Items.Item[i].SubItems[0]);
   //if i=1  then
   //ShowMessage(CDevList.Items.Item[i].SubItems[0]);
   apos := Pos(#0,trim(CDevList.Items.Item[i].SubItems[1]));
   if apos>0 then
    aEmpName := Copy(trim(CDevList.Items.Item[i].SubItems[1]),1,length(trim(CDevList.Items.Item[i].SubItems[1]))-2)
   else
   aEmpName := trim(CDevList.Items.Item[i].SubItems[1]);
   //if i=1 then
   //ShowMessage(CDevList.Items.Item[i].SubItems[1]);
   aCardNo := CDevList.Items.Item[i].SubItems[2];
   //if i=1 then
   //ShowMessage(CDevList.Items.Item[i].SubItems[2]);
   ifExists := false;
   frm_info.RefreshInfo('正在导入'+aEmpName+'的数据请稍后........');
   {for j:=0 to CEmpList.Items.Count-1 do
   begin
    if CEmpList.Items.Item[j].Caption=CDevList.Items.Item[i].SubItems[0] then
    begin
     ifExists := true;
     break;
    end; //end if
   end; //end for}
   with dm.temp do
   begin
    if active then close;
    sql.Text := 'select isnull(count(*),0) from employee where empid='+IntToStr(aEmpID);
    Open;
    if Fields[0].AsInteger>0 then ifExists := true;
    close;
    //sql.Text := 'select count(*) from employee where empid='+IntToStr(aEmpID)
    //           +' and empname='''+aEmpName+'''';
    //Open;
    //if Fields[0].AsInteger<=0 then ifExists := 1;
   end;
   if not ifExists then
   begin
    with dm.temp do
    begin
     if active then close;
     aSQL := 'Insert Employee(EmpID,EmpName,CardNo) values ('+IntToStr(aEmpID)+','+''''+trim(aEmpName)+''''+','+''''+trim(aCardNo)+''''+')';
      SQL.Text := aSQL;//'Insert Employee(EmpID,EmpName,CardNo) values ('+IntToStr(aEmpID)+','+'N'+''''+QuotedStr(aEmpName)+''''+','+''''+trim(aCardNo)+''''+')';
      try
      ExecSqL;
      except
       //ShowMessage(aEmpName);
      end;
    end; //end with
   end; //end not ifexists
  //end;//end check
 end;//end for
 frm_info.CloseInfo;
 RefreshDBUserInfo;
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -