📄 untposquestbillstr.pas
字号:
for IRow := 1 to sgorder.RowCount - 1 do
begin
Append;
FieldByName('vcSendBillId').AsString := SendMaster.vcSendBillId;
FieldByName('ord').asInteger := IRow;
FieldByName('InOrderId').asInteger := IRow;
FieldByName('vcPtypeid').AsString := Trim(sgorder.cells[2, iRow]);
FieldByName('VcSendStockID').AsString := Trim(SendMaster.vcSendStockID); //乏货单位
FieldByName('VcRecvStockID').AsString := Trim(SendMaster.vcRecvStockID); //收获
FieldByName('vcBatch').AsString := '';
FieldByName('vcGoodUnitId').AsString := Trim(sgorder.cells[6, iRow]);
//iunit := StrToInt(sgorder.Cells[20, iRow]);
dRate := StrToFloat(sgorder.Cells[16, iRow]);
iunit:=0;
if iunit = 1 then
begin
fQty := StrToFloat(Trim(sgorder.cells[7, iRow])) * dRate;
FieldByName('nuOutQuantity').asFloat := fQty;
fPrice := StrToFloat(Trim(sgorder.cells[8, iRow])) / dRate;
FieldByName('SendPrice').asFloat := fPrice;
end
else
begin
fQty := StrToFloat(Trim(sgorder.cells[7, iRow]));
FieldByName('nuOutQuantity').asFloat := fQty;
fPrice := StrToFloat(Trim(sgorder.cells[8, iRow]));
FieldByName('SendPrice').asFloat := fPrice;
end;
fTotal := fPrice * fQty;
FieldByName('SendTotal').asFloat := fTotal;
FieldByName('nuCess').asFloat := 0;
FieldByName('nuIncTaxPrice').asFloat := fPrice;
FieldByName('nuTax').asFloat := 0;
FieldByName('NTaxTotal').asFloat := fTotal;
FieldByName('nuCostPrice').asFloat := fPrice;
FieldByName('NCastTotal').asFloat := fTotal;
FieldByName('iUnit').asInteger := iunit;
FieldByName('NRate').asFloat := dRate;
end;
end;
PsRst := CdsDetailData.RecordCount;
//adisp.InsertSendBill(CdsMasterData.Data,CdsDetailData.Data,iEditMode,PsRst);
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:='从仓库'+edtSendshop.Text+'向仓库'+edtRecvStock.Text+'配送退货';
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('单据保存失败!');
ClearGrid;
Result := True;
except
on E: Exception do
begin
Application.MessageBox(Pchar(E.message), pchar(application.Title), MB_OK +MB_ICONinformation)
end;
end;
end;
procedure TFmPosQuestBillStr.BtnDelRowClick(Sender: TObject);
begin
if sgorder.RowCount = 2 then
begin
// sgorder.ClearRows(1, sgorder.ColCount);
Exit;
end;
if sgorder.Row = sgorder.RowCount - 1 then
begin
// sgorder.RemoveRows(sgorder.Row, 1);
sgorder.SetFocus;
Exit;
end;
// sgorder.RemoveRows(sgorder.Row, 1);
sgorder.SetFocus;
end;
procedure TFmPosQuestBillStr.BtnAddRowClick(Sender: TObject);
begin
// sgorder.AddRow;
end;
function TFmPosQuestBillStr.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, goods_code as c where a.vcSendBillId=b.vcSendBillId and b.vcPtypeid=c.goods_no and a.VCSENDBILLID='+''''+trim(sBillId)+'''';
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);
edtSendshop.Text:=trim(dmmain.CDSquery2.fieldbyname('vcSendStockID').AsString);
sendmaster.vcSendStockID:=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);
//------显示明细数据--------------//
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[11,iRow ] := '10';
dmmain.CDSquery2.Next;
end;
except
end;
Result := True;
except
Result := False;
end;
end;
procedure TFmPosQuestBillStr.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 TFmPosQuestBillStr.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_EsCaPE then
Close;
end;
procedure TFmPosQuestBillStr.sgorderSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
pcol:=acol;
prow:=arow;
end;
procedure TFmPosQuestBillStr.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;
if pcol = 7 then
begin
for i:=2 to sgorder.RowCount-1 do
begin
sgorder.Cells[7,i] := sgorder.cells[7,1];
SumCol(7,i);
end;
end;
if pcol = 8 then ///???//
begin
for i:=2 to sgorder.RowCount-1 do
begin
sgorder.Cells[8,i] := sgorder.cells[8,1];
SumCol(8,i);
end;
end;
///必须刷新,不然显示不对
sgorder.Refresh;
end;
procedure TFmPosQuestBillStr.FormShow(Sender: TObject);
var
t_sql:widestring;
begin
//edtSendShop.Text := shopid;
edtM.Text := trim(Handle_Man);
SendMaster.vcListerId := trim(Handle_Man); //制单人
//SendMaster.vcSendStockID := shopid;
SendMaster.VcSendStockName := shopid; //sStockName;
SendMaster.vcRecvStockID := shopid; //sStockID;
SendMaster.VcRecvStockName := shopid;//sStockName;
// SendMaster.vcAssessorId := cmbc.text;
sendmaster.vcRecvStockID := '0001';
end;
procedure TFmPosQuestBillStr.Cleargrid;
var
i,j:integer;
begin
///////////ydy add to clear the stringsgorder
with sgorder do
begin
for i:=1 to colCount do
for j:=1 to rowCount do
cells[i,j]:='';
end;
sgorder.RowCount := 2;
end;
procedure TFmPosQuestBillStr.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 TFmPosQuestBillStr.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];
key := #0;
end;
end;
procedure TFmPosQuestBillStr.sgorderMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
var
i:integer;
begin
for i:=1 to sgorder.RowCount-1 do
begin
SumCol(8,i);
end;
end;
procedure TFmPosQuestBillStr.bitcheckClick(Sender: TObject);
var
user,sql:widestring;
flag:olevariant;
begin
if trim(sBillId)=''then exit;
if trim(sgorder.Cells[1,1])='' then exit;
no:=trim(edtbillno.Text);
try
flag:=ipubtemp.batchstock(no,2); //配送入库;
sql:='update SendMasterTable set SendStatus=2 where billno='+''''+trim(no)+''''; //修改为收货完成状态;
adisp.updatesql(sql);
except
end;
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);
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 TFmPosQuestBillStr.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
action:=cafree;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -