📄 sfc_backflushoutin_b.pas
字号:
begin
inherited;
//
end;
procedure TFrm_Sfc_BackFlushOutIn_B.cmbbx_WhCodeChange(Sender: TObject);
begin
inherited;
initcmbbx_WhPositionCode(getCode(cmbbx_WhCode.text));
end;
procedure TFrm_Sfc_BackFlushOutIn_B.FormActivate(Sender: TObject);
begin
if IsAfterprint=False then
begin
inherited;
//初始化仓库
initUsablewhcmbx(AdoQry_tmp,userCode,cmbbx_WhCode,False);
ToolButton4.left:=TlBtn_Print.Left+ToolButton4.Width;
end;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.cmbbx_WhCodeExit(Sender: TObject);
var
tmp_WhCode,tmp_WhPositionCode:string;
begin
inherited;
if Isinsert then exit; //由于在插入记录时基类会触发本onEXIT事件,为了避免这一件事件执行,所以加入本变量控制
initcmbbx_WhPositionCode(getCode(cmbbx_WhCode.text));
if AdoQry_Head.fieldbyname('moSpecial').asinteger=1 then
begin
tmp_WhCode:=getCode(cmbbx_WhCode.text);
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select WhPositionCode,WhPositionName '+
' from WhPosition '+
' where whCode='''+tmp_WhCode+''' and WhPositionType=2');
open;
tmp_WhPositionCode:=fieldbyname('WhPositionCode').asstring;
end;
end;
//if not Changed then exit;
InitCmBxText(cmbbx_WhPositionCode,tmp_WhPositionCode);
InitCmbbx_WhEmployee(getCode(cmbbx_WhCode.text));
if Trim(cmbbx_WhPositionCode.text)<>'' then
cmbbx_WhPositionCode.OnExit(sender);
end;
procedure TFrm_Sfc_BackFlushOutIn_B.SaveData;
var
M:integer;
tmp_qty:real;
save_ItemListid,Billno,Billid,Billid1:string;
saveplace:tBookmArk;
begin
// inherited; 不能放开这个INHERITED
AdoQry_Body.DisableControls;
saveplace:=AdoQry_Body.GetBookmArk;
with AdoQry_Body do
begin
First;
for M:=0 to recordCount-1 do
begin
tmp_qty:=tmp_qty+fieldbyname('moRequestqty').asfloat;
next;
end;
if tmp_qty=0.0 then
begin
gotoBookmArk(saveplace);
freeBookmArk(saveplace);
enablecontrols;
DispInfo('请领数量都为零,不允许保存!',1);
abort;
end;
end;
AdoQry_Body.First;
for M:=0 to AdoQry_Body.recordCount-1 do
begin
if AdoQry_Body.fieldbyname('moRequestqty').asstring<>'0' then
begin
if not InvQtyCheck
(False,
AdoQry_Body,
AdoQry_tmp,
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('ItemCode').asstring,
'moRequestqty',
AdoQry_Body.fieldbyname('moRequestqty').asfloat,
False) then
begin
AdoQry_Body.gotoBookmArk(saveplace);
AdoQry_Body.freeBookmArk(saveplace);
AdoQry_Body.enablecontrols;
abort;
end;
if AdoQry_Body.fieldbyname('Batchno').asstring<>'' then
begin
if not BatchInvCheck(AdoQry_tmp,
AdoQry_Body.fieldbyname('Batchno').asstring,
'C',
getCode(cmbbx_WhCode.text),
getCode(cmbbx_WhPositionCode.text),
AdoQry_Body.fieldbyname('moRequestqty').asfloat) then
begin
AdoQry_Body.gotoBookmArk(saveplace);
AdoQry_Body.freeBookmArk(saveplace);
AdoQry_Body.enablecontrols;
abort;
end;
end;
end;
AdoQry_Body.next;
end;
AdoQry_Body.Connection.beginTrans;
try
//生产单据号
Billno:=getno(AdoQry_Body.Connection,getCode(cmbbx_WhCode.text)+'C'+copy(medt_Date.text,3,2)+copy(medt_Date.text,6,2),'InvBill');
//增加InvOutBill
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add(
'insert InvOutBill'+
'(InvBillno,'+
'whCode,'+
'InvBilldate,'+
'InvBillMonth,'+
'DeptCode,'+
'mono,'+
'MoLineno,'+
'BillTypeCode,'+
'EmployeeCode,'+
'Sfc_EmployeeCode,'+
'WhPositionCode,'+
'OverPlan,'+
'shiftType,'+
'InvBillremArk)'+
'Values('''+Billno+''','+
''''+getCode(cmbbx_WhCode.text)+''','+
''''+medt_Date.text+''','+
''''+copy(medt_Date.text,1,7)+''','+
''''+getCode(lbl_Dept.Caption)+''','+
''''+lbl_Mono.Caption+''','+
lbl_MoLineno.Caption+','+
''''+BillTypeCode+''','+
''''+userCode+''','+
''''+userCode+''','+
''''+getCode(cmbbx_WhPositionCode.text)+''','+
'1,'+
''''+cmbbx_Shift.text+''','+
''''+Extedt_memo.text+''')');
AdoQry_tmp.execsql;
//取InvBillID
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add(' select @@IDENTITY as Billid ');
AdoQry_tmp.open;
Billid:=AdoQry_tmp.fieldbyname('Billid').asstring;
with AdoQry_Body do
begin
First;
for M:=0 to recordCount-1 do
begin
if (fieldbyname('moCtrlqty').asstring='') and
(fieldbyname('moRequestqty').asfloat<>0) then
begin
AdoQry_tmp.Close;
AdoQry_tmp.SQL.clear;
AdoQry_tmp.SQL.text:=
' if not exists (select ItemCode from '+
'mnItemList where '+
' mono='''+lbl_Mono.Caption+''' and '+
' MoLineno='+lbl_MoLineno.Caption+' and '+
' ite_ItemCode='' '' and '+
' ItemCode='''+fieldbyname('ItemCode').asstring+''') '+
' insert mnItemList '+
' (mono,'+
' MoLineno,'+
' ItemCode,'+
' ite_ItemCode,'+
' moRequestqty) '+
' Values('''+lbl_Mono.Caption+''','+
lbl_MoLineno.Caption+','+
''''+fieldbyname('ItemCode').asstring+''','+
''''+getCode(lbl_Item.Caption)+''','+
'0) ';
AdoQry_tmp.ExecSQL;
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add(' select @@IDENTITY as Billid ');
AdoQry_tmp.open;
Billid1:=AdoQry_tmp.fieldbyname('Billid').asstring;
end;
//增加表InvOutBillLINE
if (fieldbyname('moRequestqty').asstring='0') or
(fieldbyname('moRequestqty').asstring='') then
begin
end
else
begin
if (fieldbyname('moRequestqty').asfloat<>0) then
begin
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
if fieldbyname('ItemListid').asstring<>'' then
AdoQry_tmp.sql.Add(
'insert InvOutBillline'+
'(InvBillid,'+
'InvBilllineno,'+
'mono,'+
'MoLineno,'+
'ItemCode,'+
'ite_ItemCode,'+
'BilllineremArk,'+
'Batchno,'+
'InvBillSfcqty,'+
'alterNative,'+
'ItemListid,'+
'Parentid)'+
'Values('+Billid+','+
''''+inttostr(M+1)+''','+
''''+lbl_Mono.Caption+''','+
fieldbyname('MoLineno').asstring+','+
''''+fieldbyname('ItemCode').asstring+''','+
''''+fieldbyname('ite_ItemCode').asstring+''','+
''''+fieldbyname('BilllineremArk').asstring+''','+
''''+fieldbyname('Batchno').asstring+''','+
fieldbyname('moRequestqty').asstring+','+
fieldbyname('alterNative').asstring+','+
fieldbyname('ItemListid').asstring+','+
fieldbyname('Parentid').asstring+')')
else
AdoQry_tmp.sql.Add(
'insert InvOutBillline'+
'(InvBillid,'+
'InvBilllineno,'+
'mono,'+
'MoLineno,'+
'ItemCode,'+
'ite_ItemCode,'+
'BilllineremArk,'+
'Batchno,'+
'InvBillSfcqty,'+
'alterNative,'+
'ItemListid,'+
'Parentid)'+
'Values('+Billid+','+
''''+inttostr(M+1)+''','+
''''+lbl_Mono.Caption+''','+
fieldbyname('MoLineno').asstring+','+
''''+fieldbyname('ItemCode').asstring+''','+
''''+fieldbyname('ite_ItemCode').asstring+''','+
''''+fieldbyname('BilllineremArk').asstring+''','+
''''+fieldbyname('Batchno').asstring+''','+
fieldbyname('moRequestqty').asstring+','+
'0,'+
Billid1+','+
'0)');
AdoQry_tmp.ExecSQL;
end;
end;
next;
end;
end;
AdoQry_Body.GotoBookmArk(saveplace);
AdoQry_Body.freeBookmArk(saveplace);
AdoQry_Body.EnableControls;
AdoQry_Body.Connection.CommitTrans;
Extedt_Billno.text:=Billno;
except
begin
AdoQry_Body.Connection.RollBackTrans;
DispInfo(' 存盘不成功,请稍后再试! ',1);
end;
end;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.Act_NewExecute(Sender: TObject);
begin
Extedt_Billno.text:='';
IsAfterprint:=False;
inherited;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.Act_InsertLineExecute(
Sender: TObject);
begin
Isinsert:=True; //由于在插入记录时基类会触发本onEXIT事件,为了避免这一件事件执行,所以加入本变量控制
Frm_Entry_Detail.SetFormParam(Lbl_MoNo.Caption,Lbl_MoLineNo.Caption,getCode(cmbbx_WhCode.text),getCode(cmbbx_WhPositionCode.text),medt_Date.text,'');
inherited;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.Act_ModifyExecute(Sender: TObject);
begin
Frm_Entry_Detail.SetFormParam(Lbl_MoNo.Caption,Lbl_MoLineNo.Caption,getCode(cmbbx_WhCode.text),getCode(cmbbx_WhPositionCode.text),'','');
inherited;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.Act_DeleteLineExecute(
Sender: TObject);
begin
if AdoQry_Body.fieldbyname('moCtrlqty').asfloat=0.0 then
inherited
else
DispInfo('领料清单中存在的记录不允许删除!',1);
end;
procedure TFrm_Sfc_BackFlushOutIn_B.AdoQry_BodyAfterPost(
DataSet: TDataSet);
begin
inherited;
IOType:=AdoQry_Body.fieldbyname('moRequestqty').asfloat;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.AdoQry_BodyBeforePost(
DataSet: TDataSet);
begin
inherited;
// checkIOType;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.DateCheck(Sender: TObject);
begin
inherited;
if not WHClsPeriodCheck(AdoQry_tmp,getCode(cmbbx_WhCode.text),copy(medt_Date.text,1,7)) then
begin
twincontrol(sender).setfocus;
abort;
end;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.cmbbx_WhPositionCodeExit(
Sender: TObject);
begin
inherited;
if Isinsert then exit; //由于在插入记录时基类会触发本onEXIT事件,为了避免这一件事件执行,所以加入本变量控制
if (cmbbx_WhPositionCode.text<>'') and (cmbbx_WhPositionCode.text<>oldWhPosition) then
begin
showdbgrid;
end ;
oldWhPosition:=cmbbx_WhPositionCode.text;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.CheckBox2Click(Sender: TObject);
begin
inherited;
showdbgrid;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.CheckBox1Click(Sender: TObject);
begin
inherited;
showdbgrid;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.cmbbx_WhEmployeeExit(
Sender: TObject);
begin
inherited;
if Isinsert then exit; //由于在插入记录时基类会触发本onEXIT事件,为了避免这一件事件执行,所以加入本变量控制
showdbgrid;
end;
procedure TFrm_Sfc_BackFlushOutIn_B.initprint;
begin
Frm_Sfc_MnOut_NotSave_P.QLWHCode.Caption:=cmbbx_WhCode.text;
Frm_Sfc_MnOut_NotSave_P.QLWhPositionCode.Caption:=cmbbx_WhPositionCode.text;
Frm_Sfc_MnOut_NotSave_P.qlWhEmployee.Caption:=cmbbx_WhEmployee.text;
Frm_Sfc_MnOut_NotSave_P.QLInvBillNo.Caption:=Extedt_Billno.text;
Frm_Sfc_MnOut_NotSave_P.QLDeptCode.Caption:=lbl_Dept.Caption;
Frm_Sfc_MnOut_NotSave_P.QLshifttime.Caption:=cmbbx_Shift.text;
Frm_Sfc_MnOut_NotSave_P.QLInvBillDate.Caption:=medt_Date.text;
Frm_Sfc_MnOut_NotSave_P.QLMONo.Caption:=lbl_Mono.Caption;
Frm_Sfc_MnOut_NotSave_P.QLMoLineNo.Caption:=lbl_MoLineno.Caption;
Frm_Sfc_MnOut_NotSave_P.qlItemCodeName.Caption:=lbl_Item.Caption;
Frm_Sfc_MnOut_NotSave_P.QLWH_EmployeeCodea.Caption:='';
Frm_Sfc_MnOut_NotSave_P.QLWH_EmployeeCode.Caption:='';
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select EmployeeCode,EmployeeName from Employee where EmployeeCode='''+userCode+'''');
open;
end;
Frm_Sfc_MnOut_NotSave_P.QLEmployeeCodeA.Caption:=AdoQry_tmp.fieldbyname('EmployeeCode').asstring+' '+AdoQry_tmp.fieldbyname('EmployeeName').asstring;
Frm_Sfc_MnOut_NotSave_P.QLEmployeeCode.Caption:=AdoQry_tmp.fieldbyname('EmployeeCode').asstring+' '+AdoQry_tmp.fieldbyname('EmployeeName').asstring;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select moqty from MoLine where mono='''+lbl_Mono.Caption+''' and MoLineno='+lbl_MoLineno.Caption);
open;
end;
Frm_Sfc_MnOut_NotSave_P.qlmoqty.Caption:=AdoQry_tmp.fieldbyname('moqty').asstring;
Frm_Sfc_MnOut_NotSave_P.QuickRep1.DataSet:=AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataSet :=AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataField :='ItemCode';
Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataSet := AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataField :='ItemCode2';
Frm_Sfc_MnOut_NotSave_P.QRExpr2.Expression:='COPY(AdoQry_Body.ItemName,1,44)';
Frm_Sfc_MnOut_NotSave_P.QRExpr3.Expression :='COPY(AdoQry_Body.ItemName,45,16)';
Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataSet :=AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataField :='UomName';
Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataSet :=AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataField :='moRequestqty';
Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataSet :=AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataField:='BFRealQty';
// Frm_Sfc_MnOut_NotSave_P.QRDBText3.DataSet :=AdoQry_Body;
// Frm_Sfc_MnOut_NotSave_P.QRDBText3.DataField:='BilllineremArk';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -