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

📄 untposaskbackbill.pas

📁 适合行业为眼镜业
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    EdtBillNo.SetFocus;
    Application.MessageBox('单据编号不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
    Exit;
  end;
  if (Trim(EdtSendStock.Text) = '') then
  begin
    EdtSendStock.SetFocus;
    Application.MessageBox('要货单位不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
    Exit;
  end;
  if (Trim(EdtRecvStock.Text) = '') then
  begin
    EdtRecvStock.SetFocus;
    Application.MessageBox('要货仓库不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
    Exit;
  end;
  if (Trim(EdtM.Text) = '') or
    (AskMaster.VcEID = '') then
  begin
    EdtM.SetFocus;
    Application.MessageBox('申请人不能为空!', pchar(application.Title), MB_OK + MB_ICONinformation);
    Exit;
  end;
  if (Trim(EdtC.Text) = '') or
    (AskMaster.vcCheckE = '') 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[8, iRow] = '' then
    begin
      sgorder.SetFocus;
      sgorder.Row := iRow;
      sgorder.Col := 4;
      Application.MessageBox('请选择当前的单位!', pchar(application.Title), MB_OK + MB_ICONinformation);
      Exit;
    end;
    if Trim(sgorder.Cells[5, iRow]) = '' then sgorder.Cells[5, iRow] := '0';
    if StrToFloat(sgorder.Cells[5, iRow]) = 0 then
    begin
      sgorder.SetFocus;
      sgorder.Row := iRow;
      sgorder.Col := 5;
      Application.MessageBox('请输入申请数量!', pchar(application.Title), MB_OK + MB_ICONinformation);
      Exit;
    end;
  end;

  Result := True;
end;

function TFmPosAskBackBill.SaveData: Boolean;
var
  IRow: Integer;
  fQty, fEndQty,dRate: Double;
  PsRst,iunit: Integer;
  iEditMode,IStatus: Integer;
  mdata,Ddata:olevariant;//主副表数据
begin
//
  Result := False;
  if SEditMode = '' then
    iEditMode := 0
  else
    iEditMode := 1;
  try
   CdsMasterData.EmptyDataSet;
    CdsMasterData.Append;
    CdsMasterData.FieldByName('VcGetGoodsPlanID').AsString := AskMaster.VcGetGoodsPlanID;
    CdsMasterData.FieldByName('VcBillNo').AsString := AskMaster.BillNo;
    CdsMasterData.FieldByName('VCOfficeID').AsString := AskMaster.VCOfficeID;
    CdsMasterData.FieldByName('iBilltype').asinteger := AskMaster.iBillType;
    CdsMasterData.FieldByName('VcStockID').AsString := AskMaster.VcStockID;
    CdsMasterData.FieldByName('DGetDate').asDateTime := AskMaster.DGetDate;
    CdsMasterData.FieldByName('VcEID').AsString := AskMaster.VcEID;
    CdsMasterData.FieldByName('vcCheckE').AsString := AskMaster.vcCheckE;
    CdsMasterData.FieldByName('Memo').AsString := AskMaster.Memo;
    CdsMasterData.FieldByName('IPlanStatus').Asinteger := AskMaster.IPlanStatus;
    CdsDetailData.EmptyDataSet;
    for IRow := 1 to sgorder.RowCount - 1 do
    begin
      CdsDetailData.Append;
      CdsDetailData.FieldByName('VcGetGoodsPlanID').AsString := AskMaster.VcGetGoodsPlanID;
      CdsDetailData.FieldByName('ord').asInteger := IRow;
      CdsDetailData.FieldByName('VCPtyieID').AsString := Trim(sgorder.cells[2, iRow]); //商品编号 
      CdsDetailData.FieldByName('vcGoodUnitId').AsString := Trim(sgorder.cells[4, iRow]);
      iunit :=  StrToInt(sgorder.Cells[12,iRow]);
      dRate := StrToFloat(sgorder.Cells[11,iRow]);
      if iunit = 1 then
      begin
        fQty := StrToFloat(Trim(sgorder.cells[5, iRow])) * dRate;
        CdsDetailData.FieldByName('NQty').asFloat := fQty;
        fEndQty := StrToFloat(Trim(sgorder.cells[6, iRow]));
        CdsDetailData.FieldByName('NSendQty').asFloat := fEndQty;
        CdsDetailData.FieldByName('NEndQty').asFloat := fQty - fEndQty;      
      end
      else
      begin
        fQty := StrToFloat(Trim(sgorder.cells[5, iRow]));
        CdsDetailData.FieldByName('NQty').asFloat := fQty;
        fEndQty := StrToFloat(Trim(sgorder.cells[6, iRow]));
        CdsDetailData.FieldByName('NSendQty').asFloat := fEndQty;
        CdsDetailData.FieldByName('NEndQty').asFloat := fQty - fEndQty;
      end;
      IStatus := StrToInt(sgorder.Cells[10,iRow]);
      CdsDetailData.FieldByName('IGetStatus').asFloat := IStatus;
      CdsDetailData.FieldByName('iUnit').asFloat := iunit;
      CdsDetailData.FieldByName('NRate').asFloat := dRate;
    end;
    PsRst := CdsDetailData.RecordCount;
    //adisp.InsertGetPlan(CdsMasterData.Data,CdsDetailData.Data, iEditMode, PsRst);
    mdata:= CdsMasterData.Data;
     Ddata:=CdsDetailData.Data;
     adisp.InsertGetPlan(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 TFmPosAskBackBill.CdsDetailDataBeforeGetRecords(Sender: TObject;
  var OwnerData: OleVariant);
begin
  OwnerData := 'Select * from GetGoodsPlan where VcGetGoodsPlanID =''' + sBillId + '''';
end;

procedure TFmPosAskBackBill.CdsMasterDataBeforeGetRecords(Sender: TObject;
  var OwnerData: OleVariant);
begin
  OwnerData := 'Select * from GetGoodsPlanMaster where VcGetGoodsPlanID = ''' + sBillId + '''';
end;

procedure TFmPosAskBackBill.BtnCloseClick(Sender: TObject);
begin
  Close;
end;

procedure TFmPosAskBackBill.sgordeDblClickCell(Sender: TObject; ARow,
  ACol: Integer);
begin
  if ACol = 7 then
  begin
     CheckCells(ACol,ARow);
  end;
end;

procedure TFmPosAskBackBill.CheckCells(ACol, ARow: Integer);
begin
  if (Trim(sgorder.Cells[10, ARow]) = '0') or
    (Trim(sgorder.Cells[10, ARow]) = '') then
  begin
    sgorder.Cells[ACol, ARow] := '【已审】';
    sgorder.Cells[10, ARow] := '1';
  end
  else
  begin
    sgorder.Cells[ACol, ARow] := '【未审】';
    sgorder.Cells[10, ARow] := '0';
  end;
end;

procedure TFmPosAskBackBill.BtnSaveClick(Sender: TObject);
begin
  if Not CheckData then Exit;
  if Not SaveData then Exit;
  if SEditMode = '' then
  begin
     FormIni;
     EdtSendStock.SetFocus;
     Exit;
  end;
  Close;
end;

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

procedure TFmPosAskBackBill.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
var
  irst: integer;
begin
  irst :=  Application.MessageBox('是否保存当前单据?','系统提示:', MB_YESNOCANCEL + MB_ICONQUESTION + MB_DEFBUTTON3);
  if irst = mrCancel then
  begin
     CanClose := False;
  end;
  
  if irst = mrYes then
  begin
     BtnSaveClick(Sender);
     CanClose := False;
  end;
  if irst = MrNo then
  begin
    CanClose := True;
  end;
end;


function TFmPosAskBackBill.ReadBill: Boolean;
var
  iRow: Integer;
begin
//
  Result := False;
  if SEditMode = '' then Exit;
  try
    if CdsMasterData.Active then CdsMasterData.Close;
    if CdsDetailData.Active then CdsDetailData.Close;
    CdsMasterData.Open;
    CdsDetailData.Open;
  //---显示数据,并且给相应变量付值------//



  //------显示明细数据--------------//
    CdsDetailData.First;
    for iRow := 1 to CdsDetailData.RecordCount do
    begin
   //
      sgorder.Cells[0, iRow] := IntToStr(CdsDetailData.RecNo);

      CdsDetailData.Next;
    end;
    Result := True;
  except
    Result := False;
  end;
end;

procedure TFmPosAskBackBill.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 TFmPosAskBackBill.sgorderDblClick(Sender: TObject);
var
  i:integer;
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;

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

procedure TFmPosAskBackBill.sgorderKeyPress(Sender: TObject;
  var Key: Char);
begin
  if (pcol =5) or (pcol =6){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];
   key := #0;
  end;

end;

procedure TFmPosAskBackBill.bitcheckClick(Sender: TObject);
var
  user:widestring;
  flag:olevariant;
begin
  if trim(sBillId)=''then exit;
  if trim(sgorder.Cells[1,1])='' then exit;
  no:=trim(edtbillno.Text);
  typed:='退货申请单';
  user:=trim(Handle_No);
  flag:=adisp.receipted(no,typed,user,1,Handle_Part);
  if flag='1' then
  begin
    application.MessageBox('审核成功!',pchar(application.Title),mb_iconinformation);
    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);
    //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;

end.

⌨️ 快捷键说明

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