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

📄 untpossendbill.pas

📁 适合行业为眼镜业
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  sql:widestring;
begin
//
  Result := False;
  if SEditMode = '' then Exit;
  try
  //---显示数据,并且给相应变量付值------//

    sql:='select a.*,b.*,c.* from sendmastertable as a ,senddetailtable as b, vSelectGoods as c where b.vcSendBillId=a.vcSendBillId and b.vcPtypeid =c.goods_no and c.storage_no= a.vcSendStockID  and a.ibilltype=503 and a.BillNo='+''''+trim(list_no)+'''';   //5-7 WG EDIT
    dmmain.CDSquery2.Close;
    dmmain.CDSquery2.Data:=null;
    try
    dmmain.CDSquery2.Data:=adisp.resultrecord(sql);
    dmmain.CDSquery2.Open;
    edtbillno.Text:=trim(dmmain.CDSquery2.fieldbyname('billno').AsString);
    //edtsourcno.Text:=trim(dmmain.CDSquery2.fieldbyname('VcSourceId').AsString);
    EdtSendStock.Text:=trim(dmmain.CDSquery2.fieldbyname('vcSendStockID').AsString);
    EdtRecvStock.Text:=trim(dmmain.CDSquery2.fieldbyname('vcRecvStockID').AsString);
    edtm.Text:=trim(dmmain.CDSquery2.fieldbyname('vcListerId').AsString);
    edtg.Text:=trim(dmmain.CDSquery2.fieldbyname('vcEId').AsString);
    edtc.Text:=trim(dmmain.CDSquery2.fieldbyname('vcAssessorId').AsString);
    edtmemo.Text:=trim(dmmain.CDSquery2.fieldbyname('vcExplain').AsString);
    SendMaster.nuTotalMoney:= dmmain.CDSquery2.fieldbyname('nuTotalMoney').asfloat;
    SendMaster.vcSendStockID:=EdtSendStock.Text;
    SendMaster.vcRecvStockID:=EdtRecvStock.Text;
    SendMaster.BillNo:=edtbillno.Text;
    SendMaster.iBIlltype:=dmmain.CDSquery2.fieldbyname('iBIlltype').AsInteger;
    SendMaster.vcListerId:=edtm.Text;
    SendMaster.vcEId :=edtg.Text;
    SendMaster.vcAssessorId:=edtc.Text;
    SendMaster.VcSourceId:=dmmain.CDSquery2.fieldbyname('VcSourceId').AsString;
    edtpart.Text:=SendMaster.VcSourceId;
    speedbutton3.Enabled:=false;
    speedbutton1.Enabled:=false;
    speedbutton2.Enabled:=false;
  //------显示明细数据--------------//
  sgorder.RowCount:=dmmain.CDSquery2.RecordCount+1;
    for iRow := 1 to dmmain.CDSquery2.RecordCount do
    begin
   //
      sgorder.Cells[0, iRow] := IntToStr(dmmain.CDSquery2.RecNo);
      sgorder.Cells[1, iRow]:= trim(dmmain.CDSquery2.fieldbyname('type').AsString);
      sgorder.Cells[2, iRow]:=trim(dmmain.CDSquery2.fieldbyname('vcPtypeid').AsString);//编码
      sgorder.Cells[3, iRow]:=trim(dmmain.CDSquery2.fieldbyname('goods_name').AsString);
      sgorder.Cells[6,iRow] := trim(dmmain.CDSquery2.Fieldbyname('vcGoodUnitId').AsString);
      sgorder.Cells[7,iRow] := trim(dmmain.CDSquery2.Fieldbyname('nuOutQuantity').AsString);
      //gorder.Cells[4,iRow] := trim(dmmain.CDSquery2.Fieldbyname('base_unit').AsString);
      sgorder.Cells[8,iRow] := trim(dmmain.CDSquery2.Fieldbyname('SendPrice').AsString);
      sgorder.Cells[9,iRow] := trim(dmmain.CDSquery2.Fieldbyname('SendTotal').AsString);
      sgorder.Cells[21,iRow] := trim(dmmain.CDSquery2.Fieldbyname('stock_amount').AsString);
      sgorder.Cells[19,irow ] := '0000100001';
      sgorder.Cells[16,irow ] := '10';
      sgorder.Cells[11,iRow ] := '10';
      dmmain.CDSquery2.Next;
    end;
    except
    end;
    Result := True;
  except
    Result := False;
  end;
end;

procedure TFmPosSendBill.SumCol(ACol, ARow: Integer);
var
  dQty, dPrice: Double;
begin
//
  if (ACOl = 7) or (ACOL = 8) then
  begin
    if (Trim(sgorder.Cells[7, ARow]) <> '') and
      (Trim(sgorder.Cells[8, ARow]) <> '') then
    begin
      if Trim(sgorder.Cells[7, ARow]) = '' then sgorder.Cells[7, ARow] := '0';
      if Trim(sgorder.Cells[8, ARow]) = '' then sgorder.Cells[8, ARow] := '0.00';
      dQty := StrToFloat(sgorder.Cells[7, ARow]);
      dPrice := StrToFloat(sgorder.Cells[8, ARow]);
      sgorder.Cells[9, ARow] := FloatToStr(dQty * dPrice);
    end;
  end;
end;

procedure TFmPosSendBill.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_EsCaPE then
    Close;
end;

procedure TFmPosSendBill.sgorderDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  s:string;
  r:TRect;
begin
//ydy add 设置显示颜色
 with Sender as Tstringgrid do
        begin
        if gdSelected in State then
        Canvas.Brush.Color:= clTeal;  //clBlue; //clyellow;//clRed;
        Canvas.TextRect(Rect,Rect.Left,Rect.Top,' '+Cells[ACol,ARow]);
        if gdFocused in State then
        Canvas.DrawFocusRect(Rect);
        end;

//不但水平居中,还垂直居中
with Sender as Tstringgrid do
    begin
      Canvas.FillRect(Rect);
      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 TFmPosSendBill.sgorderDblClick(Sender: TObject);
var
  i:integer;
begin
/////复制  数量  单位等
  if zd then  //从要货计划转单,
  begin
  if (pcol = 1) or (pcol =2) then
  begin
   dlgmsggoods:=tdlgmsggoods.Create(self);
   dlgmsggoods.model:=1;
   dlgmsggoods.ShowModal;
   dlgmsggoods.Free;
  end;
  end else  //主动配送
  begin
    if (pcol = 1) or (pcol =2) then
    begin
     fmgoodCodeSelPei:= TfmgoodCodeSelPei.Create(nil);
     try
     fmgoodCodeSelPei.show_mode := '配送收货单';
     fmgoodCodeSelPei.ShowModal;
     finally
     fmgoodCodeSelPei.Free;
   end;
   end;
  end;
  if pcol=7 then
  begin
    for i:=prow+1 to sgorder.RowCount-1 do
    begin
      sgorder.Cells[7,i]:= sgorder.Cells[7,prow]
    end;
  end;
end;

procedure TFmPosSendBill.sgorderSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  pcol:=acol;
  prow:=arow;
end;

procedure TFmPosSendBill.sgorderKeyPress(Sender: TObject; var Key: Char);
begin
  if (pcol =7) or (pcol =8){in [3]}  then
  begin
    if not (key in ['0'..'9',#8]) then    //数量没有小数点
    key:=#0;
    sgorder.Options := sgorder.Options+ [goediting];
  end else
  begin
   sgorder.Options := sgorder.Options - [goediting];

  end;

end;

procedure TFmPosSendBill.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  shopid:=ckid;
  action:=cafree;
end;

procedure TFmPosSendBill.bitcheckClick(Sender: TObject);
var
  user,s,temp,remarks,ofid:widestring;
  flag,intof:olevariant;
  totals:double;
  i:integer;
begin
  if trim(sBillId)=''then exit;
  if trim(sgorder.Cells[1,1])='' then exit;
  no:=trim(edtbillno.Text);
  s:=trim(EdtSendStock.Text);
  typed:='配送单';
  user:=trim(Handle_No);
  flag:=adisp.receipted(no,typed,user,1,Handle_Part);
  if flag='3' then //
  begin
    //////////////修改配送单据状态,改为收货状态;修改要货计划的已配数量,满足后设置为配送完成状态/////////
    try
    temp:='update sendmastertable set SendStatus=3,iBIlltype=501 where BillNo='+''''+trim(edtbillno.Text)+'''';
    ipubtemp.scrapsate(temp); //修改配送单;
    /////////////////////////要货单细表;
    ofid:=trim(edtpart.Text);
    ipubtemp.Updatebatch(no,ofid);
    ///////////////////////
    /////////////////////////配送出库
    flag:=ipubtemp.batchstock(no,1);
    ////////////////////////////////
    ////////////////////财务
    remarks:='从:【'+shopid+'】仓库配送商品';
    /////////////////////////////财务////////////////
    //////////////////////////////////////////////////////////////
    except
      application.MessageBox('服务器发生故障!',pchar(application.Title),mb_iconwarning);
      exit;
    end;
    ////////////////////
  end;
  if flag='1' then
  begin
    application.MessageBox('审核成功!',pchar(application.Title),mb_iconinformation);
    close;
    exit;
  end;
  if flag='2' then
  begin
    application.MessageBox('无权进行进行审核',pchar(application.Title),mb_iconinformation);
    exit;
  end;
  if flag='3' then
  begin
    application.MessageBox('审核完毕!',pchar(application.Title),mb_iconinformation);
    close;
    //exit;
  end;
  if flag='4' then
  begin
    application.MessageBox('反审核完毕!',pchar(application.Title),mb_iconinformation);
    exit;
  end;
  if flag='5' then
  begin
    application.MessageBox('反审核成功!',pchar(application.Title),mb_iconinformation);
    exit;
  end;
  if flag='6' then
  begin
    application.MessageBox('单据过帐后,不能进行审核或反审核!',pchar(application.Title),mb_iconinformation);
    exit;
  end;
end;

procedure TFmPosSendBill.sgorderMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
var
  i:integer;  
begin
  if prow<>0 then
  begin
    if (trim(sgorder.Cells[7,prow])<>'') and (trim(sgorder.Cells[21,prow])<>'') then
    begin
      if strtoint(sgorder.Cells[7,prow])> strtoint(sgorder.Cells[21,prow]) then
      begin
        sgorder.Cells[7,prow]:='0';
        application.MessageBox('数量已超过库存数量!',pchar(application.Title),mb_iconinformation);
        exit;
      end;
    end;  
  end;  
  for i:=1 to sgorder.RowCount-1 do
  begin
    SumCol(8,i);
  end;
end;

procedure TFmPosSendBill.SpeedButton3Click(Sender: TObject);
begin
   dlgSQpspart:=tdlgSQpspart.Create(self);
   dlgSQpspart.ShowModal;
   dlgSQpspart.Free;
   if dmmain.CDSdata.IsEmpty  then exit;
   edtpart.Text:=trim(dmmain.CDSdata.fieldbyname('part_name').AsString);
   officeid:=trim(dmmain.CDSdata.fieldbyname('part_no').AsString);
   if trim(edtpart.Text)<>'' then
   begin
     zd:=true;
     SendMaster.VcSourceId:=officeid;
     EdtRecvStock.Text:=trim(dmmain.CDSdata.fieldbyname('storageid').AsString);
     SendMaster.vcRecvStockID:=trim(edtrecvstock.Text);
     speedbutton2.Enabled:=false;
   end else
   begin
     zd:=false;
     SendMaster.VcSourceId:='#';//没有就给一特定字符;
   end;
   dmmain.CDSdata.Close;
   dmmain.CDSdata.Data:=null;
   //shopid:=dmmain.
end;

procedure TFmPosSendBill.edtpartChange(Sender: TObject);
begin
  if trim(edtpart.Text)<>'' then
  begin
    shopid:=ckid ;
  end ;
end;

procedure TFmPosSendBill.Cmd_AddClick(Sender: TObject);
begin
  addgridrows(sgorder);
end;

procedure TFmPosSendBill.Cmd_DeleteClick(Sender: TObject);
begin
  deletegridrows(sgorder,prow);
end;

procedure TFmPosSendBill.sourcebillClick(Sender: TObject);
begin
  if trim(sBillId)=''then exit;
  fastrepxf:=tfastrepxf.Create(self);
  fastrepxf.frReportxf.Dataset:=nil;
  fastrepxf.filenames:='PosBill.ini';
  fastrepxf.ShowModal;
  fastrepxf.Free;
end;

end.

⌨️ 快捷键说明

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