📄 sfc_mnin_b.pas
字号:
'Values('''+Billno+''','+
''''+getCode(Cmbx_WhCode.text)+''','+
''''+Trim(medt_Date.text)+''','+
''''+copy(medt_Date.text,1,7)+''','+
''''+getCode(FDeptCode)+''','+
''''+FMoNo+''','+
''''+BillTypeCode+''','+
''''+UserCode+''','+
''''+userCode+''','+
''''+getCode(Cmbx_Position.text)+''','+
''''+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
AdoQry_tmp.Close;
AdoQry_tmp.SQL.Text:='select IScheck from Item where ItemCode='''+AdoQry_Main.fieldbyname('ItemCode').asstring+'''';
AdoQry_tmp.open;
If ((AdoQry_Main.fieldbyname('MoInQty').AsFloat<>0) and (AdoQry_tmp.fieldbyname('IScheck').asinteger<>1)) or
((AdoQry_Main.fieldbyname('MoInQty').AsFloat<0) and (AdoQry_tmp.fieldbyname('IScheck').asinteger=1))then
begin
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.sql.Add('insert InvInBillline'+
'(InvBillid,'+
'InvBilllineno,'+
'MoNo,'+
'MoLineNo,'+
'ItemCode,'+
'BillLineRemArk,'+
'InvBillSfcqty)'+
'Values('+Billid+','+
inttostr(M+1)+','+
''''+FMoNo+''','+
''''+fieldbyname('MoLineNo').AsString+''','+
''''+fieldbyname('ItemCode').asstring+''','+
''''+fieldbyname('BillLineRemArk').asstring+''','+
fieldbyname('MoInqty').asstring+')');
AdoQry_tmp.ExecSQL;
end;
next;
end;
end;
AdoQry_Main.Connection.CommitTrans;
edt_Billno.text:=Billno;
Act_Save.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;
act_auto.Enabled:=False;
Cmbox_Shift.Enabled:=False;
AdoQry_Main.First;
end;
procedure TFrm_Sfc_MnIn_B.Cmbx_WhCodeExit(Sender: TObject);
begin
inherited;
If cmbx_WhCode.Text='' then
begin
DispInfo('请选择一个仓库!',1);
Cmbx_WhCode.SetFocus;
Abort;
end;
end;
procedure TFrm_Sfc_MnIn_B.Cmbx_PositionExit(Sender: TObject);
begin
inherited;
If cmbx_Position.Text='' then
begin
DispInfo('请选择一个货位!',1);
Abort;
end;
end;
procedure TFrm_Sfc_MnIn_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_MnIn_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_MnIn_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_MnIn_B.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
{ with AdoQry_Tmp do
begin
Close;
sql.text:='update Mo '+
' set MORemArk='''+Edt_Memo.text+''''+
' where MONO='''+FMONO+'''';
execsql;
end;
with Frm_Sfc_MnIn.AdoQry_Main do
begin
edit;
fieldbyname('MoremArk').asstring:=Edt_Memo.text;
post;
end;}
end;
procedure TFrm_Sfc_MnIn_B.Act_QuitExecute(Sender: TObject);
begin
if not AdoQry_Main.isempty then
if act_Save.Enabled=True then
if DispInfo('数据发生改变,是否保存?',2)='y' then
act_Save.OnExecute(sender);
inherited;
end;
procedure TFrm_Sfc_MnIn_B.Edt_MemoChange(Sender: TObject);
begin
inherited;
//act_Save.Enabled:=True;
end;
procedure TFrm_Sfc_MnIn_B.MEdt_DateChange(Sender: TObject);
begin
inherited;
//act_Save.Enabled:=True;
end;
function TFrm_Sfc_MnIn_B.CheckAllSame:boolean;
{var
I:integer;
Temp,Temp1:real;
begin
AdoQry_Main.First;
Temp:=AdoQry_Main.fieldbyname('MoInQty').asfloat;
Temp1:=Temp;
for i:=0 to AdoQry_Main.RecordCount-1 do
with AdoQry_Main do
begin
Temp:=Temp*fieldbyname('MoInQty').asfloat;
if Temp<0 then
begin
Result:=False;
exit;
end;
Temp:=Temp1;
next;
end;
Result:=True;
end;}
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_MnIn_B.FormActivate(Sender: TObject);
begin
inherited;
TlBtn_Delete.Action:=act_auto;
TlBtn_Locate.Action:=act_locate;
ToolButton6.action:=Act_Order;
end;
procedure TFrm_Sfc_MnIn_B.Act_autoExecute(Sender: TObject);
var
i:integer;
begin
inherited;
with AdoQry_Main do
begin
First;
for i:=0 to RecordCount-1 do
begin
edit;
if AdoQry_Main.fieldbyname('MoNoFinishQty').AsFloat>0 then
fieldbyname('MoInQty').asfloat:=
AdoQry_Main.fieldbyname('MoNoFinishQty').AsFloat
else
fieldbyname('MoInQty').asfloat:=0;
post;
next;
end;
end;
AdoQry_Main.First;
end;
procedure TFrm_Sfc_MnIn_B.refreshall;
begin
//刷新Query和其它控件的数据
SelectFromSQL:='select MoLine.MoNo,MoLine.MoLineNo,MoLine.ItemCode,'+
' Item.ItemName,Item.IScheck,'+
' Round(MoLine.MoQty,0) MoQty,MoLine.MoLineDate,MoLine.MoNoFinishQty,'+
' MoLine.BackFlush,'+
' Item.Wh_EmployeeCode+'' ''+Employee.EmployeeName as Wh_EmployeeCode,'+
' MoLine.MoRealInQty,MoLine.MoInQty,MoLine.BillLineRemArk '+
' 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)+''' ';
ConditionUserDefine:='(round(MoLine.MoQty*'+floattostr(1+strtofloat(Overqtydeny_Percent)/100)+',0)-MoLine.MoRealInQty>=0) ';
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 ';
OrderByFields:='MoLineNo,MoLineDate,ItemCode';
GetData;
end;
procedure TFrm_Sfc_MnIn_B.Act_OrderExecute(Sender: TObject);
begin
inherited;
//
end;
procedure TFrm_Sfc_MnIn_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_MnIn_B.cmbx_WhEmployeeChange(Sender: TObject);
begin
inherited;
refreshall;
end;
function TFrm_Sfc_MnIn_B.InitwhposIfSpec: integer;
var
i:integer;
Str:string;
Ado_tmp:TAdoQuery;
begin
if FMOSpecial then
begin
Ado_tmp:=TAdoQuery.Create(nil);
Ado_tmp.Connection:=AdoQry_Main.Connection;
Ado_tmp.SQL.text:='select WhPositionCode '+
' from WhPosition '+
' where WHCode='''+getCode(Cmbx_WhCode.Text)+''' and '+
' WhPositionType=2';
Ado_tmp.Open;
Str:=Ado_tmp.fieldbyname('WhPositionCode').asstring;
For i:=0 to Cmbx_Position.Items.Count-1 do
if getCode(Cmbx_Position.Items[i])=Trim(str) then
begin
Result:=i;
exit;
end;
end
else Result:=0;
end;
procedure TFrm_Sfc_MnIn_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_MnIn_B.DBGridEhGetCellParams(Sender: TObject;
Column: TColumnEh; AFont: TFont; var Background: TColor;
State: TGridDrawState);
begin
inherited;
If AdoQry_Main.fieldbyname('BackFlush').asinteger=1 then
begin
AFont.color:=clBlue;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -