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

📄 q_ck.pas

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

interface

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

type
  Tfrm_q_ck = class(TForm)
    pe_select: TPanel;
    cmd_q: TBitBtn;
    cb_sum: TCheckBox;
    pe_sum: TPanel;
    Label9: TLabel;
    Label10: TLabel;
    txt_sum_xx: TEdit;
    txt_sum_sx: TEdit;
    cmd_print: TBitBtn;
    Panel3: TPanel;
    DBGrid1: TDBGrid;
    ds_pj_rk: TDataSource;
    qe_pj_rk: TQuery;
    Panel1: TPanel;
    Image1: TImage;
    combo_p: TComboBox;
    cb_pj: TCheckBox;
    qe_pj: TQuery;
    qe_gg: TQuery;
    qe_kind: TQuery;
    Bevel1: TBevel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    txt_kind: TEdit;
    txt_gg: TEdit;
    txt_pj: TEdit;
    b1: TBitBtn;
    b2: TBitBtn;
    b3: TBitBtn;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure cb_sumClick(Sender: TObject);
    procedure cmd_qClick(Sender: TObject);
    procedure txt_sum_xxKeyPress(Sender: TObject; var Key: Char);
    procedure cmd_printClick(Sender: TObject);
    //
    procedure ControlClick(Sender: TObject);
    procedure ControlChange(Sender: TObject);
    procedure ControlEnter(Sender: TObject);
    procedure cb_pjClick(Sender: TObject);
    procedure b1Click(Sender: TObject);
    procedure b2Click(Sender: TObject);
    procedure b3Click(Sender: TObject);
  private
    { Private declarations }
    strSQL: string;
    hideList: array[1..3] of TListBox;
    spaceArray: array[0..20] of string;
    //
    procedure lstInfoInit;
    procedure arrayInit;
    //
    function RuleCheck: integer;
  public
    { Public declarations }
  end;

var
  frm_q_ck: Tfrm_q_ck;

implementation

{$R *.DFM}

uses
  log, main, print;

////////////////////////////////////////////////////////////////////////////////
procedure Tfrm_q_ck.arrayInit;
var
  i: integer;
begin
  for i := 0 to 20 do begin
    if i = 0 then spaceArray[i] := '';
    if i = 1 then spaceArray[i] := ' ';
    if i > 1 then spaceArray[i] := spaceArray[i - 1] + ' ';
  end;
end;

procedure Tfrm_q_ck.lstInfoInit;
var
  str_id: string;
  str_name: string;
  str_pym: string;
  i: integer;
  intLen: integer;
begin
  for i := 1 to 3 do begin
    hideList[i] := TListBox.Create(Self);
    hideList[i].BorderStyle := bsNone;
    hideList[i].Color := clInfoBk;
    hideList[i].Width := 253;
    hideList[i].Height := 78;
    hideList[i].Parent := pe_select;
    hideList[i].Tag := i;
    hideList[i].OnClick := frm_q_ck.ControlClick;
    hideList[i].Visible := False;
  end;
  //初始化配件类型列表
  qe_kind.Close;
  qe_kind.Open;
  qe_kind.First;
  while not qe_kind.Eof do begin
    str_id := Trim(qe_kind.FieldByName('pj_kind_id').AsString);
    str_name := Trim(qe_kind.FieldByName('pj_kind_name').AsString);
    str_pym := Trim(qe_kind.FieldByName('pj_pym').AsString);
    intLen := Length(str_id);
    if intLen < 20 then str_id := str_id + spaceArray[20 - intLen];
    hideList[1].Items.Add(str_id + str_name + spaceArray[20] + spaceArray[20] + spaceArray[20] + '  ^' + str_pym);
    qe_kind.Next;
  end;
  qe_kind.Close;
  hideList[1].Left := 46;
  hideList[1].Top := 55;
  hideList[1].ItemIndex := -1;
  //初始化配件规格列表
  hideList[2].Left := 46;
  hideList[2].Top := 76;
  //初始化配件信息列表
  qe_pj.Close;
  qe_pj.Open;
  qe_pj.First;
  while not qe_pj.Eof do begin
    str_id := Trim(qe_pj.FieldByName('pj_id').AsString);
    str_name := Trim(qe_pj.FieldByName('pj_name').AsString);
    str_pym := Trim(qe_pj.FieldByName('pj_pym').AsString);
    intLen := Length(str_id);
    if intLen < 20 then str_id := str_id + spaceArray[20 - intLen];
    hideList[3].Items.Add(str_id + str_name + spaceArray[20] + spaceArray[20] + spaceArray[20] + '  ^' + str_pym);
    qe_pj.Next;
  end;
  qe_pj.Close;
  hideList[3].Left := 46;
  hideList[3].Top := 97;
  hideList[3].ItemIndex := -1;
end;

procedure Tfrm_q_ck.ControlClick(Sender: TObject);
var
  intIndex: integer;
  str_name: string;
begin
  intIndex := TListBox(Sender).Tag;
  if (intIndex <= 3) and (intIndex > 0) then begin
    case intIndex of
      1: begin
           str_name := Trim(Copy(hideList[1].Items[hideList[1].ItemIndex], 21, 60));
           txt_kind.Text := str_name;
           txt_kind.SetFocus;
         end;
      2: begin
           str_name := Trim(Copy(hideList[2].Items[hideList[2].ItemIndex], 21, 60));
           txt_gg.Text := str_name;
           txt_gg.SetFocus;
         end;
      3: begin
           str_name := Trim(Copy(hideList[3].Items[hideList[3].ItemIndex], 21, 60));
           txt_pj.Text := str_name;
           txt_pj.SetFocus;
         end;
    end;
  end;
end;

procedure Tfrm_q_ck.ControlChange(Sender: TObject);
var
  strText: string;
  i: integer;
  intPos: integer;
  //
  intIndex: integer;
  str_id: string;
begin
    intIndex := TWinControl(Sender).Tag;
    if (intIndex <= 3) and (intIndex > 0) then begin
      hideList[intIndex].Visible := True;
      strText := Trim(TEdit(Sender).Text);
      //第一次
      for i := 0 to hideList[intIndex].Items.Count - 1 do begin
        str_id := Copy(hideList[intIndex].Items[i], Pos('^', hideList[intIndex].Items[i]) + 1, 20);
        intPos := Pos(strText, str_id);
        if intPos = 1 then begin
          hideList[intIndex].ItemIndex := i;
          Break;
        end else begin
          hideList[intIndex].ItemIndex := 0;
        end;
      end;
      //第二次
      if intPos <> 1 then begin
        for i := 0 to hideList[intIndex].Items.Count - 1 do begin
          str_id := Copy(hideList[intIndex].Items[i], 1, 20);
          intPos := Pos(strText, str_id);
          if intPos = 1 then begin
            hideList[intIndex].ItemIndex := i;
            Break;
          end else begin
            hideList[intIndex].ItemIndex := 0;
          end;
        end;
      end;  
      //第三次
      if intPos <> 1 then begin
        for i := 0 to hideList[intIndex].Items.Count - 1 do begin
          str_id := Copy(hideList[intIndex].Items[i], 21, 60);
          intPos := Pos(strText, str_id);
          if intPos = 1 then begin
            hideList[intIndex].ItemIndex := i;
            Break;
          end else begin
            hideList[intIndex].ItemIndex := 0;
          end;
        end;
      end;
    end;
end;

procedure Tfrm_q_ck.ControlEnter(Sender: TObject);
var
  i: integer;
  str_name: string;
  str_id: string;
  str_pym: string;
  intLen: integer;
begin
  for i := 1 to 3 do
    hideList[i].Visible := False;
  //
  if TWinControl(Sender).Tag = 2 then begin
    if (Trim(txt_kind.Text) = '') or (hideList[1].ItemIndex = -1) then begin
      MessageBox(Handle, '请确定配件类型', '沈阳信德', MB_ICONQUESTION or MB_OK);
      txt_kind.SetFocus;
      Exit;
    end else begin
      str_name := Copy(hideList[1].Items[hideList[1].ItemIndex], 21, 60);
      if Trim(str_name) <> Trim(txt_kind.Text) then begin
        MessageBox(Handle, '请确定配件类型', '沈阳信德', MB_ICONQUESTION or MB_OK);
        txt_kind.SetFocus;
        Exit;
      end else begin
        str_id := Copy(hideList[1].Items[hideList[1].ItemIndex], 1, 20);
        if Trim(str_id) <> Trim(qe_gg.ParamByName('ipj_kind_id').Value) then begin
          qe_gg.Close;
          qe_gg.ParamByName('ipj_kind_id').Value := Trim(str_id);
          qe_gg.Open;
          qe_gg.First;
          if (qe_gg.Bof) and (qe_gg.Eof) then begin
            MessageBox(Handle, '该类型的配件规格不存在', '沈阳信德', MB_ICONQUESTION or MB_OK);
            qe_gg.ParamByName('ipj_kind_id').Value := '***';
            txt_kind.SetFocus;
            Exit;
          end;
          qe_gg.First;
          hideList[2].Items.Clear;
          while not qe_gg.Eof do begin
            str_id := Trim(qe_gg.FieldByName('pj_gg_id').AsString);
            str_name := Trim(qe_gg.FieldByName('pj_gg_name').AsString);
            str_pym := Trim(qe_gg.FieldByName('pj_pym').AsString);
            intLen := Length(str_id);
            if intLen < 20 then str_id := str_id + spaceArray[20 - intLen];
            hideList[2].Items.Add(str_id + str_name + spaceArray[20] + spaceArray[20] + spaceArray[20] + '  ^' + str_pym);
            qe_gg.Next;
          end;
          qe_gg.Close;
          hideList[2].ItemIndex := -1;
          //
          txt_gg.Text := '';
        end;

⌨️ 快捷键说明

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