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

📄 pj_add.pas

📁 汽配前台收费,一个具有详细功能的小系统
💻 PAS
📖 第 1 页 / 共 4 页
字号:
               qe_pj_add.Last;
             end;
           end;
           //
           NewInit;
         end;
       end;
  end;
end;

////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                  CONTROLING THE CLICK FOR LISTBOX                          //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
procedure Tfrm_pj_add.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;

////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//               CONTROLING THE KEYPRESS FOR ALL CONTROLS                     //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
procedure Tfrm_pj_add.ControlKeyPress1(Sender: TObject; var Key: Char);
var
  intIndex: integer;
  str_name: string;
  str_id, str_name1: string;
  str_name2: string;
begin
  if Ord(Key) = 13 then begin
    intIndex := TEdit(Sender).Tag;
    if (intIndex <= 3) and (intIndex > 0) then begin
      if curState = dsInsert then begin
        if hideList[intIndex].ItemIndex > -1 then begin
          str_name := Trim(Copy(hideList[intIndex].Items[hideList[intIndex].ItemIndex], 21, 60));
          TEdit(Sender).OnChange := nil;
          TEdit(Sender).Text := str_name;
          TEdit(Sender).OnChange := frm_pj_add.ControlChange1;
        end;
        //
        if intIndex = 3 then begin
          if Trim(txt_pj.Text) <> '' then begin
            if hideList[3].ItemIndex > -1 then begin
              str_name := Trim(Copy(hideList[1].Items[hideList[1].ItemIndex], 1, 20));
              str_name1 := Trim(Copy(hideList[2].Items[hideList[2].ItemIndex], 1, 20));
              str_id := Trim(Copy(hideList[3].Items[hideList[3].ItemIndex], 1, 20));
              str_name2 := Trim(Copy(hideList[3].Items[hideList[3].ItemIndex], 21, 60));
              if Trim(txt_pj.Text) = Trim(str_name2) then begin
                qe_jy.Close;
                qe_jy.SQL.Clear;
                qe_jy.SQL.Add('SELECT * FROM PJ_CK WHERE PJ_KIND_ID = ''' + str_name + ''' AND PJ_GG_ID = ''' + str_name1 + ''' AND PJ_ID = ''' + str_id + ''' ');
                qe_jy.Open;
                qe_jy.First;
                if (qe_jy.Bof) and (qe_jy.Eof) then begin
                    txt_unit.Text := lst_unit.Items[hideList[3].ItemIndex];
                    txt_dj.Text := lst_sj.Items[hideList[3].ItemIndex];
                    txt_jj.Text := lst_jj.Items[hideList[3].ItemIndex];
                end else begin
                    txt_unit.Text := Trim(qe_jy.FieldByName('pj_unit').AsString);
                    txt_dj.Text := FloatToStr(qe_jy.FieldByName(cur_dj).Value);
                    txt_jj.Text := FloatToStr(qe_jy.FieldByName('pj_jj').Value);
                end;
              end else begin
                txt_unit.Text := '';
                txt_dj.Text := '';
                txt_jj.Text := '';
              end;
            end else begin
              txt_unit.Text := '';
              txt_dj.Text := '';
              txt_jj.Text := '';
            end;
          end else begin
            txt_unit.Text := '';
            txt_dj.Text := '';
            txt_jj.Text := '';
          end;
        end;
      end;
      //
      hideList[intIndex].Visible := False;
      controlSetFocus(TWinControl(Sender).Tag);
    end else begin
      controlSetFocus(TWinControl(Sender).Tag);
    end;
  end;
end;

procedure Tfrm_pj_add.ControlKeyPress3(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_pj_add.ControlKeyPress4(Sender: TObject; var Key: Char);
begin
  if Ord(Key) = 13 then controlSetFocus(TWinControl(Sender).Tag);
end;

////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                  CONTROLING THE CHANGE FOR ALL CONTROLS                    //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
procedure Tfrm_pj_add.ControlChange1(Sender: TObject);
var
  strText: string;
  i: integer;
  intPos: integer;
  //
  intIndex: integer;
  str_id: string;
begin
  if curState = dsEdit then
    EnabledComponent(dsEdit);
  if (curState = dsInsert) then begin
    EnabledComponent(dsInsert);
    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;
end;

////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                   CONTROLING THE ENTER FOR ALL CONTROLS                    //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
procedure Tfrm_pj_add.ControlEnter(Sender: TObject);
var
  i: integer;
  str_name, str_name1: string;
  str_name2: string;
  str_id: string;
  str_pym: string;
  intLen: integer;
begin
    for i := 1 to 3 do
    hideList[i].Visible := False;


    if curState = dsEdit then Exit;
    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
                                                  if Trim(str_id) = '000'
                                                  then  begin
                                                        end
                                                  else begin
                                                          {MessageBox(Handle, '该类型的配件规格不存在', '沈阳信德', MB_ICONQUESTION or MB_OK);
                                                          qe_gg.ParamByName('ipj_kind_id').Value := '***';
                                                          txt_kind.SetFocus;
                                                          Exit;}
                                                        end;
                                                end;
                                          qe_gg.First;
                                          hideList[2].Items.Clear;
                                          hideList[2].Items.Add('000' + spaceArray[17] + '(新规格)');
                                          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);
                                                if str_id <> '000'
                                                then begin
                                                        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);
                                                      end;
                                                qe_gg.Next;
                                              end;
                                              qe_gg.Close;
                                              hideList[2].ItemIndex := -1;
                                              txt_gg.OnChange := nil;
                                              txt_gg.Text := '';
                                              txt_gg.OnChange := frm_pj_add.ControlChange1;
                                            end;
                                          end;
                                        end;
                                      end;

  if TWinControl(Sender).Tag = 3
  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
                      if (Trim(txt_gg.Text) = '') or (hideList[2].ItemIndex = -1)
                      then begin
                              MessageBox(Handle, '请确定配件规格', '沈阳信德', MB_ICONQUESTION or MB_OK);
                              txt_gg.SetFocus;
                              Exit;
                            end
                      else begin
                              str_name := Copy(hideList[2].Items[hideList[2].ItemIndex], 21, 60);
                              if Trim(str_name) <> Trim(txt_gg.Text)
                              then begin
                                      MessageBox(Handle, '请确定配件规格', '沈阳信德', MB_ICONQUESTION or MB_OK);
                                      txt_gg.SetFocus;
                                      Exit;
                                      end
                              else begin
                                      str_name := Trim(Copy(hideList[1].Items[hideList[1].ItemIndex], 1, 20));
                                      str_name1 := Trim(Copy(hideList[2].Items[hideList[2].ItemIndex], 1, 20));

                                      if Trim(txt_pj.Text) <> ''
                              then begin
                                      if hideList[3].ItemIndex > -1
                                      then begin
                                              str_id := Trim(Copy(hideList[3].Items[hideList[3].ItemIndex], 1, 20));
                                              str_name2 := Trim(Copy(hideList[3].Items[hideList[3].ItemIndex], 21, 60));
                                              if Trim(txt_pj.Text) = Trim(str_name2)
                                              then begin
                                                      qe_jy.Close;
                                                      qe_jy.SQL.Clear;
                                                      qe_jy.SQL.Add('SELECT * FROM PJ_CK WHERE PJ_KIND_ID = ''' + str_name + ''' AND PJ_GG_ID = ''' + str_name1 + ''' AND PJ_ID = ''' + str_id + ''' ');
                                                      qe_jy.Open;
                                                      qe_jy.First;
                                              if (qe_jy.Bof) and (qe_jy.Eof)
                                              then begin
                                                    txt_unit.Text := lst_unit.Items[hideList[3].ItemIndex];
                                                    txt_dj.Text := lst_sj.Items[hideList[3].ItemIndex];
                                                    txt_jj.Text := lst_jj.Items[hideList[3].ItemIndex];
                                                    end
                                              else begin
                                                      txt_unit.Text := Trim(qe_jy.FieldByName('pj_unit').AsString);
                                                      txt_dj.Text := FloatToStr(qe_jy.FieldByName(cur_dj).Value);
                                                      txt_jj.Text := FloatToStr(qe_jy.FieldByName('pj_jj').Value);
                                                    end;
                                            end
                                      else begin
                                                txt_unit.Text := '';
                                                txt_dj.Text := '';
                                                txt_jj.Text := '';
                                            end;
                                  end
                              else begin
                                      txt_unit.Text := '';
                                      txt_dj.Text := '';
                                      txt_jj.Text := '';
                                    end;
                          end
                      else begin
                                txt_unit.Text := '';
                                txt_dj.Text := '';
                                txt_jj.Text := '';
                            end;
           
          end;
        end;
      end;
    end;
  end;
end;

procedure Tfrm_pj_add.b1Click(Sender: TObject);
begin
  hideList[1].Visible := True;
end;

procedure Tfrm_pj_add.b3Click(Sender: TObject);
begin
  hideList[3].Visible := True;
end;

procedure Tfrm_pj_add.b2Click(Sender: TObject);
begin
  hideList[2].Visible := True;
end;

////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//        THE CHECK FOR TRADE RULE BEFORE SAVING THE EDITING RECORD           //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
function Tfrm_pj_add.RuleCheck1: integer;
var
  intResult: integer;
  v, v1, v2: Double;

⌨️ 快捷键说明

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