📄 bas_item.pas
字号:
unit Bas_Item;
//物料主文件分属性维护主单元
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Outer, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, jpeg;
Type
TFrm_Bas_Item = Class(TFrm_Base_Outer)
Label1: TLabel;
edt_locate: TEdit;
cbx_Showall: TCheckBox;
tmp_grid: TDBGridEh;
chk_max: TCheckBox;
AdoQry_MainItemCode: TStringField;
AdoQry_MainItemName: TStringField;
AdoQry_MainItemshortName: TStringField;
AdoQry_MainUomCode: TStringField;
AdoQry_MainUomName: TStringField;
AdoQry_MainEmployeeCode: TStringField;
AdoQry_MainCaiGou: TStringField;
AdoQry_MainwhCode: TStringField;
AdoQry_MainwhName: TStringField;
AdoQry_MainPla_EmployeeCode: TStringField;
AdoQry_Mainwh_EmployeeCode: TStringField;
AdoQry_Mainwh_EmployeeName: TStringField;
AdoQry_MainJiHua: TStringField;
AdoQry_MainItemType: TIntegerField;
AdoQry_Maindesignno: TStringField;
AdoQry_MainItemUsable: TIntegerField;
AdoQry_Mainmaxqty: TFloatField;
AdoQry_Mainminqty: TFloatField;
AdoQry_Mainlimitout: TIntegerField;
AdoQry_Maingreateout: TIntegerField;
AdoQry_Mainpurchldtime: TFloatField;
AdoQry_Mainmnldtime: TFloatField;
AdoQry_MainPrepareLT: TIntegerField;
AdoQry_MainrunLT: TIntegerField;
AdoQry_MainQcLT: TIntegerField;
AdoQry_MainPmCode: TIntegerField;
AdoQry_MainPmBatch: TIntegerField;
AdoQry_Mainonlydefaultwh: TIntegerField;
AdoQry_MainBarCode: TStringField;
AdoQry_MainItemCode2: TStringField;
AdoQry_MaincanSale: TIntegerField;
AdoQry_MainremArk: TStringField;
AdoQry_MainItemcreatetime: TDateTimeField;
AdoQry_MainItemmodifytime: TDateTimeField;
AdoQry_MainItemdisabletime: TDateTimeField;
AdoQry_MainLongPurchLT: TIntegerField;
AdoQry_MainiScheck: TIntegerField;
AdoQry_MainCurrentOnHandInv: TFloatField;
AdoQry_MainCurrentOnCheckInv: TFloatField;
AdoQry_MainCurrentFreezeInv: TFloatField;
AdoQry_MainCurrentOnShipInv: TFloatField;
AdoQry_MainCurrentWasterInv: TFloatField;
AdoQry_MainClassCode: TStringField;
AdoQry_MainProductClass: TStringField;
AdoQry_MainQcClass: TStringField;
AdoQry_MainDeptCode: TStringField;
AdoQry_MainClassName: TStringField;
AdoQry_MainUomCodeName: TStringField;
AdoQry_MainCaiGouyuan: TStringField;
AdoQry_MainwhCodeName: TStringField;
AdoQry_MainJiHuayuan: TStringField;
AdoQry_MainDeptName: TStringField;
AdoQry_MainBatchstrat: TIntegerField;
AdoQry_MainBatchCtrl: TIntegerField;
AdoQry_MainCapacityhours: TFloatField;
AdoQry_MainItemClass1: TStringField;
AdoQry_MainItemClass2: TStringField;
AdoQry_MainItemClass3: TStringField;
AdoQry_MainItemClass4: TStringField;
AdoQry_MainItemClass5: TStringField;
AdoQry_MainopInv: TFloatField;
Label2: TLabel;
Label3: TLabel;
AdoQry_MainInspecTEmployeeCode: TStringField;
AdoQry_MainInspecTEmployeeName: TStringField;
procedure DBGridEhGetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
procedure Action3Execute(Sender: TObject);
procedure edt_locateChange(Sender: TObject);
procedure Act_LookExecute(Sender: TObject);
procedure cbx_ShowallClick(Sender: TObject);
procedure Act_FilterExecute(Sender: TObject);
procedure Act_LocateExecute(Sender: TObject);
procedure Act_NewExecute(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
sqltext,sqltext1:string;
procedure initdbgrdehcolumn;
{ Private declarations }
public
function SetDeleteSql:String;Override;
procedure initform(AdOConnection:TAdOConnection;ReadOnly:boolean);
procedure col_Adjust;
function judgeUseable:string;
{ Public declarations }
end;
var
Frm_Bas_Item: TFrm_Bas_Item;
implementation
uses Bas_Item_D,Sys_Global;
{$R *.DFM}
procedure TFrm_Bas_Item.initform(AdOConnection:TAdOConnection;ReadOnly:boolean);
var
i,j,k:integer;
begin//SQL初始化
Application.ProcessMessages;
inherited;
sqltext1:='select Item.ItemCode,Item.ItemName,Uom.UomName,Item.ItemType,'+
'Item.ItemUsable,Item.whCode,Item.wh_EmployeeCode,Item.Itemdisabletime '+
'from Item '+
'left join Uom on Item.UomCode=Uom.UomCode';
sqltext:='Select Item.ItemCode,'+
'Item.ItemName,'+
'Item.Material,'+
'Item.ItemshortName,'+
'Item.UomCode,'+
'Uom.UomName,'+
'Item.ClassCode,'+
'ItemClass.ClassName,'+
'Item.ProductClass,'+
'Item.QcClass,'+
'Item.UomCode+'+''' '''+'+Uom.UomName as UomCodeName,'+
'Item.EmployeeCode+'+''' '''+'+c.EmployeeName as CaiGouyuan, '+
'Item.whCode+'+''' '''+'+Warehouse.whName as whCodeName, '+
'Item.Pla_EmployeeCode+'+''' '''+'+j.EmployeeName as JiHuayuan,'+
'Item.EmployeeCode,'+
'c.EmployeeName as CaiGou,'+
'Item.whCode,'+
'Warehouse.whName,'+
'Item.Pla_EmployeeCode,'+
'j.EmployeeName as JiHua,'+
'Item.wh_EmployeeCode,'+
'k.EmployeeName as wh_EmployeeName,'+
'Item.ItemType,'+
'Item.designno,'+
'Item.ItemUsable,'+
'Item.maxqty,'+
'Item.minqty,'+
'Item.limitout,'+
'Item.LongPurchLT,'+
'Item.iScheck, '+
'Item.greateout,'+
'Item.purchldtime,'+
'Item.mnldtime,'+
'Item.PrepareLT,'+
'Item.runLT,'+
'Item.QcLT,'+
'Item.PmCode,'+
'Item.PmBatch,'+
'Item.onlydefaultwh,'+
'Item.BarCode,'+
'Item.ItemCode2,'+
'Item.canSale,'+
'Item.Itemcreatetime,'+
'Item.Itemmodifytime,'+
'Item.Itemdisabletime,'+
'Item.CurrentOnHandInv,'+
'Item.CurrentOnCheckInv,'+
'Item.CurrentFreezeInv,'+
'Item.CurrentOnShipInv,'+
'Item.CurrentWasterInv,'+
'Item.remArk,'+
'Item.DeptCode,'+
'case when Item.PmCode=0 then Dept.DeptName else Vendor.VendorName end as DeptName,'+
'Item.Batchstrat,'+
'Item.BatchCtrl,'+
'Item.Capacityhours,'+
'Item.ItemClass1,'+
'Item.ItemClass2,'+
'Item.ItemClass3,'+
'Item.ItemClass4,'+
'Item.ItemClass5,'+
'opCurrentInv.opInv, '+
'Item.InspecTEmployeeCode,'+
'I.EmployeeName As InspecTEmployeeName'+
' into #tmpItemBase1 '+
' from Item left join Warehouse on Item.whCode=Warehouse.whCode '+
' Left Join Employee I On I.EmployeeCode=Item.InspecTEmployeeCode '+
' left join Employee c on Item.EmployeeCode=c.EmployeeCode '+
' left join Employee j on Item.Pla_EmployeeCode=j.EmployeeCode '+
' left join Employee k on Item.wh_EmployeeCode=k.EmployeeCode '+
' left join Uom on Item.UomCode=Uom.UomCode '+
' left join Dept on Item.DeptCode=Dept.DeptCode '+
' left join Vendor on Item.DeptCode=Vendor.VendorCode '+
'left join (select ItemCode,sum(OPInv) opInv from OPCurrentInv group by ItemCode) opCurrentInv '+
' on Item.ItemCode=opCurrentInv.ItemCode'+
' left join ItemClass on Item.ClassCode=ItemClass.ClassCode';
//当前排序字段
OrderByFields:='ItemCode';
lbl_Order.Caption:='物料代码';
Executesql(AdoQry_tmp,sqltext,1);
selectfromsql:='select * from #tmpItemBase1';
//初始化DBGRID的部分列的可视设置
for i:=0 to dbgrideh.Columns.Count-1 do
begin
if (dbgrideh.Columns[i].FieldName='ItemCode')
or(dbgrideh.Columns[i].FieldName='ItemName')
or(dbgrideh.Columns[i].FieldName='UomName')
or(dbgrideh.Columns[i].FieldName='ItemType')
or(dbgrideh.Columns[i].FieldName='ItemUsable')then
dbgrideh.Columns[i].Visible:=True
else
begin
dbgrideh.Columns[i].Visible:=False;
end;
end;
GetData;
// initdbgrdehcolumn; DBGRID 的列的ORIGIN的设定
k:=AdoQry_Main.FieldCount-1;
for i:=0 to k do
begin
if (AdoQry_Main.Fields[i].DisplayName='ItemCode')
or(AdoQry_Main.Fields[i].DisplayName='ItemName')
or(AdoQry_Main.Fields[i].DisplayName='ItemType')
or(AdoQry_Main.Fields[i].DisplayName='ItemUsable')
or(AdoQry_Main.Fields[i].DisplayName='iScheck') then
AdoQry_Main.Fields[i].Origin:='Item'
else if AdoQry_Main.Fields[i].DisplayName='UomName' then
AdoQry_Main.Fields[i].Origin:='Uom'
else
begin
AdoQry_Main.Fields[i].Origin:='';
end;
end;
{ k:=dbgrideh.Columns.Count-1 ;
for i:=0 to k do
begin
if (dbgrideh.Columns[i].FieldName='ItemCode')
or(dbgrideh.Columns[i].FieldName='ItemName')
or(dbgrideh.Columns[i].FieldName='ItemType')
or(dbgrideh.Columns[i].FieldName='ItemUsable') then
dbgrideh.Columns[i].Field.Origin:='Item'
else if dbgrideh.Columns[i].FieldName='UomName' then
dbgrideh.Columns[i].Field.Origin:='Uom'
else
begin
// dbgrideh.Columns.Delete(i);
end;
end; }
//列的宽度调整
col_Adjust;
j:=0;
for i:=0 to dbgrideh.Columns.Count-1 do
begin
if dbgrideh.Columns[i].Visible then
begin
tmp_grid.Columns.Add;
tmp_grid.Columns[j].Assign(dbgrideh.columns[i]);
j:=j+1;
end;
end;
//物料的分类属性的图标设定
if Param1='General' then
begin
act_New.Enabled :=True;
act_Delete.Enabled :=True;
act_look.Enabled :=False;
act_look.Visible :=False;
action3.Enabled :=False;
Caption:='物料主文件基本属性维护';
Pnl_Title.Caption :='物料主文件基本属性维护';
end
else if (Param1='Plan') then
begin
act_New.Enabled :=False;
act_Delete.Enabled :=False;
act_look.Visible :=False;
act_look.Enabled :=False;
action3.Enabled :=False;
act_Modify.Enabled :=True;
Caption:=' 物料主文件计划属性维护';
Pnl_Title.Caption :=' 物料主文件计划属性维护';
end
else if (Param1='Stk') then
begin
act_New.Enabled :=False;
act_Delete.Enabled :=False;
act_look.Visible :=False;
act_look.Enabled :=False;
action3.Enabled :=False;
act_Modify.Enabled :=True;
Caption:='物料主文件库存管理属性维护';
Pnl_Title.Caption :=' 物料主文件库存属性维护';
end
else if (Param1='Qc') then
begin
act_New.Enabled :=False;
act_Delete.Enabled :=False;
act_look.Visible :=False;
act_look.Enabled :=False;
action3.Enabled :=False;
act_Modify.Enabled :=True;
Caption:='物料主文件质检管理属性维护';
Pnl_Title.Caption :=' 物料主文件质检属性维护';
end
else if (Param1='Fin') then
begin
act_New.Enabled :=False;
act_Delete.Enabled :=False;
act_look.Visible :=False;
act_look.Enabled :=False;
action3.Enabled :=False;
act_Modify.Enabled :=True;
Caption:='物料主文件财务属性维护';
Pnl_Title.Caption :=' 物料主文件财务属性维护';
end
else if (Param1='Use') then
begin
TlBtn_Copy.Action :=action3;
act_New.Enabled :=False;
act_Delete.Enabled :=False;
act_Modify.Enabled :=False;
act_look.Enabled :=True;
action3.Enabled :=True;
Caption:='物料主文件物料生效';
Pnl_Title.Caption :='物料主文件物料生效';
end
else
begin
act_New.Enabled :=False;
act_Delete.Enabled :=False;
act_Modify.Enabled :=False;
act_look.Enabled :=True;
action3.Enabled :=False;
Caption:='物料主文件查询';
Pnl_Title.Caption :='物料主文件查询';
end;
//设置弹出窗体
Frm_Sys_Detail:=TFrm_Bas_Item_D.Create(Application);
end;
function TFrm_Bas_Item.SetDeleteSql:String;
begin
Result:='Delete Item Where ItemCode='''+AdoQry_Main.fieldbyname('ItemCode').AsString+'''';
end;
procedure TFrm_Bas_Item.initdbgrdehcolumn;
var
recCount,fieldCounts,i,j:Integer;
ItemClass:string;
begin
//根据模块参数进行相关字段初始化
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select SysParamValueC from SysParam where left(SysParamCode,9)=''ItemClass'' ');
open;
recCount:=0;
while not eof do
begin
if fieldbyname('SysParamValueC').asstring<>'' then
inc(recCount)
else
//防止中间有一个为空的,如果有,则后面的都不理会
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -