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

📄 unit2.pas

📁 该系统是基于Dephli的开发出来的
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  ADOQuery1.FieldByName('SellPrice').AsString     := ADOQuery2.FieldByName('SellPrice').AsString;
  ADOQuery1.FieldByName('Gift').AsString          := '-';
  ADOQuery1.FieldByName('UntreadFlag').AsString   := '-';
  QH1;
  QH2;
end;

procedure TMain.QH2;
begin
  ADOQuery2.SQL.Clear;
  ADOQuery2.SQL.Add('Select SUM(Subtotal) from Sell_Minor Where InvoiceID="'+Label26.Caption+'"');
  ADOQuery2.Open;
  Label7.Caption := FormatFloat('0.00',ADOQuery2.Fields[0].AsCurrency)
end;

procedure TMain.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  SID : String;
  i   : Integer;
begin
  case key of
    VK_ESCAPE:SpeedButton1.Click;

    VK_SPACE :
    begin
      //检查货物数量
      if ADOQuery1.RecordCount<1 then begin
        ShowMessage('没有商品记录~~!');
        Exit;
      end else begin
        Gathering:=TGathering.Create(Application);
        Gathering.ShowModal;
      end;
    end;

    VK_F1:RzEdit4.SetFocus;

    VK_F2:RzEdit1.SetFocus;

    VK_F3:RzEdit2.SetFocus;

    VK_F4:RzEdit3.SetFocus;

    VK_F5: begin
      if ADOQuery1.FieldByName('Gift').AsString='-' then begin
        if ADOQuery1.RecordCount>0 then begin
          ADOQuery1.Edit;
          ADOQuery1.FieldByName('Gift').AsString:='赠品';
        end;
        QH1;
        QH2;
      end else begin
        if ADOQuery1.RecordCount>0 then begin
          ADOQuery1.Edit;
          ADOQuery1.FieldByName('Gift').AsString:='-';
        end;
        QH1;
        QH2;
      end;
    end;
    VK_F6:begin
      //初始单号
      for i:=1 to 9999 do
      begin
        SID:=FormatdateTime('yymmdd', Now)+FormatFloat('0000',i);
        ADOQuery2.SQL.Clear;
        ADOQuery2.SQL.Add('Select * from Sell_Main Where InvoiceID="'+SID+'"');
        ADOQuery2.Open;
        if ADOQuery2.RecordCount=0 then
        begin
          Break;
        end;
      end;
      //读取单号
      Label26.Caption:=SID;
      ADOQuery1.SQL.Clear;
      ADOQuery1.SQL.Add('Select * from Sell_Minor Where InvoiceID="'+Label26.Caption+'"');
      ADOQuery1.Open;
      QH2;



    end;

    VK_F7:begin
      if QD<>nil then
        QD.ShowModal
      else begin
        QD:=TQD.Create(Application);
        QD.ShowModal;
      end;
    end;

    VK_F9:begin
      if Pos_Setup<>nil then
        Pos_Setup.ShowModal
      else begin
        Pos_Setup:=TPos_Setup.Create(Application);
        Pos_Setup.ShowModal;
      end;
    end;

    VK_UP:
    begin
      DBGrid1.SetFocus;
    end;

    VK_DOWN:
    begin
      DBGrid1.SetFocus;
    end;

    VK_DELETE: begin
      if ADOQuery1.RecordCount>0 then begin
        if messagedlg('确认删除"'+ADOQuery1.FieldByName('GoodsName').AsString+'"吗?',mtconfirmation,[mbyes,mbno],0)=mryes then begin
          ADOQuery1.Delete;
          QH2;
        end;
      end else begin
        ShowMessage('没有商品记录~~!');
      end;
    end;

    VK_ADD: begin
      ADOQuery1.Edit;
      ADOQuery1.FieldByName('SellScalar').AsCurrency:=ADOQuery1.FieldByName('SellScalar').AsCurrency+1;
      QH1;
      QH2;
    end;

    VK_SUBTRACT: begin
      if ADOQuery1.FieldByName('SellScalar').AsCurrency>1 then begin
        ADOQuery1.Edit;
        ADOQuery1.FieldByName('SellScalar').AsCurrency:=ADOQuery1.FieldByName('SellScalar').AsCurrency-1;
        QH1;
        QH2;
      end;
    end;
  end;
end;

procedure TMain.RzEdit1KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then begin
    key:=#0;
    if ADOQuery1.RecordCount>0 then begin
    //输入数据检查
      try
        StrToInt(RzEdit1.Text);
        if StrToInt(RzEdit1.Text)<1 then begin
          ShowMessage('折扣不能小于1~~!');
          RzEdit1.Text:='100';
          Exit;
        end;
        Except
        ShowMessage('输入非法字符~~!');
        RzEdit1.Text:='100';
        Exit;
      end;
      ADOQuery1.Edit;
      ADOQuery1.FieldByName('Agio').AsString:=RzEdit1.Text;
      ADOQuery1.Post;
      QH1;
      QH2;
    end;
    RzEdit1.Text:='100';
    RzEdit4.SetFocus;
  end;
end;

procedure TMain.RzEdit3KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
  begin
    key:=#0;
    if ADOQuery1.RecordCount>0 then begin
      //输入数据检查
      try
        StrToCurr(RzEdit3.Text);
        if StrToCurr(RzEdit3.Text)<0 then begin
          ShowMessage('商品数量不能小于零~~!');
          RzEdit3.Text:='1';
          Exit;
        end;
      Except
        ShowMessage('输入非法字符~~!');
        Exit;
      end;
      ADOQuery1.Edit;
      ADOQuery1.FieldByName('SellScalar').AsString:=RzEdit3.Text;
      ADOQuery1.Post;
      QH1;
      QH2;
      end;
    RzEdit3.Text:='1';
    RzEdit4.SetFocus;
  end;
end;

procedure TMain.RzEdit2KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
  begin
    key:=#0;
    if ADOQuery1.RecordCount>0 then begin
      //输入数据检查
      try
        StrToCurr(RzEdit2.Text);
        if StrToCurr(RzEdit2.Text)<0 then begin
          ShowMessage('商品售价不能为负数~~!');
          RzEdit1.Text:='100';
          Exit;
        end;
      Except
        ShowMessage('输入非法字符~~!');
        Exit;
      end;
      ADOQuery1.Edit;
      ADOQuery1.FieldByName('SellPrice').AsString:=RzEdit2.Text;
      ADOQuery1.Post;
      QH1;
      QH2;
    end;
    RzEdit4.SetFocus;
  end;
end;

procedure TMain.DBGrid1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  RzEdit1.Text:=ADOQuery1.FieldByName('Agio').AsString;
  RzEdit2.Text:=ADOQuery1.FieldByName('SellPrice').AsString;
  RzEdit3.Text:=ADOQuery1.FieldByName('SellScalar').AsString;
end;

procedure TMain.DBGrid1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  RzEdit1.Text:=ADOQuery1.FieldByName('Agio').AsString;
  RzEdit2.Text:=ADOQuery1.FieldByName('SellPrice').AsString;
  RzEdit3.Text:=ADOQuery1.FieldByName('SellScalar').AsString;
end;

procedure TMain.RzEdit4KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then begin
    //当输入为空则结账
    if (RzEdit4.Text='')and(ADOQuery1.RecordCount>0) then begin
      Gathering:=TGathering.create(application);
      Gathering.showmodal;
      Exit;
    end;
    //在库存中按条码查找商品
    ADOQuery2.SQL.Clear;
    ADOQuery2.SQL.Add('Select * from Stock Where BarCode="'+RzEdit4.Text+'"');
    ADOQuery2.Open;
    if ADOQuery2.RecordCount<>0 then begin
      WRecord;
      RzEdit4.Text:='';
      RzEdit4.SetFocus;
    end else begin
      //如果按条码查找没有则按拼音查找
      ADOQuery2.SQL.Clear;
      ADOQuery2.SQL.Add('Select * from Stock Where PYBrevity="'+RzEdit4.Text+'"');
      ADOQuery2.Open;
      if ADOQuery2.RecordCount<>0 then begin
        if ADOQuery2.RecordCount>1 then begin
          Sele:=TSele.Create(Application);
          Sele.showmodal;
          Exit;
        end;
        WRecord;
        RzEdit4.Text:='';
        RzEdit4.SetFocus;
      end else begin
        //拼音查找没有提示
        showmessage('无此商品ID'+#13#13+'注意核对~~!');
        RzEdit4.Text:='';
        RzEdit4.SetFocus;
      end;
    end;
  end;
  if (key=#43) or (key=#45) then
    key:=#0;
end;

end.

⌨️ 快捷键说明

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