📄 sfc_mninoverplan_d.pas
字号:
unit Sfc_MnInOverPlan_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,math,
Base_Detail, StdCtrls, Db, AdODB, ExtCtrls, ExtEdit, linkedit, variants;
Type
TFrm_Sfc_MnInOverPlan_D = Class(TFrm_Base_Detail)
Label2: TLabel;
Label4: TLabel;
Lbl_ItemName1: TLabel;
Edt_MoLineNo: TExtEdit;
Label3: TLabel;
Lbl_VendorName: TLabel;
Label6: TLabel;
Label5: TLabel;
Label8: TLabel;
Edt_MoInQTy: TEdit;
Lbl_MoQty: TLabel;
Lbl_MoRealInQty: TLabel;
Label1: TLabel;
Lbl_MoNoFinishQty: TLabel;
ExtEdt_ItemCode: TLinkEdit;
Lbl_ItemName: TEdit;
procedure ItemCodeCheck(Sender: TObject);
procedure IntegerCheck(Sender: TObject);
procedure FloatCheck(Sender: TObject);
procedure btn_okClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ExtEdt_ItemCodeExit(Sender: TObject);
private
FMoNo,FDeptCode,FShift,HasNegative:string;
percent:real;
FWhCode,FWhPosition:String;
{ Private declarations }
public
{ Public declarations }
Max_ind:Integer;
procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,FrmParam5,FrmParam6:String);Override;
protected
procedure InitControls; Override;
procedure SaveData; Override;
end;
var
Frm_Sfc_MnInOverPlan_D: TFrm_Sfc_MnInOverPlan_D;
WhEmployee,DealedDate:String;
implementation
uses Sys_Global,Inv_Global,Sfc_MnInOverPlan_B;
{$R *.DFM}
procedure TFrm_Sfc_MnInOverPlan_D.InitControls;
begin
inherited;
If Add then
SetFocus_Control:=ExtEdt_ItemCode
else
SetFocus_Control:=Edt_MoInQty;
with AdoQry_Tmp do
begin
Close;
sql.clear;
sql.text:='select max(MoLineno) MoLineno '+
' from MoLine '+
' where mono='''+Frm_Sfc_MnInOverPlan_B.Lbl_MoNo.Caption+'''';
open;
if Max_ind< fieldbyname('MoLineno').asinteger+1 then
Max_ind:=fieldbyname('MoLineno').asInteger+1;
Edt_MoLineNo.text:=inttostr(Max_ind);
end;
with AdoQry_Maintain do
begin
if not Add then
begin
Edt_MoLineNo.Text:=IntToStr(fieldbyname('MoLineNo').AsInteger);
ExtEdt_ItemCode.Text:=fieldbyname('ItemCode').AsString;
Lbl_MoQty.Caption:=FloatToStr(fieldbyname('MoQty').AsFloat);
Lbl_MoNoFinishQty.Caption:=fieldbyname('MoNoFinishQty').asstring;
Lbl_MoRealInQty.Caption:=FloatToStr(fieldbyname('MoRealInQty').AsFloat);
Edt_MoInQty.Text:=FloatToStr(fieldbyname('MoInQty').AsFloat);
Lbl_ItemName.text:=fieldbyname('ItemName').AsString;
end
else
begin
Lbl_MoQty.Caption:='0';
Lbl_MoRealInQty.Caption:='0';
Lbl_MoNoFinishQty.Caption:='0';
end;
end;
with AdoQry_tmp do
begin
Close;
sql.text:='select MrpParamValueN '+
' from MrpParam '+
'where MrpParamCode=''Overqtydeny_Percent''';
open;
percent:=fieldbyname('MrpParamValueN').asfloat;
end;
end;
procedure TFrm_Sfc_MnInOverPlan_D.SaveData;
var
QrySort: string;//新增行的约定交货日期DealedDate
begin
inherited;
{ if(Add)then
begin
with AdoQry_Tmp do
begin
Close;
Sql.clear;
Sql.Add('Insert Into MoLine(MONO,MoLineNO,ItemCode,MOQTY,MoLineDATE,'+
' MoNoFinishQTY,MoLineSTATUS,MOStArtWorkDate,'+
' MoRealInQty,MoInQty) '+
'Values(:MONO,:MoLineNO,:ItemCode,:MOQTY,:MoLineDATE,'+
' :MoNoFinishQTY,:MoLineSTATUS,:MOStArtWorkDate,'+
' :MoRealInQty,:MoInQty) ');
Parameters.ParamByName('MONO').Value:=FMONo;
Parameters.ParamByName('MoLineNO').Value:=Edt_MoLineNo.Text;
Parameters.ParamByName('ItemCode').Value:=ExtEdt_ItemCode.Text;
Parameters.ParamByName('MOQTY').Value:=0; //约定交货量
Parameters.ParamByName('MoLineDATE').Value:=DATE();
Parameters.ParamByName('MoNoFinishQTY').Value:=0;
Parameters.ParamByName('MoLineSTATUS').Value:=6;
Parameters.ParamByName('MOStArtWorkDate').Value:=DATE();
Parameters.ParamByName('MoRealInQty').Value:=0;
Parameters.ParamByName('MoInQty').Value:=Edt_MoInQty.text;
ExecSql;
end;
end
Else
begin
with AdoQry_Tmp do
begin
Close;
Sql.clear;
Sql.Add('UpDate MoLine Set MoInQTY='+
Trim(Edt_MoInQty.Text)+
' where MONO='''+FMONo+''''+
' and MoLineNo='+Edt_MoLineNo.text);
ExecSQl;
end;
end;
with AdoQry_Maintain do
begin
QrySort:=Sort;
Close;
Open;
Sort:=QrySort;
end;}
With AdoQry_Maintain do
begin
fieldbyname('MoLineNo').AsInteger:=StrToInt(Edt_MoLineNo.Text);
fieldbyname('ItemCode').AsString:=ExtEdt_ItemCode.Text;
fieldbyname('MoQty').AsFloat:=StrToFloat(Lbl_MoQty.Caption);
fieldbyname('MoRealInQty').AsFloat:=StrToFloat(Lbl_MoRealInQty.Caption);
fieldbyname('MoInQty').AsFloat:=StrToFloat(Edt_MoInQty.Text);
fieldbyname('ItemName').AsString:=Lbl_ItemName.text;
fieldbyname('MoNoFinishQty').asstring:=Lbl_MoNoFinishQty.Caption;
If (Add) then
begin
fieldbyname('wh_EmployeeCode').asstring:=WhEmployee;
fieldbyname('MoLineDate').asstring:=DealedDate;
end;
Post;
end;
end;
procedure TFrm_Sfc_MnInOverPlan_D.ItemCodeCheck(Sender: TObject);
begin
inherited;
Lbl_MoQty.Caption:='0';
Lbl_MoRealInQty.Caption:='0';
Frm_Sfc_MnInOverPlan_B.AdoQry_Main.First;
if Add then
begin
if Frm_Sfc_MnInOverPlan_B.AdoQry_Main.locate('ItemCode',ExtEdt_ItemCode.text,[]) then
begin
DispInfo('该物料在本单据中已经存在,不允许增加或修改!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
if not DefaultWHCheck(AdoQry_tmp,getCode(Frm_Sfc_MnInOverPlan_B.Cmbx_WhCode.text),Extedt_ItemCode.text) then
begin
twincontrol(sender).setfocus;
abort;
end;
with AdoQry_Tmp do
begin
Close;
sql.text:='select I.wh_EmployeeCode+'' ''+E.EmployeeName Employee'+
' from Item I'+
' Join Employee E'+
' on E.EmployeeCode=I.Wh_EmployeeCode'+
' where ItemCode='''+ExtEdt_ItemCode.text+'''';
open;
WhEmployee:=fieldbyname('Employee').asstring;
end;
DealedDate:=datetostr(date);
end;
end;
procedure TFrm_Sfc_MnInOverPlan_D.IntegerCheck(Sender: TObject);
var
BookMArk1:TBookMArk;
begin
inherited;
if (Add) then
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add('Select Count(*) as RecCount From MoLine Where '+
'MONo='''+FMONo+'''and MoLineNo='+Edt_MoLineNO.Text);
Open;
if fieldbyname('RecCount').AsInteger<>0 then
begin
DispInfo('该订单行已经存在,不允许增加!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
BookMArk1:=AdoQry_Maintain.GetBookmArk;
AdoQry_Maintain.First;
while not AdoQry_Maintain.Eof do
begin
if AdoQry_Maintain.fieldbyname('MoLineNo').AsString=Edt_MoLineNo.Text then
begin
Edt_MoLineNo.SetFocus;
AdoQry_Maintain.GotoBookmArk(BookmArk1);
AdoQry_Maintain.FreeBookmArk(BookmArk1);
DispInfo(' 同一张单据中不能有相同的订单行号! ',3);
Abort;
end;
AdoQry_Maintain.Next;
end;
AdoQry_Maintain.GotoBookmArk(BookmArk1);
AdoQry_Maintain.FreeBookmArk(BookmArk1);
end;
end;
procedure TFrm_Sfc_MnInOverPlan_D.SetFormParam(FrmParam1, FrmParam2,
FrmParam3, FrmParam4, FrmParam5, FrmParam6: String);
begin
FMoNo:=FrmParam1;
FDeptCode:=FrmParam2;
FShift:=FrmParam3;
HasNegative:=FrmParam4;
FWhCode:=FrmParam5;
FWhPosition:=frmParam6;
end;
procedure TFrm_Sfc_MnInOverPlan_D.FloatCheck(Sender: TObject);
var
ItInMo:Boolean;
i:integer;
varj,vark:real;
Book1:TBookMArk;
begin
inherited;
with AdoQry_Tmp do
begin
Close;
sql.clear;
sql.Add('select * '+
' from MoLine'+
' where MoLineno='''+Edt_MoLineNo.text+''' and'+
' mono='''+FMoNo+'''');
open;
if not IsEmpty then
ItInMo:=True
else ItInMo:=False;
end;
If (StrToFloat(Edt_MoInQty.Text)=0) and (Not ItInMO) then
begin
DispInfo('新增记录拟入数量不能等于零',1);
Edt_MoInQty.SetFocus;
Abort;
end;
{ If ((StrToFloat(Edt_MoInQty.Text)<0)
and (UpperCase(HasNegative)<>'YES') and (UpperCase(HasNegative)<>'NONE'))
Or ((StrToFloat(Edt_MoInQty.Text)>0)
and (UpperCase(HasNegative)<>'NO') and (UpperCase(HasNegative)<>'NONE')) then
begin
DispInfo('同一次入库,不能出现正负数混合的情况',1);
Edt_MoInQty.SetFocus;
Abort;
end;}
Book1:=Frm_Sfc_MnInOverPlan_B.AdoQry_Main.GetBookmArk;
Frm_Sfc_MnInOverPlan_B.AdoQry_Main.First;
for i:=0 to Frm_Sfc_MnInOverPlan_B.AdoQry_Main.RecordCount-1 do
begin
varj:=strtofloat(Edt_MoInQTy.text);
vark:=Frm_Sfc_MnInOverPlan_B.AdoQry_Main.fieldbyname('MoInQty').asfloat;
if (varj*vark<0) and
(Frm_Sfc_MnInOverPlan_B.AdoQry_Main.fieldbyname('ItemCode').asstring<>Trim(ExtEdt_ItemCode.text))
then
begin
DispInfo('同一次出库,不能出现正负数混合的情况!',1);
Edt_MoInQTy.setfocus;
Frm_Sfc_MnInOverPlan_B.AdoQry_Main.GotoBookmArk(Book1);
Frm_Sfc_MnInOverPlan_B.AdoQry_Main.freeBookmArk(Book1);
abort;
end;
Frm_Sfc_MnInOverPlan_B.AdoQry_Main.next;
end;
Frm_Sfc_MnInOverPlan_B.AdoQry_Main.GotoBookmArk(Book1);
Frm_Sfc_MnInOverPlan_B.AdoQry_Main.freeBookmArk(Book1);
varj:=abs(strtofloat(Edt_MoInQTy.text));
vark:=strtofloat(Lbl_MoRealInQty.Caption)-round(strtofloat(Lbl_MoQty.Caption)*(1+percent/100));
if (strtofloat(Edt_MoInQTy.text)<0) and
(varj>vark) then
begin
DispInfo('冲销的数量不能大于累计超订单入库数量!',1);
Edt_MoInQTy.setfocus;
abort;
end;
if not InvQtyCheck(False,
Frm_Sfc_MnInOverPlan_B.AdoQry_Main,Frm_Sfc_MnInOverPlan_B.AdoQry_Tmp,
FwhCode,FWhPosition,
Frm_Sfc_MnInOverPlan_B.AdoQry_Main.fieldbyname('ItemCode').asstring,
'MoInQty',strtofloat(Edt_MoInQTy.text),True)then Abort;
try
Lbl_MoNoFinishQty.Caption:=floattostr(strtofloat(Lbl_MoQty.Caption)-strtofloat(Lbl_MoRealInQty.Caption)-strtofloat(Edt_MoInQTy.Text));
except
DispInfo('输入数量有误,请检查!',1);
Edt_MoInQTy.SetFocus;
end;
end;
procedure TFrm_Sfc_MnInOverPlan_D.btn_okClick(Sender: TObject);
begin
inherited;
Max_ind:=Max_ind+1;
Edt_MoLineNo.Text:=inttostr(Max_ind);
Edt_MoLineNo.Repaint;
end;
procedure TFrm_Sfc_MnInOverPlan_D.FormShow(Sender: TObject);
begin
inherited;
If not (Add) then
begin
Edt_MoLineNO.Enabled:=False;
ExtEdt_ItemCode.Enabled:=False;
SetFocus_Control:=Edt_MoInQty;
end
Else
begin
Edt_MoLineNO.Enabled:=False;
ExtEdt_ItemCode.Enabled:=True;
SetFocus_Control:=ExtEdt_ItemCode;
end;
end;
procedure TFrm_Sfc_MnInOverPlan_D.ExtEdt_ItemCodeExit(Sender: TObject);
begin
inherited;
InOutItemCodeCheck(sender);
ItemCodeCheck(Sender);
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.text:=' select ItemName from Item '
+' where ItemCode='''+Trim(ExtEdt_ItemCode.text)+''''
+' and ItemUsable=1 and ItemType in (0,2)';
open;
Lbl_ItemName.text:=fieldbyname('ItemName').asstring;
end;
if AdoQry_Maintain.locate('MoLineNo;ItemCode',varArrayOf([Edt_MoLineNo.text,Trim(ExtEdt_ItemCode.text)]),[]) then
begin
if AdoQry_Maintain.fieldbyname('MoRealInQty').asfloat<AdoQry_Maintain.fieldbyname('MoQty').asfloat then
begin
DispInfo('先正常入库再超订单入库!',3);
abort;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -