📄 bas_item_new.pas
字号:
unit Bas_Item_New;
//物料主文件分属性维护主单元
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_New = Class(TFrm_Base_Outer)
Label1: TLabel;
edt_locate: TEdit;
cbx_Showall: TCheckBox;
tmp_grid: TDBGridEh;
chk_max: TCheckBox;
Label2: TLabel;
Label3: TLabel;
AdoQry_MainItemCode: TStringField;
kk: TStringField;
AdoQry_MainMaterial: TStringField;
AdoQry_MainItemshortName: TStringField;
AdoQry_MainUomCode: TStringField;
AdoQry_MainUomName: TStringField;
AdoQry_MainClassCode: TStringField;
AdoQry_MainClassName: TStringField;
AdoQry_MainProductClass: TStringField;
AdoQry_MainQcClass: TStringField;
AdoQry_MainUomCodeName: TStringField;
AdoQry_MainCaiGouyuan: TStringField;
AdoQry_MainwhCodeName: TStringField;
AdoQry_MainJiHuayuan: TStringField;
AdoQry_MainEmployeeCode: TStringField;
AdoQry_MainCaiGou: TStringField;
AdoQry_MainwhCode: TStringField;
AdoQry_MainwhName: TStringField;
AdoQry_MainPla_EmployeeCode: TStringField;
AdoQry_MainJiHua: TStringField;
AdoQry_Mainwh_EmployeeCode: TStringField;
AdoQry_Mainwh_EmployeeName: TStringField;
AdoQry_MainItemType: TIntegerField;
AdoQry_Maindesignno: TStringField;
AdoQry_MainItemUsable: TIntegerField;
AdoQry_Mainmaxqty: TFloatField;
AdoQry_Mainminqty: TFloatField;
AdoQry_Mainlimitout: TIntegerField;
AdoQry_MainLongPurchLT: TIntegerField;
AdoQry_MainiScheck: 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_MainItemcreatetime: TDateTimeField;
AdoQry_MainItemmodifytime: TDateTimeField;
AdoQry_MainItemdisabletime: TDateTimeField;
AdoQry_MainCurrentOnHandInv: TFloatField;
AdoQry_MainCurrentOnCheckInv: TFloatField;
AdoQry_MainCurrentFreezeInv: TFloatField;
AdoQry_MainCurrentOnShipInv: TFloatField;
AdoQry_MainCurrentWasterInv: TFloatField;
AdoQry_MainremArk: TStringField;
AdoQry_MainDeptCode: 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;
AdoQry_MainAssetKmCode: TStringField;
AdoQry_MainKmName: TStringField;
AdoQry_MainInSpecTEmployeeCode: TStringField;
AdoQry_MainInSpecTEmployeeName: TStringField;
AdoQry_MainScrApType: TIntegerField;
AdoQry_MainISStockItem: TIntegerField;
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);
procedure GetPosition;
procedure FormDestroy(Sender: TObject);
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_New: TFrm_Bas_Item_New;
implementation
uses Bas_Item_D_New,Sys_Global;
{$R *.DFM}
procedure TFrm_Bas_Item_New.initform(AdOConnection:TAdOConnection;ReadOnly:boolean);
var
i,j,k:integer;
begin//SQL初始化
inherited;
sqltext:='Select * From Vw_Base_Item';
//当前排序字段
OrderByFields:='ItemCode';
lbl_Order.Caption:='物料代码';
selectfromsql:='select * from Vw_Base_Item';
ExecuteSql(AdoQry_Main,SelectFromSql+' Where 1=2 ',0);
Act_FilterExecute(Application);
Application.ProcessMessages;
CreatePanel(1,dbgrideh);
//GetData;
k:=AdoQry_Main.FieldCount-1;
//列的宽度调整
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;
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;
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;
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;
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_New.Create(Application);
If Assigned(ShowAnimate) then ShowAnimate.free;
If Assigned(ShowPanel) then ShowPanel.free;
end;
function TFrm_Bas_Item_New.SetDeleteSql:String;
begin
Result:='Delete Item Where ItemCode='''+AdoQry_Main.fieldbyname('ItemCode').AsString+'''';
end;
procedure TFrm_Bas_Item_New.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;
next;
end;
First;
//记录dbgrid有多少个Column
fieldCounts:=dbgrideh.Columns.Count;
for i:=1 to recCount do
begin
ItemClass:='ItemClass'+inttostr(i);
//遍历所有字段,而不是指定字段的序号
for j:=0 to fieldCounts-1 do
begin
if lowercase(dbgrideh.columns[j].fieldName)=ItemClass then
begin
dbgrideh.columns[j].Title.Caption:=fieldbyname('SysParamValueC').asstring;
next;
break;
end;
end;
end;
//删除不用的字段
for i:=i to 5 do
begin
ItemClass:='ItemClass'+inttostr(i);
for j:=0 to fieldCounts-1 do
begin
if lowercase(dbgrideh.columns[j].fieldName)=ItemClass then
begin
dbgrideh.columns.delete(j);
break;
end;
end;
end;
end;
end;
procedure TFrm_Bas_Item_New.DBGridEhGetCellParams(Sender: TObject;
Column: TColumnEh; AFont: TFont; var Background: TColor;
State: TGridDrawState);
begin
inherited;
if AdoQry_Main.fieldbyname('ItemUsable').AsString='0' Then
AFont.Color:=ClRed;
if (gdselected in state) then
begin
Background:=clnavy;
afont.color:=clwindow;
end;
end;
procedure TFrm_Bas_Item_New.Action3Execute(Sender: TObject);
begin
inherited;
if AdoQry_Main.fieldbyname('ItemUsable').asstring='1' then
begin
if strtofloat(judgeuseable)>0 then
begin
if DispInfo('该物料还存在库存,库存是:'+judgeuseable+#10+#13+' 确认该物料无效吗?',2)='y' then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -