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

📄 sendcard.pas

📁 pasa人力资源考勤管理系统
💻 PAS
📖 第 1 页 / 共 4 页
字号:
     s:='DESC';
   tadodataset(dbgrid8.DataSource.DataSet).Sort :=column.FieldName+' '+s;

end;

procedure Tformcard.Edit3Exit(Sender: TObject);
begin
 if trim(edit3.text)<>'' then
 begin
  adoguasi.Close;
  adoguasi.CommandText:='select * From guasi where workno='''+edit3.Text+''' or cardno='''+edit3.Text+''' or name='''+edit3.Text+'''';
  adoguasi.Open;
 end;
end;

procedure Tformcard.Edit4Exit(Sender: TObject);
begin
 if trim(edit4.text)<>'' then
 begin
  adojieguasi.Close;
  adojieguasi.CommandText:='select * From jieguasi where workno='''+edit4.Text+''' or cardno='''+edit4.Text+''' or name='''+edit4.Text+'''';
  adojieguasi.Open;
 end;
end;

procedure Tformcard.DBEdit8KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var c,n,d,p,g,s:string;
begin
 R:=False;
 if key=vk_return then
 begin
  c:='';n:='';d:='';p:='';g:='';s:='';
  adoguasi.Edit;
  if trim(dbedit8.text)<>'' then
  begin
    getworker(trim(dbedit8.text),c,n,d,p,g,s);
    if trim(c)='' then
      application.messagebox('该员工不存在','Warning',mb_ok+mb_iconwarning)
    else
    begin
          if OpenPort(@clk) then
          begin
              R:=SetBlackCard(clk.hPort, PChar(c));
              if not R then
              begin
                application.MessageBox('对不起,操作失败!','提示',mb_ok+mb_iconwarning);
                exit;
              end
              else
              begin
                adodataset2.Close;
                adodataset2.CommandText:='select dept from pub05010 where dno='''+d+'''';
                adodataset2.Open;
                adoguasimach.Value:=trim(edClock_id.Text);
                adoguasiworkno.AsString:=TRIM(dbedit8.text);
                adoguasicardno.asstring:=c;
                adoguasiname.asstring:=n;
                adoguasidept.asstring:=adodataset2.fieldbyname('dept').asstring;
                adoguasiprof.asstring:=p;
                Adoquery1.close;
                ADOQuery1.sql.clear;
                Adoquery1.sql.add('truncate table  mel08010');
                Adoquery1.sql.Add('insert into  mel08010 select workno,cardno,max(name) name , max(dept) dept, convert(varchar,rq,111) rq  ,sum(price1) money1,min(price2) money2 from mel04010 where rq between '''+copy(datetostr(date()),1,8)+'01'+''' and '''+copy(datetostr(date()),1,8)+inttostr(getdays(copy(datetostr(date()),6,2),copy(datetostr(date()),1,4)))+''' and workno='''+trim(dbedit8.text)+'''  group by workno,cardno,rq');
                Adoquery1.sql.add('truncate table  mel05010 ');
                Adoquery1.SQL.Add('insert mel05010(workno,cardno,name,deptno,money1,money2,rq) ');
                Adoquery1.SQL.Add('select workno,cardno,max(name) name ,max(dept) dept ,sum(price1),min(price2),max(left(rq,7)) ');
                Adoquery1.SQL.Add('from mel08010 where workno='''+trim(dbedit8.text)+''' group by workno,cardno ');
                adoquery1.sql.add('delete jieguasi where workno='''+trim(dbedit8.text)+''' and mach='''+trim(edClock_id.Text)+'''');
                adoquery1.ExecSQL;
                adodataset2.Close;
                adodataset2.CommandText:='select * From mel05010 where workno='''+trim(dbedit8.text)+'''';
                adodataset2.open;

                adoguasi.fieldbyname('money').Asfloat:=adodataset2.fieldbyname('money2').asfloat;
              end;
          end
          else
          begin
           application.MessageBox('没联接好设备,请及时联接!','提示',mb_ok+mb_iconwarning);
           ClosePort(@clk);
          end;
           if adoguasi.state=dsinsert then
           begin
            if r then
            begin
             adoguasi.Post;
             adoguasi.Append;
            end;
           end;
           dbedit8.SetFocus;
    end;
  end;
  end;
end;

procedure Tformcard.DBEdit12KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=vk_return then
begin
 if trim(dbedit12.text)<>'' then
 begin
 R:=False;
 adodataset2.Close ;
 adodataset2.CommandText:='select * from guasi where workno='''+trim(dbedit12.text)+''' and mach='''+trim(edClock_id.Text)+'''';
 adodataset2.Open;
 if not adodataset2.Eof then
 begin
  if OpenPort(@clk) then
  begin
    R:=DeleteBlackCard(clk.hPort, PChar(adodataset2.fieldbyname('cardno').asstring));
    if not R then
    begin
      application.MessageBox('对不起,操作失败!','提示',mb_ok+mb_iconwarning);
      adojieguasi.Cancel;
      exit;
    end
    else
    begin
      adojieguasi.Edit;
      adojieguasimach.Value:=trim(edClock_id.Text);
      adojieguasiworkno.Value:=trim(dbedit12.text);
      adojieguasicardno.Value:=adodataset2.fieldbyname('cardno').asstring;
      adojieguasidept.Value:=adodataset2.fieldbyname('dept').asstring;
      adojieguasiprof.Value:=adodataset2.fieldbyname('prof').asstring;
      adojieguasiname.Value:=adodataset2.fieldbyname('name').asstring;
      adoquery1.Close;
      adoquery1.SQL.Clear;
      adoquery1.SQL.Add('delete guasi where workno='''+trim(dbedit12.text)+''' and mach='''+trim(edClock_id.Text)+'''');
      adoquery1.ExecSQL;
    end;
  end
  else
  begin
    application.MessageBox('没联接好设备,请及时联接!','提示',mb_ok+mb_iconwarning);
    ClosePort(@clk);
  end;
            if adojieguasi.state=dsinsert then
            begin
             if r then
             begin
               adojieguasi.Post;
               adojieguasi.Append;
             end;
            end;
            dbedit12.SetFocus;
 end
 else
 begin
   application.MessageBox('该员工没做挂失处理!','提示',mb_ok+mb_iconwarning);
   dbedit12.SetFocus;
 end;
end;
end;
end;

procedure Tformcard.RadioGroup1Click(Sender: TObject);
begin
   case radiogroup1.ItemIndex of
   0:
     begin

       ADOdaycong.Close;
       adodaycong.CommandText:='select * From daycong order by rq';
       ADOdaycong.Open;
       DataSource3.DataSet:=ADOdaycong;
     end;
   1:begin
       ADOdaytuikuan.Close;
       adodaytuikuan.CommandText:='select * from daytuikuan order by rq';
       ADOdaytuikuan.Open;
       DataSource3.DataSet:=ADOdaytuikuan;
     end;
    end;
end;

procedure Tformcard.RadioGroup2Click(Sender: TObject);
begin
   case radiogroup2.ItemIndex of
   0:
     begin
       ADOmoncong.Close;
       ADOmoncong.Open;
       adodataset6.close;
       adodataset6.Open;
       DataSource5.DataSet:=ADOmoncong;
       datasource6.DataSet:=adodataset6;
     end;
   1:begin
       ADOmontuikuan.Close;
       ADOmontuikuan.Open;
       adodataset4.Close;
       adodataset4.Open;
       DataSource5.DataSet:=ADOmontuikuan;
       datasource6.DataSet:=adodataset4;
     end;
    end;
end;

procedure Tformcard.DBEdit10KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
const
  CtrlWord='FF078069';//IC卡控制字,请不要随便更改
var
  Money, Times, CardStyle, GroupStation, GroupId: Integer;
  day_consumed, day_times, c_month, c_day, c_flag: Integer;//ER-690卡扩展参数
  cardno1,name1,money1,times1,money2:string;
  pwd: array[0..32] of Char;
  CardBuf, NameBuf: array[1..50] of char;
  t1,t2,t3,t4:boolean;
begin
if key=vk_return then
begin
t1:=true;t2:=true;t3:=true;t4:=true;
if OpenPort(@clk) then
begin
        cardno1 := '';
        Name1 := '';
        Money1 := '';
        Times1 := '';
        GroupStation := -1;
        GroupId := 0;
        FillChar(CardBuf, SizeOf(CardBuf), 0);
        FillChar(NameBuf, SizeOf(NameBuf), 0);
        FillChar(Pwd, SizeOf(Pwd), 0);
        if ReadICCardEx(clk.hPort, @CardBuf, @NameBuf, @Pwd, Money, Times, day_consumed, day_times, c_month, c_day, c_flag, GroupStation, GroupId, CardStyle) then
        begin
          //读卡成功
          case CardStyle of
            CARDSTYLE_OLDCARD: Combobox1.ItemIndex:=0; // 标准IC卡格式
            CARDSTYLE_NEWCARD: Combobox1.ItemIndex:=1; // 长IC卡格式
            CARDSTYLE_690CARD: combobox1.ItemIndex:=2; // ER-690新消费机卡格式
          else
            combobox1.ItemIndex:=-1;
          end;
          cardno1 := PChar(@CardBuf);
          Name1   := PChar(@NameBuf);
          Money1  := format('%g', [Money/10]);
          Times1  := format('%d', [Times]);
        end else
        begin
        //读卡错误
         MsgBox(msg_read_iccard_error, MB_ICONERROR);
         t1:=false;
         exit;
        end;
//    Windows.Beep(2500, 150);

         adodataset1.Edit;
        adodataset1operator.asstring:=pubworkname;
        adodataset1cdate.asstring:=datetostr(date);

        if combobox2.Text='标准IC卡格式' then
          CardStyle := CARDSTYLE_OLDCARD // 标准IC卡格式
        else if combobox2.Text='长IC卡格式' then
          CardStyle := CARDSTYLE_NEWCARD // 长IC卡格式
        else if combobox2.Text='新消费机IC卡格式' then
           CardStyle := CARDSTYLE_690CARD // ER-690新消费机卡格式
        else
         CardStyle:=CARDSTYLE_OLDCARD;
        adodataset1cardkind.AsString:=combobox2.Text;
        adodataset1readok.AsBoolean:=true;
        money2:=floattostr(strtofloat(money1)+strtofloat(dbedit1.text));
        Money := Round(StrToFloat(money2)*10);
        Times := StrToIntDef(times1, 0)+1;
        day_consumed:=0;
        day_times:=0;
        c_month:=0;
        c_day:=0;
        c_flag:=0;
        GroupStation := -1;
        GroupId := 0;
        if WriteICCardEx(clk.hPort, PChar(adodataset1cardno.AsString), PChar(adodataset1name.asstring), nil, Money, Times,
                        day_consumed, day_times, c_month, c_day, c_flag, GroupStation, GroupId, CardStyle, False) then
        begin
          //写卡成功操作
          if Length(adodataset1edICCardPwd.Text)=12 then // IC卡密码必须是12位十六进制字符串
          begin
            FillChar(Pwd, SizeOf(Pwd), 0);
            Move(adodataset1edICCardPwd.Text[1], Pwd[0], Length(adodataset1edICCardPwd.Text));  // IC卡A密码
            Move(CtrlWord, Pwd[12], Length(CtrlWord));                    // IC卡控制字
            Move(adodataset1edICCardPwd.Text[1], Pwd[20], Length(adodataset1edICCardPwd.Text)); // IC卡B密码
            if not WriteICCardPassword(clk.hPort, PChar(@Pwd), -1) then
            //注意只有最新的动态库支持Block=-1;
            begin
              MsgBox(msg_write_iccard_pwd_error, MB_ICONERROR);
              exit;
            end;
          end;
        end else
        begin
          //写卡错误
          MsgBox(msg_write_iccard_error, MB_ICONERROR);
          t2:=false;
          exit;
        end;
        Windows.Beep(2500, 100);
end else
begin
        application.MessageBox('没联接好设备,请及时联接!','提示',mb_ok+mb_iconwarning);
        t3:=false;
        ClosePort(@clk);
end;
if t1 and t2 and t3 and t4 then
begin
 adodataset1.Post;
 adodataset1.Append;
end
else
 adodataset1.Cancel;
end;
end;
procedure Tformcard.DBEdit9KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
const
  CtrlWord='FF078069';//IC卡控制字,请不要随便更改
var
  Money, Times, CardStyle, GroupStation, GroupId: Integer;
  day_consumed, day_times, c_month, c_day, c_flag: Integer;//ER-690卡扩展参数
  cardno1,name1,money1,times1,money2:string;
  pwd: array[0..32] of Char;
  CardBuf, NameBuf: array[1..50] of char;
  t1,t2,t3,t4:boolean;
begin
if key=vk_return then
begin
 t1:=true;t2:=true;t3:=true;t4:=true;
 if OpenPort(@clk) then
 begin

        cardno1 := '';
        Name1 := '';
        Money1 := '';
        Times1 := '';
        GroupStation := -1;
        GroupId := 0;
        FillChar(CardBuf, SizeOf(CardBuf), 0);
        FillChar(NameBuf, SizeOf(NameBuf), 0);
        FillChar(Pwd, SizeOf(Pwd), 0);
        if ReadICCardEx(clk.hPort, @CardBuf, @NameBuf, @Pwd, Money, Times, day_consumed, day_times, c_month, c_day, c_flag, GroupStation, GroupId, CardStyle) then
        begin
          //读卡成功
          case CardStyle of
            CARDSTYLE_OLDCARD: Combobox1.ItemIndex:=0; // 标准IC卡格式
            CARDSTYLE_NEWCARD: Combobox1.ItemIndex:=1; // 长IC卡格式
            CARDSTYLE_690CARD: combobox1.ItemIndex:=2; // ER-690新消费机卡格式
          else
            combobox1.ItemIndex:=-1;
          end;
          cardno1 := PChar(@CardBuf);
          Name1   := PChar(@NameBuf);
          Money1  := format('%g', [Money/10]);
          Times1  := format('%d', [Times]);
        end else
        begin
        //读卡错误
         MsgBox(msg_read_iccard_error, MB_ICONERROR);
         t1:=false;
         exit;
        end;
//    Windows.Beep(2500, 150);
        adodataset3.Edit;
        adodataset3operator.asstring:=pubworkname;
        adodataset3cdate.asstring:=datetostr(date);


        if combobox3.Text='标准IC卡格式' then
          CardStyle := CARDSTYLE_OLDCARD // 标准IC卡格式
        else if combobox3.Text='长IC卡格式' then
          CardStyle := CARDSTYLE_NEWCARD // 长IC卡格式
        else if combobox3.Text='新消费机IC卡格式' then
           CardStyle := CARDSTYLE_690CARD // ER-690新消费机卡格式
        else
         CardStyle:=CARDSTYLE_OLDCARD;
        adodataset3cardkind.AsString:=combobox3.Text;

       // money2:=floattostr(strtofloat(money1)+strtofloat(dbedit1.text));
        Money := Round(StrToFloat(money1)*10);
        Times := StrToIntDef(times1, 0);
        day_consumed:=0;
        day_times:=0;
        c_month:=0;
        c_day:=0;
        c_flag:=0;
        GroupStation := -1;
        GroupId := 0;
        if strtofloat(money1)>=strtofloat(dbedit7.Text) then
        begin
          money2:=floattostr(strtofloat(money1)-strtofloat(dbedit7.text));
          money:=Round(StrToFloat(money2)*10);
          if WriteICCardEx(clk.hPort, PChar(adodataset3cardno.AsString), PChar(adodataset3name.asstring), nil, Money, Times,
                          day_consumed, day_times, c_month, c_day, c_flag, GroupStation, GroupId, CardStyle, False) then
          begin
            //写卡成功操作
            if Length(adodataset3edICCardPwd.Text)=12 then // IC卡密码必须是12位十六进制字符串
            begin
              FillChar(Pwd, SizeOf(Pwd), 0);
              Move(adodataset3edICCardPwd.Text[1], Pwd[0], Length(adodataset3edICCardPwd.Text));  // IC卡A密码
              Move(CtrlWord, Pwd[12], Length(CtrlWord));                    // IC卡控制字
              Move(adodataset3edICCardPwd.Text[1], Pwd[20], Length(adodataset3edICCardPwd.Text)); // IC卡B密码
              if not WriteICCardPassword(clk.hPort, PChar(@Pwd), -1) then
              //注意只有最新的动态库支持Block=-1;
              begin
                MsgBox(msg_write_iccard_pwd_error, MB_ICONERROR);
                exit;
              end;
            end;
          end else
          begin
            //写卡错误
            MsgBox(msg_write_iccard_error, MB_ICONERROR);
            t2:=false;
            exit;
          end;

          Windows.Beep(2500, 100);

       end
       else
       begin
         application.messagebox(pchar('卡上余额只有'+money1+',不能退款!'),'Warning',mb_ok+mb_iconwarning) ;
         t3:=false;
       end;
 end
 else
 begin
     application.MessageBox('没联接好设备,请及时联接!','提示',mb_ok+mb_iconwarning);
     ClosePort(@clk);
     t4:=false;
 end;
 if t1 and t2 and t3 and t4 then
 begin
   adodataset3.Post;
   adodataset3.Append;
 end
 else
 begin
   adodataset3.Cancel;

 end;

end;
end;

end.

⌨️ 快捷键说明

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