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

📄 xg_dj.pas

📁 汽配前台收费,一个具有详细功能的小系统
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit xg_dj;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, DBTables, StdCtrls, Buttons, Mask, ExtCtrls, Printers;

type
  Tfrm_xg_dj = class(TForm)
    pe_bh: TPanel;
    Label1: TLabel;
    combo_p: TComboBox;
    pe_edit: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    txt_dj_time: TMaskEdit;
    txt_jc_time: TMaskEdit;
    gb_std_info: TGroupBox;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label12: TLabel;
    txt_cph: TEdit;
    txt_cx: TEdit;
    txt_dph: TEdit;
    txt_fdjh: TEdit;
    txt_cz: TEdit;
    txt_tel: TEdit;
    txt_czdw: TEdit;
    txt_addr: TEdit;
    cb_yj: TCheckBox;
    cb_bx: TCheckBox;
    pe_yj: TPanel;
    Label11: TLabel;
    txt_yj: TEdit;
    Panel3: TPanel;
    lbl_kind: TLabel;
    combo_bx_kind: TComboBox;
    combo_wx_kind: TComboBox;
    Panel4: TPanel;
    cmd_edit: TBitBtn;
    cmd_save: TBitBtn;
    cmd_cancel: TBitBtn;
    cmd_print: TBitBtn;
    cmd_refresh: TBitBtn;
    qe_jy: TQuery;
    qe_cl: TQuery;
    sp_up_cl_dj: TStoredProc;
    qe_bx: TQuery;
    txt_bh: TMaskEdit;
    cmd_q: TBitBtn;
    sp_insert_into_day: TStoredProc;
    sp_insert_into_sj: TStoredProc;
    //
    procedure controlChange1(Sender: TObject);
    procedure controlKeyPress1(Sender: TObject; var Key: Char);
    procedure controlKeyPress2(Sender: TObject; var Key: Char);
    procedure controlKeyPress3(Sender: TObject; var Key: Char);
    procedure cmd_qClick(Sender: TObject);
    procedure cmd_editClick(Sender: TObject);
    procedure cmd_saveClick(Sender: TObject);
    procedure cmd_cancelClick(Sender: TObject);
    procedure cmd_refreshClick(Sender: TObject);
    procedure cb_yjClick(Sender: TObject);
    procedure cb_bxClick(Sender: TObject);
    procedure cmd_printClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    cur_bh: string;
    YJ_BH: string;
    //
    procedure QueryResult;
    procedure EnabledComponent(intState: TDataSetState);
    procedure controlSetFocus(intpos: integer);
    procedure controlDj(intState: TDataSetState);
    procedure EditInit;
    procedure SaveInit;
    procedure CancelInit;
    function RuleCheck: integer;
    //
    function SetNewBH1(intKind: integer): string;
  public
    { Public declarations }
  end;

var
  frm_xg_dj: Tfrm_xg_dj;

implementation

{$R *.DFM}

uses
  log, main, print, yj_select;

function Tfrm_xg_dj.SetNewBH1(intKind: integer): string;
var
  intR_m, intR_d: integer;
  stryear, strmonth, strday: string;
  year1, month1, day1: Word;
  strm, strd: string;
  strResult: string;
begin
  DecodeDate(Now, year1, month1, day1);
  stryear := IntToStr(year1);
  strmonth := Format('%2.2d', [month1]);
  strday := Format('%2.2d', [day1]);
  //
  qe_jy.Close;
  qe_jy.SQL.Clear;
  qe_jy.SQL.Add('SELECT * FROM SJ_SUM WHERE SJ_YEAR = ' + IntToStr(year1) + ' AND SJ_MONTH = ' + IntToStr(month1) + ' AND SJ_DAY = ' + IntToStr(day1) + ' AND SJ_KIND = ' + IntToStr(intKind) + ' ');
  qe_jy.Open;
  qe_jy.Last;
  intR_d := qe_jy.RecordCount;
  //
  qe_jy.Close;
  qe_jy.SQL.Clear;
  qe_jy.SQL.Add('SELECT * FROM SJ_SUM WHERE SJ_YEAR = ' + IntToStr(year1) + ' AND SJ_MONTH = ' + IntToStr(month1) + ' AND SJ_KIND = ' + IntToStr(intKind) + ' ');
  qe_jy.Open;
  qe_jy.Last;
  intR_m := qe_jy.RecordCount;
  qe_jy.Close;
  //
  if (intR_m = 0) and (intR_d = 0) then begin
    strResult := stryear + strmonth + strday + '-' + '001' + '-' + '001';
  end else if intR_m = 0 then begin
    strResult := stryear + strmonth + strday + '-' + '001' + '-' + '001';
  end else if intR_d = 0 then begin
    intR_m := intR_m + 1;
    strm := Format('%3.3d', [intR_m]);
    strResult := stryear + strmonth + strday + '-' + strm + '-' + '001';
  end else begin
    intR_m := intR_m + 1;
    intR_d := intR_d + 1;
    strm := Format('%3.3d', [intR_m]);
    strd := Format('%3.3d', [intR_d]);
    strResult := stryear + strmonth + strday + '-' + strm + '-' + strd;
  end;
  //
  sp_insert_into_sj.ParamByName('@iyear').Value := year1;
  sp_insert_into_sj.ParamByName('@imonth').Value := month1;
  sp_insert_into_sj.ParamByName('@iday').Value := day1;
  sp_insert_into_sj.ParamByName('@ikind').Value := intKind;
  sp_insert_into_sj.ExecProc;
  //
  Result := strResult;
end;

procedure Tfrm_xg_dj.CancelInit;
begin
  qe_cl.Cancel;
  //
  txt_cph.Text := Trim(qe_cl.FieldByName('dj_cph').AsString);
  txt_cx.Text := Trim(qe_cl.FieldByName('dj_cx').AsString);
  txt_dph.Text := Trim(qe_cl.FieldByName('dj_dph').AsString);
  txt_fdjh.Text := Trim(qe_cl.FieldByName('dj_fdjh').AsString);
  txt_cz.Text := Trim(qe_cl.FieldByName('dj_cz').AsString);
  txt_czdw.Text := Trim(qe_cl.FieldByName('dj_czdw').AsString);
  txt_tel.Text := Trim(qe_cl.FieldByName('dj_tel').AsString);
  txt_addr.Text := Trim(qe_cl.FieldByName('dj_addr').AsString);
  txt_dj_time.EditText := Trim(qe_cl.FieldByName('dj_time').AsString);
  txt_jc_time.EditText := Trim(qe_cl.FieldByName('dj_jctime').AsString);
  //
  if qe_cl.FieldByName('dj_bx_bs').AsInteger = 1 then begin
    cb_bx.Checked := True;
    lbl_kind.Caption := '保险类型:';
    combo_bx_kind.ItemIndex := combo_bx_kind.Items.IndexOf(Trim(qe_cl.FieldByName('dj_bx_kind').AsString));
    combo_wx_kind.Visible := False;
    combo_bx_kind.Visible := True;
  end else begin
    cb_bx.Checked := False;
    lbl_kind.Caption := '维修类型:';
    combo_wx_kind.ItemIndex := combo_wx_kind.Items.IndexOf(Trim(qe_cl.FieldByName('dj_wx_kind').AsString));
    combo_wx_kind.Visible := True;
    combo_bx_kind.Visible := False;
  end;
  //
  if qe_cl.FieldByName('dj_yj_bs').AsInteger = 1 then begin
    cb_yj.Checked := True;
    txt_yj.Text := FloatToStr(qe_cl.FieldByName('dj_yj_zf').Value);
  end else begin
    cb_yj.Checked := False;
    txt_yj.Text := '';
  end;
  //
  pe_edit.Enabled := False;
  pe_bh.Enabled := True;
  //
  EnabledComponent(dsBrowse);
end;

procedure Tfrm_xg_dj.SaveInit;
begin
  pe_edit.Enabled := False;
  pe_bh.Enabled := True;
  //
  EnabledComponent(dsBrowse);
end;

procedure Tfrm_xg_dj.EditInit;
var
  intPos: integer;
begin
  qe_jy.Close;
  qe_jy.SQL.Clear;
  qe_jy.SQL.Add('SELECT * FROM CL_DJ WHERE DJ_BH = ''' + cur_bh + ''' AND DJ_ZF_BS = 0');
  qe_jy.Open;
  qe_jy.First;
  //
  if (qe_jy.Bof) and (qe_jy.Eof) then begin
    MessageBox(Handle, '该登记已经作废,不能编辑,请按<刷新登记>刷新当前登记', '沈阳信德', MB_ICONQUESTION or MB_OK);
    Exit;
  end;
  intPos := qe_jy.FieldByName('dj_yj_jsbs').AsInteger;
  if intPos = 1 then begin
    MessageBox(Handle, '押金凭证已经打印,前台无权修改登记基本信息', '沈阳信德', MB_ICONQUESTION or MB_OK);
    Exit;
  end;
  //
  pe_edit.Enabled := True;
  pe_bh.Enabled := False;
  txt_dj_time.SetFocus;
  //
  cmd_edit.Enabled := False;
  cmd_save.Enabled := False;
  cmd_cancel.Enabled := True;
  cmd_print.Enabled := False;
  cmd_refresh.Enabled := False;
  //
  qe_cl.Edit;
end;

procedure Tfrm_xg_dj.controlKeyPress1(Sender: TObject; var Key: Char);
begin
  if Ord(Key) = 13 then controlSetFocus(TWinControl(Sender).Tag);
end;

procedure Tfrm_xg_dj.controlKeyPress2(Sender: TObject; var Key: Char);
begin
  if not (((Key >= '0') and (Key <= '9')) or (Ord(Key) = 8) or (Ord(Key) = 46) or (Ord(Key) = 13)) then
    Key := Chr(0);
  if Ord(Key) = 13 then controlSetFocus(TWinControl(Sender).Tag);
end;

procedure Tfrm_xg_dj.controlKeyPress3(Sender: TObject; var Key: Char);
begin
  if Ord(Key) = 13 then QueryResult;
end;

procedure Tfrm_xg_dj.controlSetFocus(intpos: integer);
begin
  case intpos of
    1: txt_jc_time.SetFocus;
    2: txt_cph.SetFocus;
    3: txt_cx.SetFocus;
    4: txt_fdjh.SetFocus;
    5: txt_dph.SetFocus;
    6: txt_cz.SetFocus;
    7: txt_tel.SetFocus;
    8: txt_czdw.SetFocus;
    9: txt_addr.SetFocus;
    10: cb_yj.SetFocus;
    11: combo_wx_kind.SetFocus;
  end;  
end;

procedure Tfrm_xg_dj.controlChange1(Sender: TObject);
begin
  if qe_cl.State = dsEdit then
    EnabledComponent(dsEdit);
end;

procedure Tfrm_xg_dj.EnabledComponent(intState: TDataSetState);
begin
  case intState of
    dsBrowse: begin
                cmd_edit.Enabled := True;
                cmd_save.Enabled := False;
                cmd_cancel.Enabled := False;
                cmd_print.Enabled := True;
                cmd_refresh.Enabled := True;
                //
                if (qe_cl.Bof) and (qe_cl.Eof) then begin
                  cmd_edit.Enabled := False;
                  cmd_print.Enabled := False;
                end else begin
                  if cb_yj.Checked then
                    cmd_print.Enabled := True
                  else
                    cmd_print.Enabled := False;
                end;
              end;
    dsEdit  : begin
                cmd_edit.Enabled := False;
                cmd_save.Enabled := True;
                cmd_cancel.Enabled := True;
                cmd_print.Enabled := False;
                cmd_refresh.Enabled := False;
              end;
    dsInsert: begin
                cmd_edit.Enabled := False;
                cmd_save.Enabled := True;
                cmd_cancel.Enabled := True;
                cmd_print.Enabled := False;
                cmd_refresh.Enabled := False;
              end;
  end;
end;

procedure Tfrm_xg_dj.QueryResult;
var
  intPos: integer;
  intResult: integer;
begin
  intResult := 0;
  if Trim(txt_bh.EditText) = '00000000-000-000' then begin
    MessageBox(Handle, '请确定委托编号', '沈阳信德', MB_ICONQUESTION or MB_OK);
    txt_bh.SetFocus;
    intResult := 1;
  end else begin
    qe_cl.Close;
    qe_cl.ParamByName('ibh').Value := Trim(txt_bh.EditText);
    qe_cl.ParamByName('iczr').Value := frm_main.user_name;
    qe_cl.Open;
    qe_cl.First;
    //
    if (qe_cl.Bof) and (qe_cl.Eof) then begin
      MessageBox(Handle, '未找到此委托编号相关的登记信息', '沈阳信德', MB_ICONQUESTION or MB_OK);
      txt_bh.SetFocus;
      intResult := 1;
    end else begin
      intPos := qe_cl.FieldByName('dj_js_bs').AsInteger;
      if intPos = 1 then begin
        MessageBox(Handle, '此委托编号已经结算,前台无权编辑', '沈阳信德', MB_ICONQUESTION or MB_OK);
        txt_bh.SetFocus;
        intResult := 1;
      end else begin
        intPos := qe_cl.FieldByName('dj_yj_jsbs').AsInteger;
        if intPos = 1 then begin
          MessageBox(Handle, '此委托编号已经打印了押金凭证,前台无权编辑', '沈阳信德', MB_ICONQUESTION or MB_OK);
          txt_bh.SetFocus;
          intResult := 1;
        end;
      end;
    end;  
  end;
  //
  if intResult = 0 then begin
    cur_bh := Trim(txt_bh.EditText);
    //
    txt_cph.Text := Trim(qe_cl.FieldByName('dj_cph').AsString);
    txt_cx.Text := Trim(qe_cl.FieldByName('dj_cx').AsString);
    txt_dph.Text := Trim(qe_cl.FieldByName('dj_dph').AsString);
    txt_fdjh.Text := Trim(qe_cl.FieldByName('dj_fdjh').AsString);
    txt_cz.Text := Trim(qe_cl.FieldByName('dj_cz').AsString);
    txt_czdw.Text := Trim(qe_cl.FieldByName('dj_czdw').AsString);
    txt_tel.Text := Trim(qe_cl.FieldByName('dj_tel').AsString);
    txt_addr.Text := Trim(qe_cl.FieldByName('dj_addr').AsString);
    txt_dj_time.EditText := Trim(qe_cl.FieldByName('dj_time').AsString);
    txt_jc_time.EditText := Trim(qe_cl.FieldByName('dj_jctime').AsString);
    //
    if qe_cl.FieldByName('dj_bx_bs').AsInteger = 1 then begin
      cb_bx.Checked := True;
      lbl_kind.Caption := '保险类型:';
      combo_bx_kind.ItemIndex := combo_bx_kind.Items.IndexOf(Trim(qe_cl.FieldByName('dj_bx_kind').AsString));
      combo_wx_kind.Visible := False;
      combo_bx_kind.Visible := True;
    end else begin
      cb_bx.Checked := False;
      lbl_kind.Caption := '维修类型:';
      combo_wx_kind.ItemIndex := combo_wx_kind.Items.IndexOf(Trim(qe_cl.FieldByName('dj_wx_kind').AsString));
      combo_wx_kind.Visible := True;
      combo_bx_kind.Visible := False;
    end;
    //
    if qe_cl.FieldByName('dj_yj_bs').AsInteger = 1 then begin
      cb_yj.Checked := True;
      txt_yj.Text := FloatToStr(qe_cl.FieldByName('dj_yj_zf').Value);
    end else begin
      cb_yj.Checked := False;
      txt_yj.Text := '';
    end;
    //
    EnabledComponent(dsBrowse);
  end else if intResult = 1 then begin
    txt_dj_time.Text := '0000-00-00';
    txt_jc_time.Text := '0000-00-00';
    txt_cph.Text := '';
    txt_cx.Text := '';
    txt_fdjh.Text := '';
    txt_dph.Text := '';
    txt_cz.Text := '';
    txt_czdw.Text := '';
    txt_tel.Text := '';
    txt_addr.Text := '';
    //
    cb_yj.Checked := False;
    txt_yj.Text := '';

⌨️ 快捷键说明

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