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

📄 changeunt.pas

📁 商品销售系统完全的功能SQL和JAVA
💻 PAS
📖 第 1 页 / 共 2 页
字号:
               begin
                  advstringgrid2.Cells[3,i]:=inttostr(strtoint(trim(advstringgrid2.Cells[3,i]))+1);
                  edit4.Text:='';
                  break;
                  exit;
               end
             else
               begin
                 advstringgrid2.Cells[1,hhno]:=trim(edit4.Text);
                 advstringgrid2.Cells[2,hhno]:=floattostr(dataman.thmainQuery.Fields[0].value);
                 advstringgrid2.Cells[3,hhno]:='1';
                 hhno:=hhno+1;
                 edit4.Text:='';
               end;
            end;
      end;
   end;
   end;
end;

procedure Tchangefrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
changefrm:=nil;
changefrm.Free;
end;

procedure Tchangefrm.BitBtn8Click(Sender: TObject);
begin
close;
end;

procedure Tchangefrm.AdvStringGrid2DrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var
 s:string;
 r:TRect;
  begin
 with advStringGrid2 do
   begin
     Canvas.FillRect(Rect);
     if ACol = 4 then
       begin
        Canvas.Font.Color := clred;
        canvas.Font.Style:=[fsBold];
       end;
     s:=Cells[ACol,ARow];
     r:=Rect;
     DrawText(Canvas.Handle,PChar(s),Length(s),r,DT_CENTER or DT_SINGLELINE or DT_VCENTER);
  end;

end;

procedure Tchangefrm.BitBtn7Click(Sender: TObject);
var
 i,j:integer;
begin
  yhno:=1;
  hhno:=1;
  for  i:=1 to advstringgrid1.RowCount do
   for j:=1 to advstringgrid1.ColCount do
    begin
     advstringgrid1.Cells[j,i]:='';
     advstringgrid2.Cells[j,i]:='';
    end;
  label11.Caption:='0';
  label10.Caption:='0';
  label19.Caption:='0';
  label20.Caption:='0';
  edit2.SetFocus;
end;

procedure Tchangefrm.Timer1Timer(Sender: TObject);
var
 j,l,quality1,quality2:integer;
 totalhh1,totalhh2:real;
begin
 totalhh1:=0;
 totalhh2:=0;
 quality1:=0;
 quality2:=0;
  for j:=1 to 5 do
     begin
      if advstringgrid1.Cells[1,j]='' then break;
      if trim(edit2.Text)='' then
      advstringgrid1.Cells[4,j]:=floattostr(strtofloatdef(trim(advstringgrid1.Cells[2,j]),0)*strtointdef(trim(advstringgrid1.Cells[3,j]),0))
      else
      advstringgrid1.Cells[4,j]:=floattostr(round(strtofloatdef(trim(advstringgrid1.Cells[2,j]),0)*strtointdef(trim(advstringgrid1.Cells[3,j]),0)*strtofloatdef(trim(label12.Caption),0.9)));
      totalhh1:=strtofloatdef(trim(advstringgrid1.cells[4,j]),0)+totalhh1;
      label10.Caption:=floattostr(totalhh1);
      quality1:=strtoint(trim(advstringgrid1.cells[3,j]))+quality1;
      label11.Caption:=inttostr(quality1);
     end;
  for l:=1 to 5 do
     begin
      if advstringgrid2.Cells[1,l]='' then break;
      if trim(edit2.Text)='' then
      advstringgrid2.Cells[4,l]:=floattostr(strtofloatdef(trim(advstringgrid2.Cells[2,l]),0)*strtointdef(trim(advstringgrid2.Cells[3,l]),0))
      else
      advstringgrid2.Cells[4,l]:=floattostr(round(strtofloatdef(trim(advstringgrid2.Cells[2,l]),0)*strtointdef(trim(advstringgrid2.Cells[3,l]),0)*strtofloatdef(trim(label12.Caption),0.9)));
      totalhh2:=strtofloatdef(trim(advstringgrid2.cells[4,l]),0)+totalhh2;
      label19.Caption:=floattostr(totalhh2);
      quality2:=strtoint(trim(advstringgrid2.cells[3,l]))+quality2;
      label20.Caption:=inttostr(quality2);
     end;
     edit1.Text:=floattostr(totalhh1-totalhh2);
end;

procedure Tchangefrm.BitBtn6Click(Sender: TObject);
var
 j:integer;
begin
  try
    dataman.ADOCon.BeginTrans;
    //录入换货单据
    with dataman.changemQuery do
      begin
      open;
      append;
      fieldbyname('换货单据号').Value:=trim(label6.Caption);
      fieldbyname('原货号').value:=trim(label6.Caption)+'YH';
      fieldbyname('换货号').value:=trim(label6.Caption)+'HH';
      if trim(edit2.Text)='' then
      fieldbyname('VIP卡号').Value:=null
      else
      fieldbyname('VIP卡号').Value:=edit2.Text;
      fieldbyname('换货数量').value:=strtoint(trim(label11.Caption))-strtoint(trim(label20.Caption));
      fieldbyname('换货金额').value:=strtoint(trim(label10.Caption))-strtoint(trim(label19.Caption));
      fieldbyname('换货时间').AsDateTime:=date();
      fieldbyname('经手人').AsString:=trim(edit5.Text);
      post;
      end;
    // 录入原货表记录
    WITH dataman.ygoodsQuery do
     begin
      open;
      for j:=1 to 5 do
      begin
      append;
      if trim(advstringgrid1.Cells[1,j])='' then break;
      fieldbyname('原货号').value:=trim(label6.Caption)+'YH';
      fieldbyname('货物条形码').value:=trim(advstringgrid1.Cells[1,j]);
      fieldbyname('数量').value:=trim(advstringgrid1.Cells[3,j]);
      fieldbyname('单价').value:=trim(advstringgrid1.Cells[2,j]);
      fieldbyname('金额').value:=trim(advstringgrid1.Cells[4,j]);
      post;
      end;
     end;
     //录入换货表
     with dataman.chgoodsQuery do
      begin
       open;
       for j:=1 to 5 do
       begin
       if trim(advstringgrid2.Cells[1,j])='' then break;
       append;
       fieldbyname('换货号').value:=trim(label6.Caption)+'HH';
       fieldbyname('货物条形码').value:=trim(advstringgrid2.Cells[1,j]);
       fieldbyname('数量').value:=trim(advstringgrid2.Cells[3,j]);
       fieldbyname('单价').value:=trim(advstringgrid2.Cells[2,j]);
       fieldbyname('金额').value:=trim(advstringgrid2.Cells[4,j]);
       post;
       end;
      end;
     //修改库存
     with dataman.kcQuery do
     begin
      close;
      sql.Clear;
      for j:=1 to 5 do
       begin
        if trim(advstringgrid1.Cells[1,j])='' then break;
        sql.Add('update kc set 库存数量=库存数量+:yhnumb where 货物条形码=:gno');
        parameters.ParamByName('yhnumb').Value:=strtoint(trim(advstringgrid1.Cells[3,j]));
        parameters.ParamByName('gno').Value:=trim(advstringgrid1.Cells[1,j]);
        execsql;
       end;
       close;
       sql.clear;
      for j:=1 to 5 do
       begin
        if trim(advstringgrid2.Cells[1,j])='' then break;
        sql.Add('update kc set 库存数量=库存数量-:hhnumb where 货物条形码=:gdno');
        parameters.ParamByName('hhnumb').Value:=strtoint(trim(advstringgrid2.Cells[3,j]));
        parameters.ParamByName('gdno').Value:=trim(advstringgrid2.Cells[1,j]);
        execsql;
       end;
     end;
    //修改会员消费额
     if trim(edit2.Text)<>'' then
      begin
       with dataman.xfztQuery do
        begin
         close;
         sql.Clear;
         sql.Add('update consume set 会员消费总金额=会员消费总金额- :hhxf where VIP卡号=:kh');
         parameters.ParamByName('hhxf').Value:=trim(edit1.Text);
         parameters.ParamByName('kh').Value:=trim(edit2.Text);
         execsql;
        end;
      end;
    dataman.changemQuery.UpdateBatch();
    dataman.ygoodsQuery.UpdateBatch();
    dataman.chgoodsQuery.UpdateBatch();
    Dataman.ADOCon.CommitTrans;
    showmessage('存盘成功!');
    except
     begin
       Dataman.ADOCon.RollbackTrans;
       showmessage('存盘失败!');
       exit;
       timer1.Enabled:=true;
     end;
    end;
end;

procedure Tchangefrm.BitBtn1Click(Sender: TObject);
var
  l:integer;
  f:TextFile;
  OutFile,th:string;
begin
    try
     OutFile:=ExtractFilePath(Application.ExeName)+'change.txt';
     AssignFile(F, OutFile);
     Rewrite(F);
     write(f,chr(27)+chr(64));
     th:=stringOfChar(' ',(32-Length('牧羊人服饰换货单据')) div 2)+'牧羊人服饰换货单据';
     write(f,th+chr(10));
     write(f,'换货单据号 :'+trim(label6.caption)+chr(10));
     write(f,('日期 :'+trim(label4.caption)):16);
     write(f,('经手人 :'+trim(edit5.text)):16);
     write(f,chr(10));
     write(f,'--------------------------------'+chr(10));
     write(f,'要换的商品'+chr(10));
     write(f,'--------------------------------'+chr(10));
      //       12345678901234567890123456789012
      Write(F,'商品条形码     单价  数量  金额 '+chr(10));
      Write(F,'--------------------------------');
      for l:=1 to 5 do
             begin
              if  trim(advstringgrid1.Cells[1,l])='' then break;
                write(f,trim(advstringgrid1.cells[1,l]):15);
                write(f,trim(advstringgrid1.cells[2,l]):5);
                write(f,trim(advstringgrid1.cells[3,l]):5);
                write(f,trim(advstringgrid1.cells[4,l]):5);
                write(f,chr(10));
             end;
           Write(F,'--------------------------------');
           write(f,'换后的商品'+chr(10));
           write(f,'--------------------------------'+chr(10));
           //       12345678901234567890123456789012
           Write(F,'商品条形码     单价  数量  金额 '+chr(10));
          Write(F,'--------------------------------');
          for l:=1 to 5 do
             begin
              if  trim(advstringgrid2.Cells[1,l])='' then break;
                write(f,trim(advstringgrid2.cells[1,l]):15);
                write(f,trim(advstringgrid2.cells[2,l]):5);
                write(f,trim(advstringgrid2.cells[3,l]):5);
                write(f,trim(advstringgrid2.cells[4,l]):5);
                write(f,chr(10));
             end;
           Writeln(F,'              ');
           Write(F,'--------------------------------');
           write(f,'应付差价 :'+trim(edit1.Text));
           Writeln(F,'              ');
           Writeln(F,'              ');
           Writeln(F,'              ');
           Writeln(F,'              ');
           Writeln(F,'              ');
           CloseFile(f);
           PrintFile(Outfile);
    except
     abort;
    end;
end;

end.

⌨️ 快捷键说明

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