📄 uydposbill.pas
字号:
unit UYdPosBill;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, fm_Base, ExtCtrls, StdCtrls, Buttons, Grids, DB, DBClient;
type TSendMaster = record
vcSendBillId: string;
VcSourceId: string;
BillNo: string;
iBIlltype: integer;
vcSendStockID: string; //配送仓库
vcRecvStockID: string; //接收门店仓库
dtDrawDate: TDateTime;
dtOutStockDate: Tdatetime;
vcEId: string; ///经手人
vcListerId: string; // 制单人
vcAssessorId: string; //审核人
NSumQty: Double;
nuCess: Double;
nuTax: Double;
nuIncTaxSum: Double;
nuTotalMoney: Double;
nuUnTaxSum: Double;
BillStatus: Integer;
inVoucherSign: Integer;
inIsReadSign: Integer;
vcOutHouseReadBillId: string;
inByReadSign: Integer;
vcExplain: string;
SendStatus: Integer;
VcSendStockName: string;
VcRecvStockName: string;
ObjectID: Integer;
end;
type
TFmYdPosBill = class(TfmBase)
CdsMasterData: TClientDataSet;
CdsDetailData: TClientDataSet;
Panel3: TPanel;
sgorder: TStringGrid;
Panel10: TPanel;
Cmd_Delete: TSpeedButton;
Cmd_Add: TSpeedButton;
Panel2: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
bitcheck: TBitBtn;
Panel1: TPanel;
Label2: TLabel;
SpeedButton1: TSpeedButton;
Label1: TLabel;
Label3: TLabel;
Label4: TLabel;
SpeedButton4: TSpeedButton;
Label5: TLabel;
SpeedButton5: TSpeedButton;
Label6: TLabel;
SpeedButton3: TSpeedButton;
EdtSendStock: TEdit;
Panel4: TPanel;
TeThemeButton1: TSpeedButton;
TeThemeButton2: TSpeedButton;
sourcebill: TSpeedButton;
query: TSpeedButton;
help: TSpeedButton;
BillTitle: TLabel;
EdtRecvStock: TEdit;
EdtM: TEdit;
EdtG: TEdit;
EdtC: TEdit;
EdtMemo: TEdit;
StaticText1: TStaticText;
EdtBillNo: TEdit;
edtpart: TLabeledEdit;
procedure SpeedButton3Click(Sender: TObject);
procedure sgorderDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure sgorderSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure bitcheckClick(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
private
{ Private declarations }
OrderNO:string;//定单编号;
SendMaster: TSendMaster;
sBillId, SEditMode: string;
sGoodsName,Glanno: string;
sUserCode: string;
pcol,prow:integer;
ckid:string;
procedure FormIni;
//procedure SelectGoods(iRow: Integer);
function CheckData: Boolean;
function SaveData: Boolean;
function ReadBill: Boolean;
procedure SumCol(ACol, ARow: Integer);
function READGLaN(no:string):BOOLEAN;
public
{ Public declarations }
end;
var
FmYdPosBill: TFmYdPosBill;
function ShowYDPosSendbill(sBillId: string; EditMode: string; iBillType: Integer): Integer;
implementation
uses Unt_PubStrGrid, func, UDLGYDPOS, untdatadm, UntSQpspart,
Storage_Select, Login_Man;
{$R *.dfm}
//////////////////////////
function ShowYDPosSendbill(sBillId: string; EditMode: string; iBillType: Integer): Integer;
begin
Result := 1;
FmYdPosBill := TFmYdPosBill.Create(application);
FmYdPosBill.sBillId := sBillId;
FmYdPosBill.SEditMode := UpperCase(EditMode);
FmYdPosBill.SendMaster.iBIlltype := iBillType;
try
FmYdPosBill.FormIni;
FmYdPosBill.ShowModal;
finally
FmYdPosBill.Free;
end;
end;
function TFmYdPosBill.READGlaN(NO:string):BOOLEAN;
var
iRow:integer;
CDS:TCLIENTDATASET ;
sql:widestring;
BEGIN
result:=false;
sql:=' select b.*,c.type,c.goods_name,c.stock_amount from GetGoodsPlanmaster as a, GetGoodsPlan as b,vselectgoods as c where b.vcptyieid=c.goods_no and a.vcstockid=c.storage_no and a.VcGetGoodsPlanID=b.VcGetGoodsPlanID and b.IGetStatus=1 and b.VcGetGoodsPlanID='+''''+trim(no)+'''';
cds:=TCLIENTDATASET.Create(self);
cds.Close;
cds.Data:=null;
TRY
cds.Data:=adisp.execSql(sql);
CDS.Open;
if cds.IsEmpty then
begin
application.MessageBox(pchar('预定商品还没有采购或入库,请入库后进行[预定配送]!'),pchar(application.Title),mb_iconinformation);
cds.Close;
cds.Data:=null;
cds.Free;
cds:=nil;
exit;
end;
sgorder.RowCount:=cds.RecordCount+1;
for iRow := 1 to cds.RecordCount do
begin
//
sgorder.Cells[0, iRow] := IntToStr(Irow);
sgorder.Cells[1, iRow]:= trim(cds.fieldbyname('type').AsString);
sgorder.Cells[2, iRow]:=trim(cds.fieldbyname('VCPtyieID').AsString);//编码
sgorder.Cells[3, iRow]:=trim(cds.fieldbyname('goods_name').AsString);
sgorder.Cells[6,iRow] := trim(cds.Fieldbyname('vcGoodUnitId').AsString);
sgorder.Cells[7,iRow] := trim(cds.Fieldbyname('NQty').AsString); //申请数量
sgorder.Cells[17,iRow] := trim(cds.Fieldbyname('Goodsmemo').AsString);
sgorder.Cells[8,iRow] := '0';
sgorder.Cells[9,iRow] := '0';
sgorder.Cells[19,irow ] := '0000100001';
sgorder.Cells[16,irow ] := '10';
sgorder.Cells[11,iRow ] := '10';
sgorder.Cells[21,iRow] := trim(cds.Fieldbyname('stock_amount').AsString);
cds.Next;
end;
result:=true;
cds.Close;
cds.Data:=null;
cds.Free;
cds:=nil;
EXCEPT
cds.Close;
cds.Data:=null;
cds.Free;
cds:=nil;
END;
END;
procedure TFmYdPosBill.FormIni;
var
iRow: Integer;
temp,make:string;
begin
EdtSendStock.Text := '';
EdtRecvStock.Text := '';
EdtM.Text := trim(Handle_Man);
EdtG.Text := '';
EdtC.Text := '';
EdtMemo.Text := '';
ckid:=shopid ;
if sbillid='' then
begin
temp:='select max(right(billno,4)) from SendMasterTable where dtDrawDate='+''''+formatdatetime('yyyy''-''mm''-''dd',date)+'''';
make:='PS-'+trim(Handle_Part)+trim(handle_no); //编码中部门编号
edtbillno.Text:=setcode(temp,make);
sgorder.RowCount := 2;
for iRow := 1 to sgorder.RowCount do
sgorder.Rows[irow].Clear;
sgorder.Cells[0, iRow] := IntToStr(iRow);
end else
begin
ReadBill;
end;
InitialStrGrid(sgorder,'预定商品配送单');
CdsMasterData.Close;
CdsMasterData.Data :=null;
temp:= 'Select * from SendMasterTable where 1=2';
CdsMasterData.Data:=adisp.PubBatch(temp);
CdsMasterData.Open;
temp:='Select * from SendDetailTable where 1=2';
CdsDetailData.Close;
CdsDetailData.Data:=null;
CdsDetailData.Data:=adisp.PubBatch(temp);
CdsDetailData.Open;
end;
function tFmYdPosBill.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 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 sgorder.Cells[7, iRow]>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';
sgorder.Cells[9, iRow] := FloatToStr(StrToFloat(sgorder.Cells[7, iRow]) * StrToFloat(Trim(sgorder.Cells[8, iRow])));
end;
Result := True;
end;
function TFmYdPosBill.SaveData: Boolean;
var
IRow: Integer;
fQty, fPrice, fTotal, dRate: Double;
PsRst, iunit,i: Integer;
iEditMode: Integer;
mdata,Ddata:olevariant;//主副表数据
temp:widestring;
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;
SendMaster.BillStatus:=5;
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 := trim(OrderNO);
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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -