📄 sy_ck_lmp_add.pas
字号:
' and a.CKJHDH =' + QuotedStr(qry_CKXZ.FieldByName('JHH').AsString) +
' and a.PPDM =' + QuotedStr(qry_CKXZ.FieldByName('PPDM').AsString) +
' order by b.PXM ';
end;
2: {无依据} {}
Exit;
end;
with qry_DWFP do
begin
Close;
SQL.Text := l_sql;
Open;
end;
SetRounding; {凑包凑版调用}
end;
{-------------------------------------------------------------------------------}
{取得凑整的规格}
procedure TFrm_SY_CK_LMP_Add.GetGG(A_PPDM: string);
var
l_sql: string;
begin
case rg_Type.ItemIndex of
0, 1: {普票、零枚} {}
l_sql := 'select a.BZLSH, A.BJC, sum(c.GBGTMS * e.GBGBBS) BZSL ' +
' from TB_BZSJB A, TB_YZPPTUXXB b,TB_BTGXB c, TB_BSJB d, TB_BBGXB e ' +
' where a.BZLSH = e.BZLSH and b.TUDM = c.TUDM and c.BLSH = d.BLSH and d.BLSH = e.BLSH ' +
' and (e.GBGBBS is not NULL) and c.TUDM= ' + QuotedStr(A_PPDM) +
' group by a.BZLSH, a.BJC order by a.BZLSH ';
2: {封片} {}
with qry_tmp do
begin
Close;
SQL.Text := 'select BZFS from TB_YZPPTXXB where TDM = ' + QuotedStr(A_PPDM);
Open;
if Fields[0].AsString = '1' then {按套包装}
l_sql := 'select a.BZLSH, A.BJC, a.ZXTS BZSL ' +
' from TB_BZSJB A where a.BZBBJ <>''2'' and a.TDM = ' + QuotedStr(A_PPDM) +
' order by a.BZLSH '
else
l_sql := 'select a.BZLSH, A.BJC, sum(c.GBGTMS * e.GBGBBS) BZSL ' +
' from TB_BZSJB A, TB_YZPPTUXXB b,TB_BTGXB c, TB_BSJB d, TB_BBGXB e ' +
' where a.BZLSH = e.BZLSH and b.TUDM = c.TUDM and c.BLSH = d.BLSH and d.BLSH = e.BLSH ' +
' and (e.GBGBBS is not NULL) and a.TDM = ' + QuotedStr(A_PPDM) +
' group by a.BZLSH, a.BJC order by a.BZLSH ';
Close;
end;
end;
{取得该票品的所有包装规格,资料包除外}
fcb_BZGG.ClearAll;
with qry_tmp do
begin
Close;
SQL.Text := l_sql;
Open;
while not eof do
begin
fcb_BZGG.Items.Add(FieldByName('BJC').AsString);
fcb_BZGG.FieldItems.Add(FieldByName('BZSL').AsString);
Next;
end;
if not IsEmpty then
fcb_BZGG.ItemIndex := 0;
Close;
end;
case rg_Type.ItemIndex of
0, 1: {普票、零枚} {}
l_sql := 'select b.GBGTMS from TB_YZPPTUXXB a,TB_BTGXB b where a.TUDM = b.TUDM ' +
' and a.TUDM= ' + QuotedStr(A_PPDM);
2: {封片} {}
l_sql := 'select b.GBGTMS from TB_YZPPTUXXB a,TB_BTGXB b where a.TUDM = b.TUDM ' +
' and substr(a.TUDM, 1, 11) = ' + QuotedStr(Copy(A_PPDM, 1, 11));
end;
{取得该票品的版的规格}
with qry_tmp do
begin
Close;
SQL.Text := l_sql;
Open;
VL_Ban_GG := Fields[0].AsInteger;
Close;
end;
end;
{-------------------------------------------------------------------------------}
{面值,售价,结算价以元显示}
procedure TFrm_SY_CK_LMP_Add.qry_PPMZGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
begin
if Trim(Sender.AsString) = '' then
Exit;
try
if Sender.AsInteger <> 0 then
Text := FormatFloat('¥#,##0.00', Sender.AsFloat / 100);
except
end;
end;
{-------------------------------------------------------------------------------}
{调用选择票品模块}
procedure TFrm_SY_CK_LMP_Add.bbtn_SearchClick(Sender: TObject);
var
l_ModalResult: Integer;
begin
rg_Type.OnClick := nil;
qry_PP.AfterScroll := nil;
with TFrm_SearchPP.Create(Application) do
try
Lios_Type := io_txp;
L_index := rg_Type.ItemIndex;
FB_ShowZero := false;
fcb_PPDLB.ItemIndex := rg_Type.ItemIndex;
fcb_PPDLBChange(nil); {刷新小类}
l_ModalResult := ShowModal;
if l_ModalResult = mrOK then
begin
VL_Type := fcb_PPDLB.ItemIndex;
with qry_PP do
begin
Close;
SQL.Text := GetSQL; {由选择票品模块生成的SQL语句}
Open;
end;
end;
finally
Free;
end;
qry_PP.AfterScroll := qry_PPAfterScroll;
rg_Type.ItemIndex := VL_Type;
rg_Type.OnClick := rg_TypeClick;
if l_ModalResult = mrOK then
GetGG(qry_PP.FieldByName('TUDM').AsString); {取得凑整的规格}
end;
{-------------------------------------------------------------------------------}
{上一步}
procedure TFrm_SY_CK_LMP_Add.bbtn_PriorClick(Sender: TObject);
begin
SetState(0);
end;
{-------------------------------------------------------------------------------}
{下一步}
procedure TFrm_SY_CK_LMP_Add.bbtn_NextClick(Sender: TObject);
begin
if qry_PP.IsEmpty then
begin
Application.MessageBox('必须存在一种票品,才能进行下一步的操作!', '提示', MB_OK + MB_IconInformation);
Exit;
end;
SetState(1); {界面刷新}
rg_CKXZClick(nil); {取分配计划或者分配单}
end;
{-------------------------------------------------------------------------------}
{完成新制定的计划分配单}
procedure TFrm_SY_CK_LMP_Add.bbtn_FinishClick(Sender: TObject);
begin
if qry_DWFP.IsEmpty then
begin
Application.MessageBox('必须根据一种票品的分配方案,才能进行完成分配单的制定!!', '提示', MB_OK + MB_IconInformation);
Exit;
end;
ModalResult := mrOK;
end;
{-------------------------------------------------------------------------------}
{按步处理的界面显示设置}
procedure TFrm_SY_CK_LMP_Add.SetState(A_Style: Integer);
begin
pgc_Select.ActivePageIndex := A_Style;
case a_Style of
0:
begin
bbtn_Search.Visible := True;
bbtn_Prior.Enabled := False;
bbtn_Next.Enabled := True;
bbtn_Finish.Visible := False;
end;
1:
begin
bbtn_Search.Visible := False;
bbtn_Prior.Enabled := True;
bbtn_Next.Enabled := False;
bbtn_Finish.Visible := True;
end;
end;
end;
{-------------------------------------------------------------------------------}
{凑包凑版调用}
procedure TFrm_SY_CK_LMP_Add.SetRounding;
var
l_Dest: Integer;
begin
l_Dest := 0;
case rg_Round.ItemIndex of
0: {凑包} {}
begin
if fcb_BZGG.Items.Count = 0 then
begin
Application.MessageBox('包装规格可能不完整,无法按包进行凑整!', '提示', MB_OK + MB_IconInformation);
rg_Round.ItemIndex := 2; {默认为不凑}
Exit;
end;
l_Dest := StrToInt(fcb_BZGG.FieldString);
end;
1: {凑版} {}
l_Dest := VL_Ban_GG;
2: {不用凑整数} {}
l_Dest := 0;
end;
SetRoundSL(rg_Round.ItemIndex, rg_Round_Style.ItemIndex, L_Dest); {分配数量的凑整处理}
end;
{-------------------------------------------------------------------------------}
{分配数量的凑整处理}
procedure TFrm_SY_CK_LMP_Add.SetRoundSL(A_Round, A_Round_Style, A_SingleDest: Integer);
{参数说明:凑包方式、凑整的方式(向上、向下)、凑整时的单包或者单版包装规格}
var
l_dbgPlace: TBookMark;
begin
{凑整}
with qry_DWFP do
begin
DisableControls;
First;
l_dbgPlace := GetBookMark;
while not Eof do
begin
Edit;
if A_Round = 2 then {不凑} {}
FieldByName('SL').AsInteger := FieldByName('SL_OLD').AsInteger
else
FieldByName('SL').AsInteger :=
GetRoundNumber(FieldByName('SL_OLD').AsInteger, A_SingleDest, A_Round_Style); {返回凑整后的数据}
Post;
Next;
end;
GotoBookMark(l_dbgPlace);
FreeBookMark(l_dbgPlace);
EnableControls;
end;
end;
{-------------------------------------------------------------------------------}
{返回凑整后的数据}
function TFrm_SY_CK_LMP_Add.GetRoundNumber(A_source, A_SingleDest, A_type: Integer): Integer;
var
l_Mod, l_Div: Integer;
begin
Result := 0;
if A_SingleDest <= 0 then {为0或者小于0时直接返回}
begin
Result := A_Source;
Exit;
end;
l_Mod := A_Source Mod A_SingleDest; {求余数,为0时整除}
if (l_Mod = 0) and (A_Source >= A_SingleDest) then {恰好为整包或整版}
begin
Result := A_Source;
Exit;
end;
l_Div := A_Source Div A_SingleDest; {}
case A_type of
0: {向上} {}
Result := (l_Div + 1) * A_SingleDest;
1: {向下} {}
begin
Result := (l_Div - 1) * A_SingleDest;
end;
end;
if Result < 0 then {向下取整时为负数时返回0}
Result := 0;
end;
procedure TFrm_SY_CK_LMP_Add.qry_PPJJGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
begin
if Trim(Sender.AsString) = '' then
Exit;
try
if Sender.AsInteger <> 0 then
Text := FormatFloat('¥#,##0.000', Sender.AsFloat / 100);
except
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -