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

📄 uydposbill.pas

📁 适合行业为眼镜业
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    for IRow := 1 to sgorder.RowCount - 1 do
    begin
      CdsDetailData.Append;
      CdsDetailData.FieldByName('vcSendBillId').AsString := SendMaster.vcSendBillId;
      CdsDetailData.FieldByName('ord').asInteger := IRow;
      CdsDetailData.FieldByName('InOrderId').asInteger := IRow;
      CdsDetailData.FieldByName('vcPtypeid').AsString := Trim(sgorder.cells[2, iRow]);
      CdsDetailData.FieldByName('VcSendStockID').AsString := Trim(SendMaster.vcSendStockID);
      CdsDetailData.FieldByName('VcRecvStockID').AsString := Trim(SendMaster.vcRecvStockID);
      CdsDetailData.FieldByName('vcBatch').AsString := '';
      CdsDetailData.FieldByName('vcGoodUnitId').AsString := Trim(sgorder.cells[6, iRow]);
      CdsDetailData.FieldByName('GoodsMemo').AsString := Trim(sgorder.cells[17, iRow]);
      dRate := StrToFloat(sgorder.Cells[16, iRow]);
      iunit:=0;
      if iunit = 1 then
      begin
        fQty := StrToFloat(Trim(sgorder.cells[7, iRow])) * dRate;
        CdsDetailData.FieldByName('nuOutQuantity').asFloat := fQty;
        fPrice := StrToFloat(Trim(sgorder.cells[8, iRow])) / dRate;
        CdsDetailData.FieldByName('SendPrice').asFloat := fPrice;
      end
      else
      begin
        fQty := StrToFloat(Trim(sgorder.cells[7, iRow]));
        CdsDetailData.FieldByName('nuOutQuantity').asFloat := fQty;
        fPrice := StrToFloat(Trim(sgorder.cells[8, iRow]));
        CdsDetailData.FieldByName('SendPrice').asFloat := fPrice;
      end;
      fTotal := fPrice * fQty;
      CdsDetailData.FieldByName('SendTotal').asFloat := fTotal;
      CdsDetailData.FieldByName('nuCess').asFloat := 0;
      CdsDetailData.FieldByName('nuIncTaxPrice').asFloat := fPrice;
      CdsDetailData.FieldByName('nuTax').asFloat := 0;
      CdsDetailData.FieldByName('NTaxTotal').asFloat := fTotal;
      CdsDetailData.FieldByName('nuCostPrice').asFloat := fPrice;
      CdsDetailData.FieldByName('NCastTotal').asFloat := fTotal;
      CdsDetailData.FieldByName('iUnit').asInteger := iunit;
      CdsDetailData.FieldByName('NRate').asFloat := dRate;
    end;
    PsRst := CdsDetailData.RecordCount;
    if ieditmode=0 then   //写草稿;
    begin
      dmmain.cdsReceipt.close;
      dmmain.cdsReceipt.Open;
      dmmain.cdsReceipt.Append;
      dmmain.cdsReceipt.FieldByName('Receipt_NO').AsString:=Trim(edtbillno.Text);
      dmmain.cdsReceipt.FieldByName('Receipt_Name').AsString:='预定商品配送单';
      dmmain.cdsReceipt.FieldByName('Copy_Date').AsString:=formatdatetime('yyyy''-''mm''-''dd',date);
      dmmain.cdsReceipt.FieldByName('Proposer').AsString:=Trim(Edtm.Text);
      dmmain.cdsReceipt.FieldByName('Check_Result').Asinteger:=0;
      dmmain.cdsReceipt.FieldByName('Flag_Sign').AsString:='草稿';
      dmmain.cdsReceipt.FieldByName('Condense').AsString:='仓库【'+shopid+'】指定出货仓库【'+EdtSendStock.Text+'】向仓库'+EdtRecvStock.Text+'预定商品配送';
      dmmain.cdsReceipt.FieldByName('Re_part').AsString:=trim(Handle_Part);
      dmmain.cdsReceipt.Post;
      dmmain.cdsReceipt.ApplyUpdates(-1);
    end;
    mdata:= CdsMasterData.Data;
    Ddata:=CdsDetailData.Data;
    adisp.InsertSendBill(mData,dData,iEditMode, PsRst);

    if PsRst <> 0 then
    begin
      raise Exception.Create('单据保存失败!');
    end else
    begin
      if iEditMode=0 then   //改变;
      begin
        temp:=' update Getgoodsglanmaster set IPlanStatus=0 where VcGetGoodsPlanID='+''''+trim(Glanno)+'''';
        try
          adisp.updatesql(temp);
        except
        end;
      end;
    end;
    Result := True;
  except
    on E: Exception do
    begin
      Application.MessageBox(Pchar(E.message), pchar(application.Title), MB_OK + MB_ICONinformation)
    end;
  end;
end;
function TFmYdPosBill.ReadBill: Boolean;
var
  iRow: Integer;
  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;
  //------显示明细数据--------------//
  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);
      sgorder.Cells[17,iRow] := trim(dmmain.CDSquery2.Fieldbyname('goodsmemo').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';
      //sgorder.Cells[21,iRow] := trim(dmmain.CDSquery2.Fieldbyname('goodsmemo').AsString);
      dmmain.CDSquery2.Next;
    end;
    except
    end;
    Result := True;
  except
    Result := False;
  end;
end;
procedure TFmYdPosBill.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 TFmYdPosBill.SpeedButton3Click(Sender: TObject);
begin
  inherited;
   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
     SendMaster.VcSourceId:=officeid;
     EdtRecvStock.Text:=trim(dmmain.CDSdata.fieldbyname('storageid').AsString);
     SendMaster.vcRecvStockID:=trim(edtrecvstock.Text);
     DlgYdPos:=tDlgYdPos.Create(self);
     DlgYdPos.p_no:=trim(officeid);
     DlgYdPos.SHOPNO:=trim(EdtRecvStock.Text);
     DlgYdPos.ShowModal;
     if not dmmain.cdsyddata.IsEmpty  then
     begin
       if readglan(dmmain.cdsyddata.fieldbyname('VcGetGoodsPlanID').AsString) then
       begin
         Glanno:=trim(dmmain.cdsyddata.fieldbyname('VcGetGoodsPlanID').AsString);
         OrderNO:=trim(dmmain.cdsyddata.fieldbyname('Memo').AsString);
       end;
     end;
     dmmain.cdsyddata.close;
     dmmain.cdsyddata.data:=null;
   end;
   dmmain.CDSdata.Close;
   dmmain.CDSdata.Data:=null;
end;

procedure TFmYdPosBill.sgorderDrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  s:string;
  r:TRect;
begin
  inherited;
 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 TFmYdPosBill.sgorderSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
  inherited;
  pcol:=acol;
  prow:=arow;
end;

procedure TFmYdPosBill.bitcheckClick(Sender: TObject);
var
  user,s,temp,remarks,ofid:widestring;
  flag,intof:olevariant;
  totals:double;
  i:integer;
begin
  inherited;
  if trim(SEditMode) = ''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);
    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 TFmYdPosBill.SpeedButton1Click(Sender: TObject);
var
  sStockID, sStockName: string;
begin
  inherited;
//选择中心仓库
  sStockID := '';
  sStockName := '';
  Check_Storage:='';
  Check_Storage_Result:='';
  Check_Storage:='Storage_Umanage_Fad';
  frm_Storage_Select:=Tfrm_Storage_Select.Create(self);
  frm_Storage_Select.ShowModal;
  sStockName:=Trim(Check_Storage_Result);
  sStockID:=Check_Storage_Result_NO;
  frm_Storage_Select.Free;
  EdtSendStock.Text:= sStockName;
  SendMaster.vcSendStockID := sStockID;
  SendMaster.VcSendStockName := sStockName;
end;

procedure TFmYdPosBill.BitBtn1Click(Sender: TObject);
begin
  inherited;
  sendmaster.vcListerId:=trim(Handle_Man);
  if not CheckData then Exit;
  if not SaveData then Exit;
  FormIni;
end;

procedure TFmYdPosBill.BitBtn2Click(Sender: TObject);
begin
  inherited;
  close;
end;

procedure TFmYdPosBill.SpeedButton4Click(Sender: TObject);
begin
  inherited;
  Employe_Check:='';
  Employe_Check:='Storage_Umanage_Fad';
  Employe_Check_Result:='';
  frm_Login_Man:=Tfrm_Login_Man.Create(self);
  frm_Login_Man.Caption:='经手人选择';
  frm_Login_Man.ShowModal;
  SendMaster.vcEId := Employe_Check_Result;
  EdtG.Text := Employe_Check_Result;
end;

procedure TFmYdPosBill.SpeedButton5Click(Sender: TObject);
begin
  inherited;
  Employe_Check:='';
  Employe_Check:='Storage_Umanage_Fad';
  Employe_Check_Result:='';
  frm_Login_Man:=Tfrm_Login_Man.Create(self);
  frm_Login_Man.Caption:='审核人选择';
  frm_Login_Man.ShowModal;
  SendMaster.vcAssessorId := Employe_Check_Result;
  EdtC.Text := Employe_Check_Result;
end;

end.

⌨️ 快捷键说明

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