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

📄 u_goodsinstock.pas

📁 河南师范大学餐饮进销存软件,只要控制库存的数据。
💻 PAS
📖 第 1 页 / 共 2 页
字号:
      end
    else
      begin
        Total := 0;
        edtTotal.Text := FloatToStr(Total);
      end;
end;

procedure TfrmGoodsInStock.lvMainSelectItem(Sender: TObject;
  Item: TListItem; Selected: Boolean);
begin
  InitEdt;
  InitShowAdd;
end;

procedure TfrmGoodsInStock.edtGoodsAmountKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if  (key = vk_Return) and  (Not CheckInt(edtGoodsAmount.Text)) then
    begin
      Application.MessageBox('数量输入有误','警告',MB_OK);
      edtGoodsAmount.SetFocus;
      Exit;
    end;
  if (key = vk_Return) and  CheckInt(edtGoodsAmount.Text) then
      btnSave.SetFocus;
end;

procedure TfrmGoodsInStock.cmbSupplyKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (key = VK_RETURN) and (length(trim(cmbSupply.Text))>0) then
    frmGoodsInStock.cmbSupplyExit(self);
end;

procedure TfrmGoodsInStock.btnOKClick(Sender: TObject);
var
  Success,i  : Integer;
  Check      : Tadoquery ;
begin
  if cmbSupply.Text = '' then
  begin
    Application.MessageBox('请选择供应商','警告',MB_OK);
    cmbSupply.SetFocus;
    Exit;
  end;
  {
  if IsNumeric(edtPayMent.Text)=False then
  begin
    Application.MessageBox('付款金额输入有误','警告',MB_OK);
    edtPayMent.SetFocus;
    Exit;
  end;
  }     
  if (lvMain.Items.Count<1) and (edtTotal.Text = '0') then
  begin
    Application.MessageBox('请输入商品信息','警告',MB_OK);
    edtGoodsBH.SetFocus;
    Exit;
  end;
  {
  if Not IsNumeric(edtPayMent.Text) then
  begin
    Application.MessageBox('付款金额输入有误,请重新输入!','警告',MB_OK);
    edtPayMent.SetFocus;
    Exit;
  end;
  if (StrToFloat(edtPayMent.Text)<0) then
  begin
    Application.MessageBox('收款金额不可为负','警告',MB_OK);
    edtPayMent.SetFocus;
    Exit;
  end;
  }
  //如果是试用版的话,记录控制在20条
  if Not IsJXCAvailable then
      begin
        Check := Tadoquery.Create(self);
        Check.Connection := frmDataCtrl.ADOConn;
        Check.Close;
        Check.SQL.Clear;
        Check.SQL.Add('select count(*) as Rec from tb_GoodsInMaster');
        try
          Check.Active := true ;
          if Check.FieldByName('Rec').AsInteger >=20 then
            begin
              Application.MessageBox('试用版只能输入20条入库单,请你使用正式版!','警告',MB_OK);
              Exit;
            end;
        except
        end;
      end;
  //
  with pipGoodsInMaster do
  begin
    Parameters.ParamByName('@InBH').Value     := EdtGoodsInBH.Text;
    Parameters.ParamByName('@SupName').Value  := cmbSupply.Text;
    Parameters.ParamByName('@InUser').Value   := JXC_UserBH;
    Parameters.ParamByName('@InTotal').Value  := edtTotal.Text;
    Parameters.ParamByName('@InPayMon').Value := edtPayMent.Text;
    if ChkCheck.Checked then
      Parameters.ParamByName('@btCheck').Value  := 1
    else
      Parameters.ParamByName('@btCheck').Value  := 0;
    ExecProc;
    Success := Parameters.ParamByName('@RETURN_VALUE').Value;
  end;
  if Success = 1 then
    begin
       with pipGoodsInDetail do
         begin
           for i := 0 to lvMain.Items.Count-1 do
             begin
              with LvMain.Items do
                begin
                  Parameters.ParamByName('@InBH').Value         := EdtGoodsInBH.Text;
                  Parameters.ParamByName('@SupName').Value      := cmbSupply.Text;
                  Parameters.ParamByName('@GoodsBH').Value      := Item[i].Caption;
                  Parameters.ParamByName('@GoodsSpec').Value    := Item[i].SubItems.Strings[1];
                  Parameters.ParamByName('@GoodsModel').Value   := Item[i].SubItems.Strings[2];
                  Parameters.ParamByName('@GoodsInSum').Value   := Item[i].SubItems.Strings[4];
                  Parameters.ParamByName('@GoodsInPrice').Value := Item[i].SubItems.Strings[3];
                  ExecProc;
                  Success := Parameters.ParamByName('@RETURN_VALUE').Value;
                end;
             end;
          end;
      if StrtoFloat(edtPayMent.Text)>0 then
        begin
          with pipSupAccount do
          begin
            Parameters.ParamByName('@SupName').Value      := cmbSupply.Text;
            Parameters.ParamByName('@SupSummary').Value   := cmbSupply.Text+'付款';
            Parameters.ParamByName('@GoodsInSum').Value   := IntToStr(0);
            Parameters.ParamByName('@GoodsInPrice').Value := IntToStr(0);
            Parameters.ParamByName('@InDH').Value         := EdtGoodsInBH.Text;
            Parameters.ParamByName('@PayMent').Value      := edtPayMent.Text;
            ExecProc;
            Success := Parameters.ParamByName('@RETURN_VALUE').Value;
          end;
        end;
      if Success = 1 then
        begin
          Application.MessageBox('商品入库成功','提示',MB_OK);
          //打印报表
          if chkPrint.Checked then
            begin
              frmGoodsInRep.edtInDate.Caption := edtDate.Text;
              frmGoodsInRep.edtInBH.Caption:= edtGoodsInBH.Text;
              InRepQry.Close;
              InRepQry.SQL.Clear;
              InRepQry.SQL.Text:='select * from vw_GoodsInDetail where InBH='+QuotedStr(edtGoodsInBH.Text);
              try
                InRepQry.Open;
                frmGoodsInRep.InReport.Preview;
              except
              end;
            end;
          //结束
          edtTotal.Clear;
          edtPayMent.Clear;
          lvMain.Items.Clear;
          BtnAdd.Click;
          cmbSupply.SetFocus;
          with popGetGoodsInBH do
            begin
              Close;
              ExecProc;
              EdtGoodsInBH.Text:=Parameters.ParamByName('@billcode').Value;
            end;
        end;
    end;
end;

procedure TfrmGoodsInStock.edtPayMentKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if key = VK_RETURN then
    btnOK.SetFocus;
end;

procedure TfrmGoodsInStock.edtGoodsPriceKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if(key = VK_RETURN) and (Not IsNumeric(edtGoodsPrice.Text)) then
    begin
      Application.MessageBox('单价输入有误','警告',MB_OK);
      edtGoodsPrice.SetFocus;
      Exit;
    end;
  if(key = VK_RETURN) and IsNumeric(edtGoodsPrice.Text) then
    edtGoodsAmount.SetFocus;
end;

procedure TfrmGoodsInStock.btnAbandonClick(Sender: TObject);
begin
  if Application.MessageBox('您确定要放弃吗?','警告',MB_OKCANCEL)=1 then
  begin
    BtnAdd.Click;
    lvMain.Items.Clear;
    edtTotal.Clear;
    edtPayMent.Clear;
    with popGetGoodsInBH do
    begin
      Close;
      ExecProc;
      EdtGoodsInBH.Text:=Parameters.ParamByName('@billcode').Value;
    end;
  end;
end;

procedure TfrmGoodsInStock.FormShow(Sender: TObject);
begin
  Total := 0;
  edtTotal.Text := '0';
   with popGetSysTime do
     begin
       Close;
       ExecProc;
       edtDate.Text:=Parameters.ParamByName('@billcode').Value;
     end;
   with popGetGoodsInBH do
     begin
       Close;
       ExecProc;
       EdtGoodsInBH.Text:=Parameters.ParamByName('@billcode').Value;
     end;
  BtnAdd.Click;
  cmbSupply.SetFocus;
end;

procedure TfrmGoodsInStock.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := Cafree ;
end;

procedure TfrmGoodsInStock.PmDelClick(Sender: TObject);
begin
  btnDelete.Click;
end;

procedure TfrmGoodsInStock.edtGoodsBHExit(Sender: TObject);
var
  TempSql : String;
  TempQuery   : TADOQuery;
begin
  if trim(edtGoodsBH.Text)<>'' then
    begin
      TempSql := 'select * from vw_GoodsInfo where GoodsBH='+QuotedStr(edtGoodsBH.Text);
      TempQuery := frmDataCtrl.ReturnQuery(TempSql);
      if TempQuery.RecordCount > 0 then
      begin
        edtGoodsName.Text   := TempQuery.FieldValues['GoodsName'];
        edtGoodsSpec.Text   := TempQuery.FieldValues['GoodsSpec'];
        edtGoodsModel.Text  := TempQuery.FieldValues['GoodsModel'];
        edtGoodsPrice.Text  := TempQuery.fieldbyname('GoodsInPrice').AsString ;
        TempQuery.Free;
        edtGoodsPrice.SetFocus;
      end
      else
        begin
          showmessage('没有此商品,请重新输入!');
          edtGoodsBH.SetFocus;
          exit;
        end;
    end;
end;

procedure TfrmGoodsInStock.cmbSupplyExit(Sender: TObject);
var
  Check : Tadoquery ;
  AddQry: Tadoquery ;
begin
  if length(trim(cmbSupply.Text))>0 then
    begin
      Check := Tadoquery.Create(self);
      Check.Connection := frmDataCtrl.ADOConn;
      Check.Close;
      Check.SQL.Clear;
      Check.SQL.Add('select * from tb_Supply where SupSName='+QuotedStr(cmbSupply.Text));
      try
        check.Active := true ;
        if Check.RecordCount<1 then
           if Application.MessageBox('没有此供应商,是否增加此供应商?','询问',MB_YesNo)=IDYes then
              begin
                AddSup;
                edtGoodsBH.SetFocus;
              end
           else
              begin
                cmbSupply.Text := '';
                cmbSupply.SetFocus;
              end
        else
          edtGoodsBH.SetFocus;
      except
      end;
    end;
end;

procedure TfrmGoodsInStock.AddSup();
var
  Check : Tadoquery ;
  SupNo : String ;
begin
  with sp_GetSupNo do
  begin
    Close;
    ExecProc;
    SupNo := Parameters.ParamByName('@billcode').Value;
  end;
  Check := Tadoquery.Create(self);
  Check.Connection := frmDataCtrl.ADOConn;
  Check.Close;
  Check.SQL.Clear;
  Check.SQL.Add(' EXEC pip_Supply '+QuotedStr(SupNo)+','+QuotedStr(cmbSupply.Text)+',');
  Check.SQL.Add(QuotedStr('')+','+QuotedStr('')+','+QuotedStr('')+','+QuotedStr('')+',');
  Check.SQL.Add(QuotedStr('')+','+QuotedStr('')+','+QuotedStr('')+','+QuotedStr('')+',');
  Check.SQL.Add(QuotedStr('')+','+QuotedStr(''));
  try
    Check.ExecSQL;
  except
    showmessage('数据库操作失败!');
  end;
end;
procedure TfrmGoodsInStock.cmbSupplyDblClick(Sender: TObject);
begin
  frmSupSearch.SupQry.Close;
  frmSupSearch.SupQry.Open;
  frmSupSearch.ShowModal;
end;

end.

⌨️ 快捷键说明

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