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

📄 mc_jhpzgl.~pas

📁 腾龙餐饮管理软件
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
 Query3.SQL.Add('Select * From 库存信息表 ORDER BY 编号 ASC');
 Query3.Open;
 Query3.Last;
 If Query3.RecordCount <> 0 Then
 d:=Query3.FieldByName('编号').AsInteger
 else d:=0;
 Query3.Close;
 if Length(StringGrid1.Cells[1,1])=0 then
 begin
  ShowMessage('对不起,没有进货信息。无法保存。');
 End
 Else
 if MessageDlg('确认将这批货物入库吗?',mtCustom,[mbNo,mbYes],0)=mrYes then
 begin
  for a:=1 to 100 do
  begin
     //将数据存储到进货历史信息表
   if Length(StringGrid1.Cells[2,a])<>0 then
   begin
     Query2.Close;
     Query2.SQL.Clear;
     Query2.SQL.Add('Insert 进货信息历史表(单据编号,经受人,进货日期,商品编号,商品名称,单位,数量,单价,合计金额,进货说明,仓库名称,仓库编号)');
     Query2.SQL.Add('Values(:A,:B,:C,:D,:E,:F,:H,:G,:I,:J,:M,:N)');
     Query2.Params[0].asInteger:=StrToInt(Label4.Caption);
     Query2.Params[1].asString:=Edit1.Text;
     Query2.Params[2].AsDatetime:=StrToDate(Label8.Caption);
     Query2.Params[3].AsInteger:=StrToInt(StringGrid1.Cells[2,a]);
     Query2.Params[4].AsString:=StringGrid1.Cells[3,a];
     Query2.Params[5].AsString:=StringGrid1.Cells[4,a];
     Query2.Params[6].AsInteger:=StrToInt(StringGrid1.Cells[5,a]);
     Query2.Params[7].AsFloat:=StrToFloat(StringGrid1.Cells[6,a]);
     Query2.Params[8].AsFloat:=StrToFloat(StringGrid1.Cells[7,a]);
     Query2.Params[10].AsString:=Query4.FieldByName('仓库名称').AsString;
     Query2.Params[11].AsInteger:=Query4.FieldByName('仓库编号').AsInteger;
     if Length(StringGrid1.Cells[8,a])=0 then Query2.Params[9].AsString:='无'
     Else
     Query2.Params[9].AsString:=StringGrid1.Cells[8,a];
     Query2.ExecSQL;
   end;
  end;
 //结束循环
 //添加进货单据信息
 Query2.Close;
 Query2.SQL.Clear;
 Query2.SQL.Add('Insert 进货历史单据表(单据编号,经受人,总计金额,记录日期,单据说明)Values(:A,:B,:C,:D,:E)');
 Query2.Params[0].AsInteger:=StrToInt(Label4.Caption);
 Query2.Params[1].AsString:=Edit1.Text;
 Query2.Params[2].AsFloat:=StrToFloat(Label11.Caption);
 Query2.Params[3].AsDateTime:=StrToDate(Label8.Caption);
 Query2.Params[4].AsString:='['+Edit1.Text+']进的货.';
 Query2.ExecSQL;
 for a:=1 to 100 do
  begin
 d:=d+1;
 if Length(StringGrid1.Cells[2,a])<>0 then
  begin
   Query2.Close;
   Query2.RequestLive:=True;
   Query2.SQL.Clear;
   Query2.SQL.Add('Select * From 库存信息表 Where 商品编号=:A');  //查找库存中是否含有入库商品
   Query2.Params[0].AsInteger:=StrToInt(StringGrid1.Cells[2,a]);
   Query2.Open;
   If Query2.RecordCount <> 0 Then //如果库存中存在该商品
    begin
      Query2.Prior;
      b:=0;
      While not Query2.Eof do
      begin
        if (query2.FieldByName('单价').AsFloat=StrToFloat(StringGrid1.Cells[6,a])) then
        begin
         if (Query2.FieldByName('仓库编号').AsInteger=Query4.FieldByName('仓库编号').AsInteger) then
           begin
            Query2.Edit;
            Query2.FieldByName('数量').AsInteger:=Query2.FieldByName('数量')
                  .AsInteger+StrToInt(StringGrid1.Cells[5,a]);   //更新库存
            Query2.Post;
           End
         Else
           begin
            b:=b+1;
           end;
        End
        Else
        b:=b+1;
        Query2.Next;
      end;
     If b = Query2.RecordCount Then
      begin
        Query2.Append;
        Query2.FieldByName('编号').AsInteger:=d+1;
        Query2.FieldByName('经受人').AsString:=Edit1.Text;
        Query2.FieldByName('进货日期').AsDateTime:=StrToDate(Label8.Caption);
        Query2.FieldByName('提醒下限').AsInteger:=50;
        Query2.FieldByName('商品说明').AsString:=StringGrid1.Cells[8,a];
        Query2.FieldByName('商品编号').AsInteger:=StrToInt(StringGrid1.Cells[2,a]);
        Query2.FieldByName('商品名称').AsString:=StringGrid1.Cells[3,a];
        Query2.FieldByName('单位').AsString:=StringGrid1.Cells[4,a];
        Query2.FieldByName('数量').AsInteger:=StrToInt(StringGrid1.cells[5,a]);
        Query2.FieldBYName('单价').AsFloat:=StrToFloat(StringGrid1.Cells[6,a]);
        Query2.FieldByName('仓库名称').AsString:=Query4.FieldByName('仓库名称').AsString;
        Query2.FieldByName('仓库编号').AsInteger:=Query4.FieldByName('仓库编号').AsInteger;
        Query2.Post;
      end;
     End
     Else  //如果库存中不存在该商品,则保存该商品信息到库存
     begin
       Query2.Append;
       Query2.FieldByName('编号').AsInteger:=d+1;
       Query2.FieldByName('经受人').AsString:=Edit1.Text;
       Query2.FieldByName('进货日期').AsDateTime:=StrToDate(Label8.Caption);
       Query2.FieldByName('提醒下限').AsInteger:=50;
       Query2.FieldByName('商品说明').AsString:=StringGrid1.Cells[8,a];
       Query2.FieldByName('商品编号').AsInteger:=StrToInt(StringGrid1.Cells[2,a]);
       Query2.FieldByName('商品名称').AsString:=StringGrid1.Cells[3,a];
       Query2.FieldByName('单位').AsString:=StringGrid1.Cells[4,a];
       Query2.FieldByName('数量').AsInteger:=StrToInt(StringGrid1.cells[5,a]);
       Query2.FieldBYName('单价').AsFloat:=StrToFloat(StringGrid1.Cells[6,a]);
       Query2.FieldByName('仓库名称').AsString:=Query4.FieldByName('仓库名称').AsString;
       Query2.FieldByName('仓库编号').AsInteger:=Query4.FieldByName('仓库编号').AsInteger;
       Query2.Post;
     end;
   end;//结束判空条件
  end;//结束For
 Query2.Close;
 Query2.SQL.Clear;
 Query2.SQL.Add('Select * From 公司资金表 ORDER BY 编号 ASC');
 Query2.Open;
 Query2.Last;
 b:=Query2.FieldByName('编号').AsInteger;
 c:=Query2.FieldByName('资金').AsFloat;
 Query2.Append;
 Query2.FieldByName('编号').AsInteger:=b+1;
 Query2.FieldByName('更新日期').AsDateTime:=StrToDate(Label8.Caption);
 Query2.FieldByName('资金').AsFloat:=c-StrToFloat(Label11.Caption);  //更新公司资金
 Query2.FieldByName('更新说明').AsString:='进货时支出['+Label11.Caption+']单据['+Label4.Caption+']';
 Query2.Post;
 Bitbtn2.Enabled:=False;
 BitBtn1.Enabled:=True;
 ShowMessage('入库完毕.');
 end;//--结束是否保存入库.
end;
procedure TJHPZGL.DBLookupComboBox1Exit(Sender: TObject); //EDIT1获得焦点
begin
 Edit1.SetFocus;
end;
procedure TJHPZGL.BitBtn1Click(Sender: TObject);  //进货登记
var a,b:integer;
begin
 Query2.Close;
 Query2.SQL.Clear;
 Query2.SQL.Add('select * From 进货历史单据表 ORDER BY 单据编号 ASC');
 Query2.Open;
 if Query2.RecordCount=0 then Label4.Caption:='10000'//如果进货历史单据表数据为空,进货单据编号为'10000'
 Else
 begin
  Query2.Last;
  Label4.Caption:=IntToStr(Query2.FieldByName('单据编号').asInteger+1); //否则为上次入库编号加一
 end;
 Query2.Close;
 Label8.Caption:=DateToStr(Date);   //进货日期为系统日期
 Edit1.Enabled:=True;
 for a:=1 to 100 do
 begin
 for b:=1 to 9 do
  begin
   StringGrid1.Cells[b,a]:=''; //清空入库单
  end;
 end;
 DBLookupComboBox1.SetFocus;
 DBLookupComboBox1.KeyValue:=Query4.FieldByName('仓库名称').AsString;
 StringGrid1.Enabled:=True;
 BitBtn2.Enabled:=True;
 BitBtn4.Enabled:=True;
 BitBtn1.Enabled:=False;
end;

procedure TJHPZGL.DBLookupComboBox1KeyPress(Sender: TObject;
var Key: Char);
begin
 if key=#13 then Edit1.SetFocus;    //回车,Edit1获得焦点
end;

procedure TJHPZGL.QuickRep1Preview(Sender: TObject);  //预览报表
begin
 DYYLBrose.QRPreview1.QRPrinter:=QuickRep1.QRPrinter;
end;

procedure TJHPZGL.BitBtn4Click(Sender: TObject);   //打印进货凭证
begin
 Query5.Close;
 Query5.SQL.Clear;
 Query5.SQL.Add('Select * From 进货信息历史表 Where 单据编号=:A');
 Query5.Params[0].AsInteger:=StrToInt(Label4.Caption);
 Query5.Open;
 If Query5.RecordCount = 0 Then
 begin
  ShowMessage('对不起,没有['+Label4.Caption+']号单据的进货信息.');
 End
 Else
 begin
  DYYLBrose.Show;
  QuickRep1.Preview;
 end;
end;

procedure TJHPZGL.DBGrid1KeyPress(Sender: TObject; var Key: Char); //选择入库商品名称
begin
 if key=#27 then  //按Esc隐藏DBGrid1
 begin
  DBGrid1.Visible:=False;
  StringGrid1.SetFocus;
  StringGrid1.Col:=1;
  Exit;
 end;
 if key=#13 then    //回车将商品添加到入库单
 If Query1.RecordCount <> 0 Then
 begin
  StringGrid1.Cells[1,x]:=Query1.FieldByName('简称').AsString;
  StringGrid1.Cells[2,x]:=Query1.FieldByName('编号').AsString;
  StringGrid1.Cells[3,x]:=Query1.FieldByName('名称').AsString;
  StringGrid1.Cells[4,x]:=Query1.FieldByName('单位').AsString;
  StringGrid1.Cells[5,x]:='1';
  StringGrid1.Cells[6,x]:=Query1.FieldByName('单价').AsString;
  StringGrid1.Cells[7,x]:=Query1.FieldByName('单价').AsString;
  StringGrid1.Cells[8,x]:=Query1.FieldbyName('商品说明').AsString;
  DBGrid1.Visible:=False;
  StringGrid1.Col:=5;
  StringGrid1.SetFocus;
 End
 Else
 begin
  DBGrid1.Visible:=False;
  StringGrid1.Col:=1;
  StringGrid1.SetFocus;
 end;
end;
 //处理StringGrid1中的INSERT键、方向键 ←、方向键 →键盘事件
procedure TJHPZGL.StringGrid1KeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
begin
 x:=StringGrid1.Row; //行变量x
 y:=StringGrid1.Col; //列变量y
 if key=$2D then  //INSERT键
 begin
  if Length(StringGrid1.Cells[2,x-1])<>0 then //判断当前行的上一行是否为空
  begin
    Query1.Close;
    Query1.SQL.Clear;
    Query1.SQL.Add('Select * From 商品基础信息表');  //选择商品信息
    Query1.Open;
    DBGrid1.Visible:=True;   //显示商品信息表
    DBGrid1.SetFocus;
  end;
 end;
 if key=$25 then  //处理方向键 ←
 begin
  if StringGrid1.Col>1 then StringGrid1.Col:=StringGrid1.Col-1;
  Abort;
 end;
 if key=$27 then  //处理方向键 →
 begin
  if StringGrid1.Col<9 then StringGrid1.Col:=StringGrid1.Col+1;
  Abort;
 end;
end;
procedure TJHPZGL.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  ANimateWindow(Handle,300,AW_SLIDE+AW_HIDE+AW_VER_POSITIVE);
  JHPZGL.Release;
  JHPZGL:=nil;
end;

end.


⌨️ 快捷键说明

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