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

📄 untpossendbill.pas

📁 适合行业为眼镜业
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  frm_Login_Man.Caption:='经手人选择';
  frm_Login_Man.ShowModal;
  SendMaster.vcEId := Employe_Check_Result;
  EdtG.Text := Employe_Check_Result;
  Perform(WM_NEXTDLGCTL, 0, 0);
end;

procedure TFmPosSendBill.SpeedButton5Click(Sender: TObject);
begin
//选择人员
  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;
  Perform(WM_NEXTDLGCTL, 0, 0);
end;

procedure TFmPosSendBill.EdtSendStockKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
  begin
    SpeedButton1Click(sender);
  end;
end;

procedure TFmPosSendBill.EdtRecvStockKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
    SpeedButton2Click(sender);
end;

procedure TFmPosSendBill.EdtMKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
   
end;

procedure TFmPosSendBill.EdtGKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
    SpeedButton4Click(sender);
end;

procedure TFmPosSendBill.EdtCKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
    SpeedButton5Click(sender);
end;

procedure TFmPosSendBill.EdtMemoKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_RETURN then
  begin
    sgorder.SetFocus;
    sgorder.Col := 1;
    sgorder.Row := 1;
  end;
end;

procedure TFmPosSendBill.SelectGoods(iRow: Integer);
begin
{
  sGoodsID := 'SYSP';
  sPtypeid := '0000100001';
  sGoodsName := '商品名称';
  sStd := '规格';
  sUserCode := 'UserCode';
  Grid.Cells[1, iRow] := sUserCode;
  Grid.Cells[2, iRow] := sGoodsName;
  Grid.Cells[3, iRow] := sStd;
  Grid.Cells[4, iRow] := SendMaster.VcSendStockName;
  Grid.Cells[5, iRow] := SendMaster.VcRecvStockName;
  Grid.Cells[19, iRow] := sPtypeid;
  Grid.Cells[16, iRow] := '10';
  Grid.Col := 6;
}
end;


function TFmPosSendBill.CheckData: Boolean;
var
  iRow: Integer;
begin
//
  Result := False;
  SendMaster.vcExplain := EdtMemo.Text;
  SendMaster.BillNo := EdtBillNo.Text;
  if Trim(SendMaster.BillNo) = '' then
  begin
    EdtBillNo.SetFocus;
    Application.MessageBox('单据编号不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
    Exit;
  end;
  if (Trim(EdtSendStock.Text) = '') or
    (SendMaster.vcSendStockID = '') then
  begin
    EdtSendStock.SetFocus;
    Application.MessageBox('配送仓库不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
    Exit;
  end;
  if (Trim(EdtRecvStock.Text) = '') or
    (SendMaster.vcRecvStockID = '') then
  begin
    EdtRecvStock.SetFocus;
    Application.MessageBox('收货仓库不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
    Exit;
  end;
  if (Trim(EdtM.Text) = '') or
    (SendMaster.vcListerId = '') then
  begin
    EdtM.SetFocus;
    Application.MessageBox('制单人不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
    Exit;
  end;
  if (Trim(EdtG.Text) = '') or
    (SendMaster.vcEId = '') then
  begin
    EdtG.SetFocus;
    Application.MessageBox('经手人不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
    Exit;
  end;
  if (Trim(EdtC.Text) = '') or
    (SendMaster.vcAssessorId = '') then
  begin
    EdtC.SetFocus;
    Application.MessageBox('审核人不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
    Exit;
  end;
  for iRow := 1 to sgorder.RowCount - 1 do
  begin
    if (sgorder.Cells[1, iRow] = '') or (sgorder.Cells[2, iRow] = '') then
    begin
      sgorder.SetFocus;
      sgorder.Row := iRow;
      sgorder.Col := 1;
      Application.MessageBox('当前商品不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
      Exit;
    end;
    {if sgorder.Cells[20, iRow] = '' then
    begin
      sgorder.SetFocus;
      sgorder.Row := iRow;
      sgorder.Col := 6;
      Application.MessageBox('请选择当前的单位!', pchar(application.Title), MB_OK + MB_ICONinformation);
      Exit;
    end;}
    
    if Trim(sgorder.Cells[7, iRow]) = '' then sgorder.Cells[7, iRow] := '0';
    if StrToFloat(sgorder.Cells[7, iRow]) = 0 then
    begin
      sgorder.SetFocus;
      sgorder.Row := iRow;
      sgorder.Col := 7;
      Application.MessageBox('请输入配送数量!', pchar(application.Title), MB_OK + MB_ICONinformation);
      Exit;
    end;
    if strtoint(trim(sgorder.Cells[7, iRow]))>strtoint(trim(sgorder.Cells[21, iRow])) then
    begin
      sgorder.SetFocus;
      sgorder.Row := iRow;
      sgorder.Col := 7;
      Application.MessageBox(pchar('现有库存数量不能满足配送数量!'), pchar(application.Title), MB_OK + MB_ICONinformation);
      Exit;
    end;
    if Trim(sgorder.Cells[8, iRow]) = '' then sgorder.Cells[8, iRow] := '0';
    {if StrToFloat(sgorder.Cells[8, iRow]) = 0 then
    begin
      sgorder.SetFocus;
      sgorder.Row := iRow;
      sgorder.Col := 8;
      Application.MessageBox('配送价不能为空或零!', pchar(application.Title), MB_OK + MB_ICONinformation);
      Exit;
    end;}
    sgorder.Cells[9, iRow] := FloatToStr(StrToFloat(sgorder.Cells[7, iRow]) * StrToFloat(Trim(sgorder.Cells[8, iRow])));
  end;

  Result := True;
end;

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

function TFmPosSendBill.SaveData: Boolean;
var
  IRow: Integer;
  fQty, fPrice, fTotal, dRate: Double;
  PsRst, iunit,i: Integer;
  iEditMode: Integer;
  mdata,Ddata:olevariant;//主副表数据
begin
  if ieditmode=1  then
  begin
    if not bedit then
    begin
      if trim(Handle_Man)<>trim(edtm.Text) then
      begin
        Application.MessageBox('不能修改数据!',pchar(application.Title),mb_iconinformation);
        exit;
      end;
    end;
  end;
  SendMaster.dtDrawDate:=date;
  for i:=1 to sgorder.RowCount-1 do
  begin
    SendMaster.nuTotalMoney:=SendMaster.nuTotalMoney+strtofloat(sgorder.cells[9,i]);
  end;
  Result := False;
  if SEditMode = '' then
    iEditMode := 0
  else
    iEditMode := 1;
  try
    CdsMasterData.EmptyDataSet;
    CdsMasterData.Append;
    CdsMasterData.FieldByName('vcSendBillId').AsString := SendMaster.vcSendBillId;
    CdsMasterData.FieldByName('VcSourceId').AsString := SendMaster.VcSourceId;
    CdsMasterData.FieldByName('vcSendStockID').AsString := SendMaster.vcSendStockID;
    CdsMasterData.FieldByName('vcRecvStockID').AsString := SendMaster.vcRecvStockID;
    CdsMasterData.FieldByName('vcEId').AsString := SendMaster.vcEId;
    CdsMasterData.FieldByName('vcListerId').AsString := SendMaster.vcListerId;
    CdsMasterData.FieldByName('vcAssessorId').AsString := SendMaster.vcAssessorId;
    CdsMasterData.FieldByName('vcOutHouseReadBillId').AsString := SendMaster.vcOutHouseReadBillId;
    CdsMasterData.FieldByName('vcExplain').AsString := SendMaster.vcExplain;
    CdsMasterData.FieldByName('BillStatus').Asinteger := SendMaster.BillStatus;
    CdsMasterData.FieldByName('iBIlltype').Asinteger := SendMaster.iBIlltype;
    CdsMasterData.FieldByName('inVoucherSign').Asinteger := SendMaster.inVoucherSign;
    CdsMasterData.FieldByName('inIsReadSign').Asinteger := SendMaster.inIsReadSign;
    CdsMasterData.FieldByName('SendStatus').Asinteger := SendMaster.SendStatus;
    CdsMasterData.FieldByName('NSumQty').AsFloat := SendMaster.NSumQty;
    CdsMasterData.FieldByName('nuCess').AsFloat := SendMaster.nuCess;
    CdsMasterData.FieldByName('nuTax').AsFloat := SendMaster.nuTax;
    CdsMasterData.FieldByName('nuIncTaxSum').AsFloat := SendMaster.nuIncTaxSum;
    CdsMasterData.FieldByName('nuTotalMoney').AsFloat := SendMaster.nuTotalMoney;
    CdsMasterData.FieldByName('nuUnTaxSum').AsFloat := SendMaster.nuUnTaxSum;
    CdsMasterData.FieldByName('dtDrawDate').AsDateTime := SendMaster.dtDrawDate;
    CdsMasterData.FieldByName('dtOutStockDate').AsDateTime := SendMaster.dtOutStockDate;
    CdsMasterData.FieldByName('BillNo').AsString := SendMaster.BillNo;
    CdsMasterData.FieldByName('ObjectID').asInteger := SendMaster.ObjectID;
    CdsDetailData.EmptyDataSet;
    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 :='配送';
      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 raise Exception.Create('单据保存失败!');
    Result := True;
  except
    on E: Exception do
    begin
      Application.MessageBox(Pchar(E.message), pchar(application.Title), MB_OK + MB_ICONinformation)
    end;
  end;
end;

procedure TFmPosSendBill.TeThemeButton1Click(Sender: TObject);
begin
//  Grid.AddRow;

end;

function TFmPosSendBill.ReadBill: Boolean;
var
  iRow: Integer;

⌨️ 快捷键说明

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