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

📄 mc_chpzgl.pas

📁 一个通用的餐饮管理软件
💻 PAS
📖 第 1 页 / 共 2 页
字号:
        StringGrid1.Cells[6,x]:=FloatToStr(StrToInt(StringGrid1.Cells[4,x])*StrToFloat(StringGrid1.Cells[5,x]));
       end;
      end;
      //结束第五列的判断
      //开始第六列的判断
     if y=6 then
      begin
      abc:=0;
      for a:=1 to 100 do
      begin
       if Length(StringGrid1.Cells[6,a])<>0 then
       abc:=abc+StrToFloat(StringGrid1.Cells[6,a]);
      end;
       Label11.Caption:=FloatToStr(abc);
       end;
       //结束第六列的判断
        end;
      //结束回车键的判断
     if Length(StringGrid1.Cells[2,x-1])=0 then key:=#0//判断当前行的上一行是否为空
     else
      begin
      //-判断是否是1,5,7,10列
      if not ((y=1) or (y=4) or (y=5) or (y=8) or (y=10)) then key:=#0
        else
        begin
         if y=5 then
         begin
          if Pos('.',StringGrid1.Cells[5,x])>0 then
          begin
          if key=#8 then key:=#8
          else if (key<'0') or (key>'9') then key:=#0;
          end
          else
          begin
          if key=#8 then key:=#8
          else
          if key='.' then
          else
          if (key<'0') or (key>'9') then key:=#0;
         end;
         end;
         if (y=1) or (y=4) then//判断不是第8列出货说明
           if key=#8 then key:=#8
           else if (key<'0') or (key>'9') then key:=#0;
       end;
     end;
end;
//选择出货商品
procedure TCHPZGL.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#27 then//按Esc隐藏DBGrid1
    begin
     DBGrid1.Visible:=False;
     StringGrid1.SetFocus;
     StringGrid1.Col:=1;
    end;
  if key=#13 then
    begin
    if Query2.RecordCount=0 then
    begin
     DBGrid1.Visible:=False;
     StringGrid1.Cells[1,x]:='';
     StringGrid1.SetFocus;
    end
     else
    begin
     DBGrid1.Visible:=False;
     StringGrid1.Cells[1,x]:=Query2.FieldByName('商品编号').Asstring;
     StringGrid1.Cells[2,x]:=Query2.FieldByName('商品名称').AsString;
     StringGrid1.Cells[3,x]:=Query2.FieldByName('单位').AsString;
     StringGrid1.Cells[4,x]:='1';
     stringGrid1.Cells[5,x]:=Query2.FieldByName('单价').AsString;;
     StringGrid1.Cells[6,x]:=Query2.FieldByName('单价').AsString;
     StringGrid1.Cells[7,x]:=Query2.FieldByName('商品说明').AsString;
     StringGrid1.Cells[9,x]:=Query2.FieldByName('仓库名称').AsString;
     StringGrid1.Cells[10,x]:=Query2.FieldByName('编号').AsString;
     StringGrid1.SetFocus;
     StringGrid1.Col:=4;
    end;
  end;
end;

procedure TCHPZGL.Edit1Enter(Sender: TObject);
begin
 Edit1.color:=clWhite;
end;

procedure TCHPZGL.Edit1Exit(Sender: TObject);
begin
 Edit1.color:=clScrollBar;
end;
//取消出货操作
procedure TCHPZGL.BitBtn3Click(Sender: TObject);
begin
 if Bitbtn2.Enabled=True then
   begin
    if MessageDLG('确认放弃出货吗?',mtCustom,[mbYes,mbNo],0)=mrYes then close;
   end
  else Close;
end;
//商品出货
procedure TCHPZGL.BitBtn2Click(Sender: TObject);
var a,b,d:integer;
    abc,cba:Real;
begin
  if Length(StringGrid1.Cells[2,1])=0 then
   begin
     ShowMessage('没有出货信息.');
   end
   else
   begin
   //库存初始化
   Query2.Close;
   Query2.SQL.Clear;
   Query2.RequestLive:=True;//打开写入权限
   Query2.SQL.Add('Select * From 库存信息表 ORder by 编号 ASC');
   Query2.Open;
   //结束库存初始化---------------------------------------------------
   //开始添加出货记录修改库存-----------------------------------------
   For a:=1 to 100 do
   begin
    if (Length(StringGrid1.Cells[2,a])=0)
      or (Length(StringGrid1.Cells[3,a])=0) or (Length(StringGrid1.Cells[4,a])=0)
      or (Length(StringGrid1.Cells[5,a])=0) or (Length(StringGrid1.Cells[6,a])=0)
      or (Length(StringGrid1.Cells[10,a])=0) then
    begin
     end
     else
     begin
      if Query2.Locate('编号',StringGrid1.Cells[10,a],[loCaseInsensitive]) then
       begin
        Query3.Close;
        Query3.SQL.Clear;
        Query3.SQL.Add('insert 出货信息历史表(单据编号,经受人,出货日期,商品编号,商品名称,单位,数量,单价,合计金额,出货说明)');
        Query3.SQL.Add('Values(:DJBH,:JSR,:CHRQ,:SPBH,:SPMC,:DW,:SL,:DJ,:ZJJE,:CHSM)');
        Query3.ParamByName('DJBH').AsInteger:=StrToInt(Label4.Caption);
        Query3.ParamByName('JSR').AsString:=Edit1.Text;
        Query3.ParamByName('CHRQ').AsDateTime:=StrToDate(Label8.Caption);
        Query3.ParamByName('SPBH').AsInteger:=Query2.FieldByName('商品编号').AsInteger;
        Query3.ParamByName('SPMC').AsString:=Query2.FieldByName('商品名称').AsString;
        Query3.paramByName('DW').AsString:=Query2.FieldByName('单位').AsString;
        Query3.paramByName('SL').AsInteger:=StrToInt(StringGrid1.Cells[4,a]);
        Query3.paramByName('DJ').AsFloat:=Query2.FieldByName('单价').AsFloat;
        Query3.paramByName('ZJJE').AsFloat:=StrToFloat(StringGrid1.Cells[6,a]);
        Query3.paramByName('CHSM').AsString:=StringGrid1.Cells[8,a];
        Query3.ExecSQL;
        //修改库存数量
        Query2.Edit;
        Query2.FieldByName('数量').AsInteger:=Query2.FieldByName('数量').AsInteger-StrToInt(StringGrid1.Cells[4,a]);
        Query2.Post;
        //结束修改
        if Query2.FieldByName('数量').AsInteger<=Query2.FieldByName('提醒下限').AsInteger then
        begin
         ShowMessage('['+Query2.FieldByName('仓库名称').AsString
         +']里的['+Query2.FieldByName('商品名称').AsString
         +']商品底于(提醒下限:'+Query2.FieldByName('提醒下限').AsString+')');
        end;
        end;
        end;
        end;
        //结束出货
        //记录出货单据
        Query3.Close;
        Query3.SQL.Clear;
        Query3.SQL.Add('insert 出货历史单据表(单据编号,经受人,总计金额,记录日期,单据说明)');
        Query3.SQL.Add('Values(:DJBH,:JSR,:ZJJE,:JLRQ,:DJSM)');
        Query3.ParamByName('DJBH').Asinteger:=StrToInt(Label4.Caption);
        Query3.ParamByName('JSR').AsString:=Edit1.Text;
        Query3.ParamByName('ZJJE').AsFloat:=StrToFloat(Label11.Caption);
        query3.ParamByName('JLRQ').AsDateTime:=StrtoDate(Label8.Caption);
        query3.paramByName('DJSM').AsString:='出货凭证管理系统自动录入';
        Query3.ExecSQL;
        //结束记录
        Query3.Close;
        Query3.SQL.Clear;
        Query3.SQL.Add('Select * from 公司资金表 ORDER by 编号 ASC');
        Query3.Open;
        Query3.Last;
        d:=Query3.FieldByName('编号').AsInteger;
        cba:=Query3.FieldByName('资金').asFloat;
        //开始结算费用
        Query3.Close;
        Query3.SQL.Clear;
        Query3.SQL.Add('insert 公司资金表(编号,更新日期,资金,更新说明)');
        Query3.SQL.Add('Values(:BH,:GXRQ,:ZJ,:GXSM)');
        Query3.ParamByName('BH').AsInteger:=d+1;
        Query3.ParamByName('GXRQ').AsDateTime:=StrToDate(Label8.Caption);
        Query3.ParamByName('ZJ').AsFloat:=cba+StrToFloat(Label11.Caption);
        Query3.ParamByName('GXSM').AsString:='出货凭证时录入[出货单据:'+Label4.Caption+']';
        Query3.ExecSQL;
        //结束结算
        ShowMessage('出货完毕。');
        BitBtn2.Enabled:=False;
        BitBtn1.Enabled:=True;
        StringGrid1.Enabled:=False;
     end;
end;
//出货打印
procedure TCHPZGL.BitBtn4Click(Sender: TObject);
begin
 Query4.Close;
 Query4.SQL.Clear;
 Query4.SQL.Add('Select * From 出货信息历史表');
 Query4.SQL.Add('Where 单据编号=:A');
 Query4.Params[0].AsInteger:=StrToInt(Label4.Caption);
 Query4.Open;
 if Query4.RecordCount=0 then
 begin
  ShowMessage('对不起,没有['+Label4.Caption+']号单据的出货信息.');
 end
 else
 begin
 DYYLBrose.Show;
 QuickRep1.Preview;
end;
end;
//预览报表
procedure TCHPZGL.QuickRep1Preview(Sender: TObject);
begin
 DYYLBrose.QRPreview1.QRPrinter:=QuickRep1.QRPrinter;
end;
//处理StringGrid1控件的回车事件
procedure TCHPZGL.StringGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 x:=StringGrid1.Row;//行变量x
 y:=StringGrid1.Col;//列变量y
 if key=$2D then
 begin
 if Length(StringGrid1.Cells[2,x-1])<>0 then //判断当前行的上一行是否为空
   begin
   Query2.Close;
   Query2.SQL.Clear;
   Query2.SQL.Add('select * From 库存信息表');
   Query2.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 TCHPZGL.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  ANimateWindow(Handle,300,AW_SLIDE+AW_HIDE+AW_VER_POSITIVE);
  CHPZGL.Release;
  CHPZGL:=nil;
end;
end.

⌨️ 快捷键说明

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