📄 sfc_mninoverplan_b.pas
字号:
''''+FMoNo+''','+
''''+BillTypeCode+''','+
''''+UserCode+''','+
''''+userCode+''','+
''''+getCode(Cmbx_Position.text)+''','+
'1,'+
''''+getCode(Cmbx_WhEmployee.text)+''','+
''''+Cmbox_Shift.text+''','+
''''+Edt_memo.text+''')');
AdoQry_tmp.execsql;
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add(' select @@IDENTITY as Billid ');
AdoQry_tmp.open;
Billid:=AdoQry_tmp.fieldbyname('Billid').asstring;
end;
with AdoQry_Main do
begin
First;
for M:=0 to recordCount-1 do
begin
//增加InvBillLINE
If AdoQry_Main.fieldbyname('MoInQty').AsFloat<>0 then
begin
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add('insert InvInBillline'+
'(InvBillid,'+
'InvBilllineno,'+
'MoNo,'+
'MoLineNo,'+
'ItemCode,'+
'InvBillSfcqty)'+
'Values('+Billid+','+
inttostr(M+1)+','+
''''+FMoNo+''','+
''''+fieldbyname('MoLineNo').AsString+''','+
''''+fieldbyname('ItemCode').asstring+''','+
fieldbyname('MoInqty').asstring+')');
AdoQry_tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Add('Select Count(*) as RecCount From MoLine Where '+
'MONo='''+FMONo+'''and MoLineNo='+AdoQry_Main.fieldbyname('MoLineNo').AsString);
AdoQry_Tmp.Open;
If AdoQry_Tmp.fieldbyname('RecCount').Asinteger<=0 then
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.Sql.Add('Insert Into MoLine(MONO,MoLineNO,ItemCode,MoLineStatus,MoLineDATE) '+
' Values('''+FMoNo+''','+
AdoQry_Main.fieldbyname('MoLineNo').AsString+','+
''''+AdoQry_Main.fieldbyname('ItemCode').AsString+''','+
' ''6'','+
''''+ForMatDateTime('yyyy.mm.dd',Now)+''')');
AdoQry_Tmp.ExecSQL;
end;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Add('Update MoLine '+
'Set '+
'MoInQty=0 '+
'where MoNo='''+FMoNo+''''+
' and MoLineNo='+fieldbyname('MoLineNo').AsString);
AdoQry_Tmp.ExecSql;
end;
next;
end;
end;
AdoQry_Main.Connection.CommitTrans;
edt_Billno.text:=Billno;
Act_Save.Enabled:=False;
Act_DeleteLine.Enabled:=False;
Act_New.Enabled:=False;
Act_Modify.Enabled:=False;
Act_Delete.Enabled:=False;
Cmbx_WhCode.Enabled:=False;
Cmbx_Position.Enabled:=False;
DBGridEh.SetFocus;
Medt_Date.enabled:=False;
Edt_BillNo.Enabled:=False;
Edt_MeMo.Enabled:=False;
DbGridEh.ReadOnly:=True;
cmbx_WhEmployee.enabled:=False;
Except
begin
AdoQry_Main.Connection.RollBackTrans;
if not BeforeSaveError then
DispInfo(' 存盘不成功,请稍后再试! ',1);
end;
end;
act_Save.Enabled:=False;
Cmbox_Shift.enabled:=False;
end;
procedure TFrm_Sfc_MnInOverPlan_B.Cmbx_WhCodeExit(Sender: TObject);
begin
inherited;
If cmbx_WhCode.Text='' then
begin
DispInfo('请选择一个仓库!',1);
Cmbx_WhCode.SetFocus;
Abort;
end;
end;
procedure TFrm_Sfc_MnInOverPlan_B.Cmbx_PositionExit(Sender: TObject);
begin
inherited;
If cmbx_Position.Text='' then
begin
DispInfo('请选择一个货位!',1);
Abort;
end;
end;
procedure TFrm_Sfc_MnInOverPlan_B.DateCheck(Sender: TObject);
begin
inherited;
if not WHClsPeriodCheck(AdoQry_Tmp,GetCode(Cmbx_WhCode.Text),Copy((Medt_Date.Text),1,7)) then
begin
Medt_Date.SetFocus;
abort;
end;
end;
procedure TFrm_Sfc_MnInOverPlan_B.Act_PreviewExecute(Sender: TObject);
begin
// inherited;
BillPrint(AdoQry_Tmp.Connection,GetCode(Cmbx_WhCode.text),Edt_BillNo.text,Param2,ModuleCode,True,False,True,'');
end;
procedure TFrm_Sfc_MnInOverPlan_B.FormActivate(Sender: TObject);
begin
inherited;
// ToolButton13.left:=TlBtn_Print.left+ToolButton13.Width;
// ToolButton4.left:=ToolButton13.Left+ToolButton4.Width;
end;
procedure TFrm_Sfc_MnInOverPlan_B.Act_PrintExecute(Sender: TObject);
begin
// inherited;
BillPrint(AdoQry_Tmp.Connection,GetCode(Cmbx_WhCode.text),Edt_BillNo.text,Param2,ModuleCode,False,False,True,'');
end;
procedure TFrm_Sfc_MnInOverPlan_B.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
if not AdoQry_Main.isempty then
if (act_Save.Enabled) and (DispInfo('数据发生改变,是否保存?',2)='y') then act_Save.OnExecute(sender);
end;
procedure TFrm_Sfc_MnInOverPlan_B.AdoQry_MainAfterInsert(
DataSet: TDataSet);
begin
inherited;
act_Save.Enabled:=True;
end;
procedure TFrm_Sfc_MnInOverPlan_B.AdoQry_MainAfterPost(DataSet: TDataSet);
begin
inherited;
act_Save.Enabled:=True;
end;
procedure TFrm_Sfc_MnInOverPlan_B.refreshall;
begin
SelectFromSQL:='select MoLine.MoNo,MoLine.MoLineNo,MoLine.ItemCode,'+
' Item.ItemName,'+
' MoLine.MoQty,MoLine.MoLineDate,MoLine.MoNoFinishQty, '+
' Item.Wh_EmployeeCode,'+
' Item.Wh_EmployeeCode+'' ''+Employee.EmployeeName as EmployeeFlag, '+
' MoLine.MoRealInQty,MoLine.MoInQty '+
' from MoLine '+
' Join Mo on(Mo.MONO=MoLine.MONo) '+
' and (MO.MoNo='''+FMONo+''')'+
' Join Item On(Item.ItemCode=MoLine.ItemCode) and '+
'Item.whCode='''+getCode(Cmbx_WhCode.text)+''' ';
OrderByFields:='MoLineDate,ItemCode';
if cmbx_WhEmployee.Text<>'' then
SelectFromSQL:=SelectFromSQL+
' and Item.wh_EmployeeCode='''+getCode(Cmbx_WhEmployee.text)+''' ';
SelectFromSQL:=SelectFromSQL+' join Employee on Employee.EmployeeCode=Item.wh_EmployeeCode ';
ConditionUserDefine:=' (round(MoLine.MoQty*'+floattostr(1+strtofloat(Overqtydeny_Percent)/100)+',0)-MoLine.MoRealInQty<=0) ';
GetData;
end;
procedure TFrm_Sfc_MnInOverPlan_B.InitCmbX_WhEmployee(WhCode: String);
begin
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select distinct i.wh_EmployeeCode,e.EmployeeName '+
' from Item i,Employee e '+
' where whCode='''+whCode+''''+
' and i.wh_EmployeeCode is not null '+
' and i.wh_EmployeeCode=e.EmployeeCode '+
' Order by i.wh_EmployeeCode');
open;
cmbx_WhEmployee.clear;
cmbx_WhEmployee.Items.Add('');
if not Eof then
begin
First;
while not Eof do
begin
cmbx_WhEmployee.Items.Add(fieldbyname('wh_EmployeeCode').asstring+' '+fieldbyname('EmployeeName').asstring);
Next;
end;
cmbx_WhEmployee.Itemindex:=0;
end;
end;
end;
procedure TFrm_Sfc_MnInOverPlan_B.cmbx_WhEmployeeChange(Sender: TObject);
begin
inherited;
refreshall;
end;
function TFrm_Sfc_MnInOverPlan_B.CheckAllSame: boolean;
var
i:integer;
flag:boolean;
begin
AdoQry_Main.First;
for i:=0 to AdoQry_Main.RecordCount-1 do
begin
if AdoQry_Main.fieldbyname('MoInQty').asfloat<>0 then
begin
if AdoQry_Main.fieldbyname('MoInQty').asfloat>0 then
flag:=True
else flag:=False;
break;
end;
AdoQry_Main.next;
end;
AdoQry_Main.First;
for i:=0 to AdoQry_Main.RecordCount-1 do
begin
if AdoQry_Main.fieldbyname('MoInQty').asfloat<>0 then
begin
if ((flag) and (AdoQry_Main.fieldbyname('MoInQty').asfloat<0)) or
((not flag) and (AdoQry_Main.fieldbyname('MoInQty').asfloat>0)) then
begin
Result:=False;
exit;
end;
end;
AdoQry_Main.next;
end;
Result:=True;
end;
procedure TFrm_Sfc_MnInOverPlan_B.FindItemIndex(Shift: string);
var
I:integer;
begin
if FShift='' then exit;
for I:=0 to Cmbox_Shift.Items.Count-1 do
begin
if Cmbox_Shift.Items[i]=Fshift then
begin
Cmbox_Shift.ItemIndex:=i;
Cmbox_Shift.Refresh;
exit;
end;
end;
end;
procedure TFrm_Sfc_MnInOverPlan_B.AdoQry_MainBeforePost(DataSet: TDataSet);
begin
inherited;
if AdoQry_Main.fieldbyname('MoInQty').asstring='' then
begin
AdoQry_Main.fieldbyname('MoInQty').asstring:='0';
abort;
end;
end;
procedure TFrm_Sfc_MnInOverPlan_B.Cmbx_PositionChange(Sender: TObject);
begin
inherited;
Frm_Sys_Detail.SetFormParam(FMono,FDeptCode,FShift,HasNegative,getCode(Cmbx_WhCode.text),getCode(Cmbx_Position.text));
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -