📄 inv_mnlistaudit_b.pas
字号:
unit Inv_MnListAudit_B;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Body, Db, DBCtrls, StdCtrls, ActnList, AdODB, Grids, DBGridEh,
ExtCtrls, ComCtrls, ToolWin, ExtPrintReport, ExtEdit, Mask,dbgrids, jpeg;
Type
TFrm_Inv_MnListAudit_B = Class(TFrm_Base_Entry_Body)
Label3: TLabel;
Label5: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
lbl_Dept: TLabel;
lbl_Mono: TLabel;
lbl_MoLineno: TLabel;
lbl_Item: TLabel;
cmbbx_Shift: TComboBox;
Label1: TLabel;
DBText1: TDBText;
Label2: TLabel;
DBText2: TDBText;
Label4: TLabel;
edt_No: TEdit;
Label6: TLabel;
medt_Date: TMaskEdit;
AdoQry_tmp2: TAdoQuery;
Label7: TLabel;
Label8: TLabel;
cmbx_WhCode: TComboBox;
cmbx_WhPosition: TComboBox;
Rbtn_ShowWhCode: TRadioButton;
Rbtn_Showall: TRadioButton;
Label12: TLabel;
cmbx_Employee: TComboBox;
procedure Act_PreviewExecute(Sender: TObject);
procedure Act_PrintExecute(Sender:TObject);
procedure medt_DateChange(Sender: TObject);
procedure DBGridEhGetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
procedure DBGridEh1GetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
procedure Act_ModifyExecute(Sender: TObject);
procedure Act_InsertLineExecute(Sender: TObject);
procedure DBGridEhDblClick(Sender: TObject);
procedure cmbbx_ShiftChange(Sender: TObject);
procedure Act_DeleteLineExecute(Sender: TObject);
procedure cmbx_WhCodeChange(Sender: TObject);
procedure cmbx_WhPositionChange(Sender: TObject);
procedure ckbx_ShowallClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Rbtn_ShowallClick(Sender: TObject);
procedure Rbtn_ShowWhCodeClick(Sender: TObject);
procedure Rbtn_ShowWhCodeMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Rbtn_ShowallMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure DBGridEhEnter(Sender: TObject);
procedure Act_SaveExecute(Sender: TObject);
procedure Act_NewExecute(Sender: TObject);
procedure DBGridEhColExit(Sender: TObject);
procedure AdoQry_BodyAfterPost(DataSet: TDataSet);
procedure cmbx_EmployeeChange(Sender: TObject);
private
IOType,oldmoRequestlineqty,oldswApmoRequestqty,oldbodymoRequestqty:real;
swApflag,MoLinestatus,PriceType:integer;
bodyItemListid,BillTypeCode,Billid,oldwhCode,oldWhPosition,oldEmployee:string;
IsAfterprint,IScheck,clickpreview:boolean;
// Param2:string;
procedure showdbgrid(s:string;whCode:string;WhPosition:string);
{ Private declarations }
public
tmp_Status:string;
ClassType1:string;
procedure SetStatus(CurrentStatus:String;var AnswerStatus,EnableControls:String); Override;//设置各种状态下那些控件Enable
procedure InitControls; Override;//初始化Form上所有控件
procedure SaveData; Override;
{ Public declarations }
end;
var
Frm_Inv_MnListAudit_B: TFrm_Inv_MnListAudit_B;
implementation
uses Sys_Global, Inv_MnListAudit_H,Inv_Global,Inv_MnListAudit_D;
{$R *.DFM}
procedure TFrm_Inv_MnListAudit_B.Showdbgrid(s:string;whCode:string;WhPosition:string);
var
sql_text,con_Sql,con_Sql2,tmp_WhEmployee,tmp_DeptCode,tmpfields,tmp_WhCode,tmp_WhPosition:string;
cursor:tcursor;
begin
cursor:=Screen.Cursor ;
Screen.Cursor :=crHourGlass;
tmp_WhCode:=whCode;
tmp_WhPosition:=WhPosition;
try
with AdoQry_tmp do
begin
Close;
sql.text:='drop table #tmPmoRequest,#TmPmORequest2';
execsql;
end;
except
end;
if (rbtn_Showall.Checked) then
con_Sql2:=' and 1=1 '
else
if cmbx_Employee.Text='' then
con_Sql2:=' and (i.whCode='''+tmp_WhCode+''' or (m.alterNative=1 and m.Parentid=0) '+
' or m.alterNative=2 or c.onhandInv>0) '
else
con_Sql2:=' and (i.whCode='''+tmp_WhCode+''' or (m.alterNative=1 and m.Parentid=0) '+
' or m.alterNative=2 or c.onhandInv>0) and i.wh_EmployeeCode='+
QuotedStr(getCode(cmbx_Employee.Text));
if s='' then
con_Sql:=' (m.shiftType is null or m.shiftType='''') and '
else
con_Sql:=' m.shiftType='''+s+''' and ';
if tmp_WhCode='' then
con_Sql:=con_Sql+' and 1=1 and '
else
con_Sql:=con_Sql+' and 1=1 and ';
sql_text:=
'set noCount on '+
'select c.whCode,c.onhandInv,m.ItemCode,m.ite_ItemCode,m.BilllineremArk,'+
'm.moCtrlqty,m.MoRealqty,m.mono,m.MoLineno,m.Bomqty,m.BomScrAp_Percent,'+
'm.alterNative,m.Parentid,m.ItemListid,m.Parentid Parentid2 '+
'into #TmPmORequest '+
'from mnItemList m '+
' left join CurrentInv C on m.ItemCode=C.ItemCode and c.whCode='''+tmp_WhCode+''' and c.WhPositionCode='''+tmp_WhPosition+''' '+
' left join Item i on m.ItemCode=i.ItemCode '+
'where m.mono='''+lbl_Mono.Caption+''' '+
con_Sql2+
' and m.MoLineno='+lbl_MoLineno.Caption+' '+
//使父项与子项放在一起
'update #TmPmORequest '+
'set Parentid=ItemListid '+
'where ItemListid in (select Parentid from #TmPmORequest) '+
//产生显示的结果集
'select t.ItemCode+'' ''+i.ItemName ItemDESC,i.limitout,t.ItemCode,t.ite_ItemCode,t.whCode,t.onhandInv,'+
' t.BilllineremArk,u.UomName,i.ItemCode2,t.Parentid,t.ItemListid,t.alterNative,'+
' t.moCtrlqty,t.MoRealqty,t.Parentid2,m.ShiftType,t.mono,t.MoLineno,t.Bomqty,t.BomScrAp_Percent, '+
' m.tmpRealOutQty,m.tmpBatchno,'+
' m.whCode1,m.WhPositionCode1,m.Requestqty1,m.realoutqty1,Batchno1,m.Requesttime1, '+
' m.whCode2,m.WhPositionCode2,m.Requestqty2,m.realoutqty2,Batchno2,m.Requesttime2,m.tmpflag, '+
' m.whCode3,m.WhPositionCode3,m.realoutqty3,Batchno3,m.Requesttime3, '+
' m.whCode4,m.WhPositionCode4,m.realoutqty4,Batchno4,m.Requesttime4, '+
' m.whCode5,m.WhPositionCode5,m.realoutqty5,Batchno5,m.Requesttime5, '+
' m.whCode6,m.WhPositionCode6,m.realoutqty6,Batchno6,m.Requesttime6, '+
' m.whCode7,m.WhPositionCode7,m.realoutqty7,Batchno7,m.Requesttime7, '+
' m.whCode8,m.WhPositionCode8,m.realoutqty8,Batchno8,m.Requesttime8, '+
' m.whCode9,m.WhPositionCode9,m.realoutqty9,Batchno9,m.Requesttime9, '+
' m.whCode10,m.WhPositionCode10,m.realoutqty10,Batchno10,m.Requesttime10 '+
'into #TmPmORequest2 '+
'from #TmPmORequest t '+
' left join '+
' (select ItemListid,ShiftType,m.tmpflag,tmpRealOutQty,tmpBatchno, '+
' m.whCode1+'' ''+w1.whName whCode1,rTrim(m.WhPositionCode1)+'' ''+wp1.WhPositionName WhPositionCode1,m.Requestqty1,m.realoutqty1,Batchno1,m.Requesttime1, '+
' m.whCode2+'' ''+w2.whName whCode2,rTrim(m.WhPositionCode2)+'' ''+wp2.WhPositionName WhPositionCode2,m.Requestqty2,m.realoutqty2,Batchno2,m.Requesttime2, '+
' m.whCode3+'' ''+w3.whName whCode3,rTrim(m.WhPositionCode3)+'' ''+wp3.WhPositionName WhPositionCode3,m.Requestqty3,m.realoutqty3,Batchno3,m.Requesttime3, '+
' m.whCode4+'' ''+w4.whName whCode4,rTrim(m.WhPositionCode4)+'' ''+wp4.WhPositionName WhPositionCode4,m.realoutqty4,Batchno4,m.Requesttime4, '+
' m.whCode5+'' ''+w5.whName whCode5,rTrim(m.WhPositionCode5)+'' ''+wp5.WhPositionName WhPositionCode5,m.realoutqty5,Batchno5,m.Requesttime5, '+
' m.whCode6+'' ''+w6.whName whCode6,rTrim(m.WhPositionCode6)+'' ''+wp6.WhPositionName WhPositionCode6,m.realoutqty6,Batchno6,m.Requesttime6, '+
' m.whCode7+'' ''+w7.whName whCode7,rTrim(m.WhPositionCode7)+'' ''+wp7.WhPositionName WhPositionCode7,m.realoutqty7,Batchno7,m.Requesttime7, '+
' m.whCode8+'' ''+w8.whName whCode8,rTrim(m.WhPositionCode8)+'' ''+wp8.WhPositionName WhPositionCode8,m.realoutqty8,Batchno8,m.Requesttime8, '+
' m.whCode9+'' ''+w9.whName whCode9,rTrim(m.WhPositionCode9)+'' ''+wp9.WhPositionName WhPositionCode9,m.realoutqty9,Batchno9,m.Requesttime9, '+
' m.whCode10+'' ''+w10.whName whCode10,rTrim(m.WhPositionCode10)+'' ''+wp10.WhPositionName WhPositionCode10,m.realoutqty10,Batchno10,m.Requesttime10 '+
' from MNListRequest m '+
' left join Warehouse w1 '+
' on w1.whCode=m.whCode1 '+
' left join WhPosition wp1 '+
' on wp1.whCode=m.whCode1 and '+
' wp1.WhPositionCode=m.WhPositionCode1 '+
' left join Warehouse w2 '+
' on w2.whCode=m.whCode2 '+
' left join WhPosition wp2 '+
' on wp2.whCode=m.whCode2 and '+
' wp2.WhPositionCode=m.WhPositionCode2 '+
' left join Warehouse w4 '+
' on w4.whCode=m.whCode4 '+
' left join WhPosition wp4 '+
' on wp4.whCode=m.whCode4 and '+
' wp4.WhPositionCode=m.WhPositionCode4 '+
' left join Warehouse w5 '+
' on w5.whCode=m.whCode5 '+
' left join WhPosition wp5 '+
' on wp5.whCode=m.whCode5 and '+
' wp5.WhPositionCode=m.WhPositionCode5 '+
' left join Warehouse w6 '+
' on w6.whCode=m.whCode6 '+
' left join WhPosition wp6 '+
' on wp6.whCode=m.whCode6 and '+
' wp6.WhPositionCode=m.WhPositionCode6 '+
' left join Warehouse w7 '+
' on w7.whCode=m.whCode7 '+
' left join WhPosition wp7 '+
' on wp7.whCode=m.whCode7 and '+
' wp7.WhPositionCode=m.WhPositionCode7 '+
' left join Warehouse w8 '+
' on w8.whCode=m.whCode8 '+
' left join WhPosition wp8 '+
' on wp8.whCode=m.whCode8 and '+
' wp8.WhPositionCode=m.WhPositionCode8 '+
' left join Warehouse w9 '+
' on w9.whCode=m.whCode9 '+
' left join WhPosition wp9 '+
' on wp9.whCode=m.whCode9 and '+
' wp9.WhPositionCode=m.WhPositionCode9 '+
' left join Warehouse w10 '+
' on w10.whCode=m.whCode10 '+
' left join WhPosition wp10 '+
' on wp10.whCode=m.whCode10 and '+
' wp10.WhPositionCode=m.WhPositionCode10 '+
' left join Warehouse w3 '+
' on w3.whCode=m.whCode3 '+
' left join WhPosition wp3 '+
' on wp3.whCode=m.whCode3 and '+
' wp3.WhPositionCode=m.WhPositionCode3 ) m'+
' on m.ItemListid=t.ItemListid, '+
' Item i,Uom u '+
'where t.ItemCode=i.ItemCode and '+
' i.UomCode=u.UomCode '+
// con_Sql+
// '(m.Requestqty1<>0 or m.Requestqty2<>0 or m.Requestqty3<>0) and '+
// '(m.realoutqty1 is null or m.realoutqty1=0 or m.realoutqty2 is null or m.realoutqty2=0 or m.realoutqty3 is null or m.realoutqty3=0'+
// ' or m.realoutqty4 is null or m.realoutqty4=0 or m.realoutqty5 is null or m.realoutqty5=0 ) '+
'Order by t.Parentid,t.ItemListid '+
//处理虚项的子项缩进,注意可能有虚项嵌套的情况
//只考虑两两层嵌套的情况
'update #TmPmORequest2 '+
'set ItemDESC='' ''+ItemDESC '+
'where Parentid2 in '+
' (select ItemListid from #TmPmORequest) '+
'update #TmPmORequest2 '+
'set ItemDESC='' ''+ItemDESC '+
'where Parentid2 in '+
' (select ItemListid from #TmPmORequest where Parentid2<>0) ';
try
with AdoQry_Body do
begin
Close;
sql.clear;
sql.Add(sql_text);
execsql;
Close;
sql.text:='select * from #TmPmoRequest2 ';
open;
end;
ClassType1:=AdoQry_Body.fieldbyname('shiftType').asstring;
finally
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('drop table #TmPmORequest,#TmPmoRequest2');
execsql;
end;
end;
with dbgrideh do
begin
columns[7].Width:=64;
columns[8].Width:=64;
columns[11].Width:=64;
columns[12].Width:=64;
columns[15].Width:=64;
columns[16].Width:=64;
columns[19].Width:=64;
columns[20].Width:=64;
columns[23].Width:=64;
columns[24].Width:=64;
columns[27].Width:=64;
columns[28].Width:=64;
columns[31].Width:=64;
columns[32].Width:=64;
columns[35].Width:=64;
columns[36].Width:=64;
columns[39].Width:=64;
columns[40].Width:=64;
columns[43].Width:=64;
columns[44].Width:=64;
end;
Screen.Cursor :=cursor;
end;
procedure TFrm_Inv_MnListAudit_B.InitControls;
begin//初始化Form上的控件
inherited;
IScheck:=False;
// initUsablewhcmbx(AdoQry_tmp,userCode,cmbx_WhCode,False);
InitCmBx_Condition(AdoQry_tmp.Connection,cmbx_WhPosition,'WhPosition','WhPositionCode',
'WhPositionName','whCode='''+getCode(cmbx_WhCode.text)+''' and not (Backflushwhp=1 or WhPositionType=1)');
AdoQry_tmp2.Connection:=AdoQry_Body.Connection ;
BillTypeCode:=Param2;
lbl_Mono.Caption:=AdoQry_Head.fieldbyname('mono').asstring;
lbl_MoLineno.Caption:=AdoQry_Head.fieldbyname('MoLineno').asstring;
lbl_Item.Caption:=AdoQry_Head.fieldbyname('ItemCode').asstring+' '+Frm_Inv_MnListAudit_H.AdoQry_Head.fieldbyname('ItemName').asstring;
lbl_Dept.Caption:=Frm_Inv_MnListAudit_H.tmp_DeptCode;
MoLinestatus:=AdoQry_Head.fieldbyname('MoLinestatus').asinteger;
IOType:=0;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select PriceType from Warehouse where whCode='''+getCode(Frm_Inv_MnListAudit_H.tmp_WhCode)+'''');
open;
PriceType:=fieldbyname('PriceType').asinteger;
end;
// Act_insertline.visible:=True;
act_Modify.visible:=True;
// act_Deleteline.visible:=True;
// Act_insertline.Enabled :=False;
act_Modify.Enabled:=True;
// act_Deleteline.Enabled:=False;
if status='ReadOnly' then
begin
Act_insertline.Enabled :=False;
// act_Modify.Enabled:=False;
act_Deleteline.Enabled:=False;
end;
Act_insertline.Visible :=False;
act_Deleteline.Visible :=False;
medt_Date.Text :=datetostr(now);
InitShiftCmBx(AdoQry_tmp,cmbbx_Shift,True);
InitCmBxText(cmbbx_Shift,Frm_Inv_MnListAudit_H.tmp_MoRequestshift);
with AdoQry_tmp do
begin
Close;
sql.text:='select WhEmployee.EmployeeCode+'' ''+Employee.EmployeeName as EmployeeName '+
'from WhEmployee '+
'left join Employee on Employee.EmployeeCode=WhEmployee.EmployeeCode '+
'left join WHAccessCtrl on WHAccessCtrl.EmployeeCode=WhEmployee.EmployeeCode '+
'where WhEmployee.WhEmployeeUsable=1 and WHAccessCtrl.whCode='+
QuotedStr(getCode(cmbx_WhCode.Text));
open;
if not eof then
begin
cmbx_Employee.Items.clear;
cmbx_Employee.Items.Add('');
while not eof do
begin
cmbx_Employee.Items.Add(fieldbyname('EmployeeName').asstring);
next;
end;
cmbx_Employee.ItemIndex:=0;
end;
end;
showdbgrid(Frm_Inv_MnListAudit_H.tmp_MoRequestshift,getCode(cmbx_WhCode.text),getCode(cmbx_WhPosition.text));
end;
procedure TFrm_Inv_MnListAudit_B.SetStatus(CurrentStatus:String;var AnswerStatus,
EnableControls:String);
begin//指明当前状态,定义Enable=True的控件
inherited;
if CurrentStatus='Edit' then
begin
EnableControls:='cmbbx_Shift,cmbx_WhCode,cmbx_Employee,cmbx_WhPosition,Rbtn_Showall,Rbtn_ShowWhCode,';
end
else
EnableControls:='cmbbx_Shift,cmbx_WhCode,cmbx_Employee,cmbx_WhPosition,Rbtn_Showall,Rbtn_ShowWhCode,';
end;
procedure TFrm_Inv_MnListAudit_B.Act_PreviewExecute(Sender: TObject);
begin
if Trim(edt_No.text)<>'' then
begin
BillPrint(AdoQry_Tmp.Connection,getCode(cmbx_WhCode.text),edt_No.Text,Param2,ModuleCode,True,False,True,'');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -