frm_k_yjclpas.pas

来自「是一个用delphi设计的考勤系统」· PAS 代码 · 共 263 行

PAS
263
字号
unit Frm_K_YjclPas;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ModalForm, Menus, StdCtrls, ExtCtrls, DB, DBTables, ComCtrls,
  Buttons, YLabelButton, ChangeImage, ADODB, UErrDisplay, ImgList,
  ModalForm1;

type
  TFrm_K_Yjcl = class(TMyModalForm1)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    GroupBox1: TGroupBox;
    Memo1: TMemo;
    Panel1: TPanel;
    Label1: TLabel;
    Label3: TLabel;
    Label2: TLabel;
    cmbN_kq: TComboBox;
    cmbY_kq: TComboBox;
    cmbrq_yj: TComboBox;
    rbn1: TRadioButton;
    rbn2: TRadioButton;
    TabSheet2: TTabSheet;
    GroupBox2: TGroupBox;
    Memo2: TMemo;
    Panel3: TPanel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    dtpjsrq: TDateTimePicker;
    dtpksrq: TDateTimePicker;
    Panel2: TPanel;
    Image2: TImage;
    BtnInport: TChangeImg;
    LBtnInport: TLabelB;
    ChangeImg1: TChangeImg;
    LabelB1: TLabelB;
    LabelB2: TLabelB;
    BtnEdit: TChangeImg;
    Pkq_M_kqcl: TADOStoredProc;
    pkq_D_MonthKqCn: TADOStoredProc;
    ChangeImg2: TChangeImg;
    LabelB3: TLabelB;
    rbn3: TRadioButton;
    cmbrq_hy: TComboBox;
    procedure FormCreate(Sender: TObject);
    procedure ChangeImg1Click(Sender: TObject);
    procedure rbn1Click(Sender: TObject);
    procedure BtnEditClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frm_K_Yjcl: TFrm_K_Yjcl;

implementation

uses DM_DataModal;

{$R *.dfm}

procedure TFrm_K_Yjcl.FormCreate(Sender: TObject);
var
  qry: TADOQuery;
begin
  borderstyle := bsdialog;
  qry := TADOQuery.create(self);
  try
    with qry do
    begin
      Connection := WindData.AdoConn;
      sql.clear;
      sql.add('select distinct n,y from kq_bcsd');
      open;
      cmbrq_yj.Items.Clear;
      while not eof do
      begin
        cmbrq_yj.Items.Add(fieldbyname('n').asstring + '-' + fieldbyname('y').asstring);
        next;
      end;
    end;
  finally
    qry.free;
  end;
  //-------------------------------还原日期---------------
   qry := TADOQuery.create(self);
    try
    with qry do
    begin
       Connection := WindData.AdoConn;
      sql.clear;
      sql.add('select distinct n,y from Kq_kqqk');
      open;
      cmbrq_hy.Items.Clear;
      while not eof do
      begin
        cmbrq_hy.Items.Add(fieldbyname('n').asstring + '-' + fieldbyname('y').asstring);
        next;
      end;
    end;
  finally
    qry.free;
  end;
  dtpksrq.DateTime := now - 30;
  dtpjsrq.DateTime := now;
end;


procedure TFrm_K_Yjcl.ChangeImg1Click(Sender: TObject);
var
  RetMsg: string;
begin
  inherited;
  if rbn1.Checked then
  begin
    if application.MessageBox('月结后此月的数据将不能修改,是否继续?', '系统提示', mb_okcancel + mb_iconwarning) = id_cancel then exit
  end ;
  if rbn2.Checked then
  begin
    if application.MessageBox('将延用上月班次设置进行此月设置,是否继续?', '系统提示', mb_okcancel + mb_iconwarning) = id_cancel then exit;
  end;
  if rbn3.Checked then
  begin
    if application.MessageBox('将还原月结处理设置,是否继续?', '系统提示', mb_okcancel + mb_iconwarning) = id_cancel then exit;
  end;
  Label2.visible := true;
  Label2.update;
  with pkq_D_MonthKqCn do
  begin
    close;
    try
      if rbn1.Checked then
      begin
        if trim(cmbrq_yj.Text) <> '' then
        begin
          Parameters.ParamByName('@sign').Value := 1;
          Parameters.ParamByName('@n').Value := copy(cmbrq_yj.text, 1, 4);
          Parameters.ParamByName('@y').Value := copy(cmbrq_yj.text, 6, 2);
        end
        else
        begin
          application.MessageBox('请选择月结日期', '系统提示', mb_ok + mb_iconinformation);
          exit;
        end;
      end;
      if rbn2.Checked then
      begin
        if (trim(cmbn_kq.text) <> '') and (trim(cmby_kq.text) <> '') then
        begin
          Parameters.ParamByName('@sign').Value := 2;
          Parameters.ParamByName('@n').Value := trim(cmbn_kq.text);
          Parameters.ParamByName('@y').Value := trim(cmby_kq.text);
        end
        else
        begin
          application.MessageBox('请选择考勤日期', '系统提示', mb_ok + mb_iconinformation);
          exit;
        end;
      end;
      if rbn3.Checked then
      begin
        if trim(cmbrq_hy.Text) <> '' then
        begin
          Parameters.ParamByName('@sign').Value := 3;
          Parameters.ParamByName('@n').Value := copy(cmbrq_hy.text, 1, 4);
          Parameters.ParamByName('@y').Value := copy(cmbrq_hy.text, 6, 2);
        end
        else
        begin
          application.MessageBox('请选择月结日期', '系统提示', mb_ok + mb_iconinformation);
          exit;
        end;
      end ;
      execproc;
      if (Parameters.ParamByName('@RETURN_VALUE').Value <> 0) then
      begin
        RetMsg := Parameters.ParamByName('@retmsg').Value;
        application.messagebox(Pchar(RetMsg), '系统提示', mb_ok + mb_iconinformation);
        Label2.visible := false;
        Label2.update;
        exit;
      end;
      if rbn1.Checked then
        application.messagebox('月结处理完毕!!!', '系统提示', mb_ok + mb_iconinformation) ;
       if rbn2.Checked then
      begin
        application.messagebox('考勤处理完毕!!!', '系统提示', mb_ok + mb_iconinformation);
      end;
     if rbn3.Checked then
      begin
        application.messagebox('还原月结重新处理完毕!!!', '系统提示', mb_ok + mb_iconinformation);
      end;
      cmbrq_yj.Text := '';
      cmbrq_hy.Text := '';
      FormCreate(self);
      cmbrq_yj.Update;
    except
      on E: Exception do
      begin
         if rbn1.Checked then       application.messagebox(pchar(e.Message + '月结处理失败!!!'), '系统提示', mb_ok + mb_iconerror);

         if rbn2.Checked then           application.messagebox(pchar(e.Message + '考勤处理失败!!!'), '系统提示', mb_ok + mb_iconerror);

         if rbn3.Checked then             application.messagebox(pchar(e.Message + '还原月结处理失败!!!'), '系统提示', mb_ok + mb_iconerror);
     end;
    end;
  end;
  Label2.visible := false;
  Label2.update;
end;

procedure TFrm_K_Yjcl.rbn1Click(Sender: TObject);
begin
  inherited;
  BtnInport.Enabled := Rbn2.Checked;
  LBtnInport.Enabled := Rbn2.Checked;
  ChangeImg1.Enabled := Rbn1.Checked;
  LabelB1.Enabled := Rbn1.Checked;
  LabelB3.Enabled :=Rbn3.Checked;
  ChangeImg2.Enabled :=Rbn3.Checked;
end;

procedure TFrm_K_Yjcl.BtnEditClick(Sender: TObject);
var
  RetMsg: string;
begin
  inherited;
  Label4.visible := true;
  Label4.update;
  with Pkq_M_kqcl do
  begin
    Parameters.ParamByName('@kq').Value := '1';
    Parameters.ParamByName('@qq').Value := '1';
    Parameters.ParamByName('@sg').Value := '1';
    Parameters.ParamByName('@ksrq').Value := datetostr(dtpksrq.date);
    Parameters.ParamByName('@jsrq').Value := datetostr(dtpjsrq.date);
    try
      execproc;
      if Parameters.ParamByName('@RETURN_VALUE').Value <> '0' then
      begin
        RetMsg := Parameters.ParamByName('@retmsg').Value;
        application.MessageBox(pchar(RetMsg + #13 + '重新处理失败!'), '系统提示', mb_ok + mb_iconwarning);
        exit;
      end;
      application.messagebox('重新处理完毕!!!', '系统提示', mb_ok + mb_iconinformation);
    except
      on E: Exception do
        application.messagebox(pchar(e.Message + ';重新处理失败!!!'), '系统提示', mb_ok + mb_iconerror);
    end;
  end;
  Label4.visible := false;
  Label4.update;
end;

end.

⌨️ 快捷键说明

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