📄 pm_enter_ssvendorassigninfo2.pas
字号:
unit Pm_Enter_SsVendorAssignInfo2;
//
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_Pm_Enter_SsVendorAssignInfo2 = Class(TFrm_Base_Outer)
AdoQry_MainItemCode: TStringField;
AdoQry_MainItemName: TStringField;
AdoQry_MainUomName: TStringField;
AdoQry_MainIsAssign: TIntegerField;
AdoQry_Mainduedate: TDateTimeField;
AdoQry_Mainssqty: TFloatField;
AdoQry_Mainssdate: TDateTimeField;
AdoQry_MainSysqty: TFloatField;
AdoQry_MainItemFlag: TStringField;
AdoQry_MainSSSysInfoFlag: TIntegerField;
AdoQry_MainSsreleaseDate: TDateTimeField;
AdoQry_MainToDate: TStringField;
AdoQry_Maintmpfield: TIntegerField;
procedure FormDestroy(Sender: TObject);
procedure AdoQry_MainBeforeInsert(DataSet: TDataSet);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure AdoQry_MainBeforeEdit(DataSet: TDataSet);
procedure AdoQry_MainAfterPost(DataSet: TDataSet);
procedure Act_autoExecute(Sender: TObject);
procedure DBGridEhTitleClick(Column: TColumnEh);
private
checked:boolean;
{ Private declarations }
public
Flag : boolean;
procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
{ Public declarations }
end;
var
Frm_Pm_Enter_SsVendorAssignInfo2: TFrm_Pm_Enter_SsVendorAssignInfo2;
implementation
uses Sys_Global, Pm_Enter_SsVendorAssignInfo2_B;
{$R *.DFM}
{ TFrm_Mrp_Qry_DynamicMrpInfo }
procedure TFrm_Pm_Enter_SsVendorAssignInfo2.InitForm(
AdOConnection: TAdOConnection; ReadOnly: Boolean);
var sqltext:string;
begin
Application.ProcessMessages;
inherited;
Flag := False;
If ReadOnly=True Then
begin
TlBtn_Copy.Visible:=False;
end;
sqltext:= ' declAre @RunMrpdate varchAr(30) '
+' Select @RunMrpDate=MrpParamValueC '
+' From MrpParam '
+' Where MrpParamCode=''RunMrpDate'' '
+' select TmpField, '
+' ToDate,'
// +' Convert(varchAr,Convert(Datetime,PurchaseApply.Todate),102) as ToDate, '
+' PurchaseApply.ItemCode,'
+' ItemName, '
+' PurchaseApply.ItemCode+'' ''+ItemName as ItemFlag, '
+' UomName, '
+' IsAssign, '
+' PlanDueDate as duedate, '
+' PurchaseApply.SSReleaseDate, '
+' ssqty, '
+' ssSysInfoFlag=0, '
+' ssdate=PlanReleaseDate, '
+' Sysqty=PlanQty '
+' into #TmpVendorAssignInfo '
+' from PurchaseApply '
+' left join Item on PurchaseApply.ItemCode=Item.ItemCode '
+' left join Uom on Item.UomCode=Uom.UomCode '
+' where IsMultiVendor=1 '
+' and IsAssign=0 '
+' and IsActive=1 '
+' and Convert(Datetime,ToDate)=Convert(DateTime,@RunMrpDate) ';
ExecuteSql(AdoQry_Tmp,SqlText,1);
selectfromsql:='select * from #TmpVendorAssignInfo';
OrderByFields := 'ItemCode';
GetData;
Lbl_Condition.Caption:='全部';
AdoQry_Tmp.Close;
Checked:=False;
Application.ProcessMessages;
end;
procedure TFrm_Pm_Enter_SsVendorAssignInfo2.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Pm_Enter_SsVendorAssignInfo2:=nil;
end;
procedure TFrm_Pm_Enter_SsVendorAssignInfo2.AdoQry_MainBeforeInsert(
DataSet: TDataSet);
begin
inherited;
Abort;
end;
procedure TFrm_Pm_Enter_SsVendorAssignInfo2.FormCreate(Sender: TObject);
begin
inherited;
ExtendCaption:=False;
toolbutton6.Action:=act_auto;
end;
procedure TFrm_Pm_Enter_SsVendorAssignInfo2.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
try
Executesql(AdoQry_tmp,'drop table #TmpVendorAssignInfo',1);
except
end;
try
Executesql(AdoQry_tmp,'drop table #TmpPc',1);
except
end;
end;
procedure TFrm_Pm_Enter_SsVendorAssignInfo2.AdoQry_MainBeforeEdit(
DataSet: TDataSet);
begin
inherited;
If AdoQry_Main.fieldbyname('IsAssign').AsInteger=1 then
begin
DispInfo('这条记录已分配完,不可选定!',3);
Abort;
end;
end;
procedure TFrm_Pm_Enter_SsVendorAssignInfo2.AdoQry_MainAfterPost(
DataSet: TDataSet);
begin
inherited;
ExecuteSql(AdoQry_Tmp,'update #TmpVendorAssignInfo '
+' set TmpField='+AdoQry_Main.fieldbyname('TmpField').AsString
+' where ToDate='+QuotedStr(AdoQry_Main.fieldbyname('ToDate').asString)
+' and ItemCode='+QuotedStr(AdoQry_Main.fieldbyname('ItemCode').AsString)
+' and SSReleaseDate='+QuotedStr(AdoQry_Main.fieldbyname('SSReleaseDAte').AsString)
,1);
end;
procedure TFrm_Pm_Enter_SsVendorAssignInfo2.Act_autoExecute(
Sender: TObject);
{var
BookmArk:String;
SqlText : String;
AdoQry,AdoQry1 : TAdoQuery; }
var
BookmArk:String;
begin
inherited;
If AdoQry_Main.RecordCount=0 Then Exit;
If AdoQry_Main.fieldbyname('IsAssign').AsInteger=1 Then
begin
DispInfo('本条建议已分配完毕,不能再分配!',3);
Abort;
end;
try
BookmArk:=AdoQry_Main.BookmArk;
begin
Frm_Pm_Enter_SsVendorAssignInfo2_B:=TFrm_Pm_Enter_SsVendorAssignInfo2_B.Create(Application);
Frm_Pm_Enter_SsVendorAssignInfo2_B.SetSysParam(UserCode,ModuleCode,MenuId,DateTimeToStr(Now));
Frm_Pm_Enter_SsVendorAssignInfo2_B.ToDate := AdoQry_Main.fieldbyname('ToDate').AsString;
Frm_Pm_Enter_SsVendorAssignInfo2_B.ItemCode := AdoQry_Main.fieldbyname('ItemCode').AsString;
Frm_Pm_Enter_SsVendorAssignInfo2_B.ItemName := AdoQry_Main.fieldbyname('ItemName').AsString;
Frm_Pm_Enter_SsVendorAssignInfo2_B.SSReleaseDate := AdoQry_Main.fieldbyname('SSDate').AsString;
Frm_Pm_Enter_SsVendorAssignInfo2_B.DueDate := AdoQry_Main.fieldbyname('DueDate').AsString;
Frm_Pm_Enter_SsVendorAssignInfo2_B.Lbl_Qty.Caption:=AdoQry_Main.fieldbyname('Sysqty').asstring;
Frm_Pm_Enter_SsVendorAssignInfo2_B.qty := AdoQry_Main.fieldbyname('SysQty').AsFloat;
Frm_Pm_Enter_SsVendorAssignInfo2_B.GetalterItem(AdoQry_Main,AdoQry_Main.fieldbyname('ItemCode').asstring);
Frm_Pm_Enter_SsVendorAssignInfo2_B.ShowModal;
Frm_Pm_Enter_SsVendorAssignInfo2_B.Release;
end;
AdoQry_Main.ReQuery;
finally
AdoQry_Main.BookmArk:=BookmArk;
end;
end;
{
begin
inherited;
BookMArk := AdoQry_Main.BookmArk;
If AdoQry_Main.State in [dsEdit] then AdoQry_Main.Post;
ExecuteSql(AdoQry_Tmp,'select * from #TmpVendorAssignInfo '
+' where TmpField=1 ',0) ;
If AdoQry_Tmp.RecordCount=0 then exit;
AdoQry_Tmp.First;
AdoQry := TAdoQuery.Create(nil);
AdoQry.Connection := DbConnect;
AdoQry.EnableBCD := False;
AdoQry1 := TAdoQuery.Create(nil);
AdoQry1.Connection := Dbconnect;
AdoQry1.EnableBCD := False;
try
ExecuteSql(AdoQry,'drop table #TmpPc ',1);
Except
end;
ExecuteSql(AdoQry,'select Pc.VendorCode,pcLine.* '
+' Into #TmpPC '
+' from PcLine '
+' join Pc on PcLine.PcNo=Pc.PcNo '
+' where PcLineStatus=1 ',1);
try
try
dbconnect.beginTrans;
While not AdoQry_Tmp.Eof do
begin
// ThisAssignQty := AdoQry_Tmp.fieldbyname('SysQty').AsFloat;
ExecuteSql(AdoQry,'select ItemCode,VendorCode, '
+QuotedStr(AdoQry_Tmp.fieldbyname('ssDate').AsString)+' as PlanReleaseDate, '
+' AssignRate,AssignRate/100.0*'+AdoQry_Tmp.fieldbyname('SysQty').AsString+' as Qty '
+' from VendorItemAssign '
+' where ItemCode='+QuotedStr(AdoQry_Tmp.fieldbyname('ItemCode').AsString)
,0);
while (not AdoQry.Eof) do begin
ExecuteSql(AdoQry1,'select * from #TmpPc '
+' where PcStArtDate<='+QuotedStr(AdoQry.fieldbyname('PlanReleaseDate').AsString)
+' and PcendDate>='+QuotedStr(AdoQry.fieldbyname('PlanReleaseDate').AsString)
+' and ItemCode='+QuotedStr(AdoQry.fieldbyname('ItemCode').AsString)
+' and VendorCode='+QuotedStr(AdoQry.fieldbyname('VendorCode').AsString)
,0);
If AdoQry1.RecordCount>0 then
begin
SqlText := 'insert into PurchaseApplyAssign '
+' (ToDate,ItemCode,VendorCode,SSQty,PlanQty, '
+' SSReleaseDate,PlanDueDate,PlanReleaseDate, '
+' CreateEmployeeCode,CreateDate, '
+' EdItEmployeeCode,EditDate) '
+'Values('+QuotedStr(AdoQry_Tmp.fieldbyname('ToDate').AsString)+','
+quotedstr(AdoQry_Tmp.fieldbyname('ItemCode').asstring)+','
+QuotedStr(AdoQry.fieldbyname('VendorCode').AsString)+','
+floattostr(IIFValue((AdoQry.fieldbyname('QTY').AsFloat>AdoQry1.fieldbyname('PcendQty').AsFloat) and (AdoQry1.fieldbyname('PcendQty').AsFloat<>0.0),AdoQry1.fieldbyname('PcendQty').AsFloat,AdoQry.fieldbyname('QTY').AsFloat))+','
+floattostr(IIFValue((AdoQry.fieldbyname('QTY').AsFloat>AdoQry1.fieldbyname('PcendQty').AsFloat) and (AdoQry1.fieldbyname('PcendQty').AsFloat<>0.0),AdoQry1.fieldbyname('PcendQty').AsFloat,AdoQry.fieldbyname('QTY').AsFloat))+','
+quotedstr(AdoQry_Tmp.fieldbyname('ssdate').asstring)+','
+quotedstr(AdoQry_Tmp.fieldbyname('duedate').asstring)+','
+quotedstr(AdoQry_Tmp.fieldbyname('ssdate').asstring)+','
+QuotedStr(UserCode)+','
+'GetDate(),'
+quotedstr(UserCode)+','
+'GetDate()'
+')';
ExecuteSql(AdoQry1,SqlText,1);
end;
AdoQry.Next;
end;
ExecuteSql(AdoQry1,'update PurchaseApply '
+' set IsAssign=1 '
+' where ToDate='+QuotedStr(AdoQry_Tmp.fieldbyname('ToDate').AsString)
+' and ItemCode='+Quotedstr(AdoQry_Tmp.fieldbyname('ItemCode').AsString)
+ ' and SsReleaseDate='+quotedStr(AdoQry_Tmp.fieldbyname('SSReleaseDate').AsString)
,1);
ExecuteSql(AdoQry1,'update #TmpVendorAssignInfo '
+' set IsAssign=1, '
+' TmpField=0 '
+' where ToDate='+QuotedStr(AdoQry_Tmp.fieldbyname('ToDate').AsString)
+' and ItemCode='+Quotedstr(AdoQry_Tmp.fieldbyname('ItemCode').AsString)
+ ' and SsReleaseDate='+quotedStr(AdoQry_Tmp.fieldbyname('SSReleaseDate').AsString)
,1);
AdoQry_Tmp.Next;
end;
dbconnect.CommitTrans;
AdoQry_Main.ReQuery;
AdoQry_Main.BookmArk := BookMArk;
DispInfo('分配完毕!',3);
Except
If dbconnect.InTransaction then dbconnect.RollBackTrans;
DispInfo('分配失败,请重试!',1);
end;
finally
If Assigned(AdoQry) then AdoQry.Free;
If Assigned(AdoQry1) then AdoQry1.Free;
end;
end;
}
procedure TFrm_Pm_Enter_SsVendorAssignInfo2.DBGridEhTitleClick(
Column: TColumnEh);
var
BookMArk:String;
begin
inherited;
If Trim(Column.Title.Caption)<>'标记' Then
Abort;
If AdoQry_Main.RecordCount=0 Then
Abort;
BookMArk:=AdoQry_Main.BookmArk;
If Not Flag Then
begin
AdoQry_Main.First;
While Not AdoQry_Main.Eof Do
begin
AdoQry_Main.Edit;
AdoQry_Main.fieldbyname('TmpField').AsInteger:=1;
AdoQry_Main.Post;
AdoQry_Main.Next;
end;
end
Else
begin
AdoQry_Main.First;
While Not AdoQry_Main.Eof Do
begin
AdoQry_Main.Edit;
AdoQry_Main.fieldbyname('TmpField').AsInteger:=0;
AdoQry_Main.Post;
AdoQry_Main.Next;
end;
end;
AdoQry_Main.BookmArk:=BookMArk;
Flag:=Not Flag;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -