📄 sfc_mninoverplan_b.pas
字号:
unit Sfc_MnInOverPlan_B;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Inner, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,dbGrids,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, Base_Outer, DBCtrls, Mask, jpeg;
Type
TFrm_Sfc_MnInOverPlan_B = Class(TFrm_Base_Outer)
Label3: TLabel;
Label2: TLabel;
Label4: TLabel;
AdoQry_MainMoLineNo: TIntegerField;
AdoQry_MainItemCode: TStringField;
AdoQry_MainItemName: TStringField;
AdoQry_MainMoQty: TFloatField;
AdoQry_MainMoLineDate: TDateTimeField;
AdoQry_MainMoNoFinishQty: TFloatField;
AdoQry_MainMoRealInQty: TFloatField;
AdoQry_MainMoInQty: TFloatField;
Lbl_MoNo: TLabel;
DBText1: TDBText;
Cmbx_WhCode: TComboBox;
Label5: TLabel;
Label6: TLabel;
Cmbx_Position: TComboBox;
Edt_Memo: TEdit;
Label9: TLabel;
Label8: TLabel;
Lbl_Dept: TLabel;
Label7: TLabel;
MEdt_Date: TMaskEdit;
Edt_BillNo: TEdit;
Label10: TLabel;
Label1: TLabel;
cmbx_WhEmployee: TComboBox;
AdoQry_Mainwh_EmployeeCode: TStringField;
Cmbox_Shift: TComboBox;
AdoQry_MainEmployeeflag: TStringField;
procedure DBGridEhKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Act_DeleteExecute(Sender: TObject);
procedure Cmbx_WhCodeChange(Sender: TObject);
procedure Act_SaveExecute(Sender: TObject);
procedure Cmbx_WhCodeExit(Sender: TObject);
procedure Cmbx_PositionExit(Sender: TObject);
procedure DateCheck(Sender: TObject);
procedure Act_PreviewExecute(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Act_PrintExecute(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure AdoQry_MainAfterInsert(DataSet: TDataSet);
procedure AdoQry_MainAfterPost(DataSet: TDataSet);
procedure cmbx_WhEmployeeChange(Sender: TObject);
procedure AdoQry_MainBeforePost(DataSet: TDataSet);
procedure Cmbx_PositionChange(Sender: TObject);
private
Overqtydeny_Percent:string;
FMoNo,FDeptCode,FShift,HasNegative:string;
BillTypeCode :String;
FMOSpecial :Boolean; //标志是否是独立订单
function CheckAllSame:boolean;
procedure FindItemIndex(Shift:string);
procedure refreshall;
procedure InitCmbx_Position(WhCode :String);
procedure InitCmbX_WhEmployee(WhCode:String);
{ Private declarations }
protected
function SetDeleteSql:String;OverRide;
public
procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);OverRide;
procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,FrmParam5,FrmParam6:String);Override;
{ Public declarations }
end;
var
Frm_Sfc_MnInOverPlan_B: TFrm_Sfc_MnInOverPlan_B;
implementation
uses Sfc_MnInOverPlan_D,Sys_Global,Inv_Global;
{$R *.DFM}
{ TFrm_Sfc_MnIn }
procedure TFrm_Sfc_MnInOverPlan_B.InitForm(AdOConnection: TAdOConnection;
ReadOnly: Boolean);
begin
inherited;
with DBGridEh do
begin
options:=options+[dgEditing]-[dgRowselect];
end;
Tlbtn_Order.Action:=Act_Save;
Lbl_MoNo.Caption:=FMono;
Medt_Date.Text:=DateToStr(Date());
Lbl_Dept.Caption:=FDeptCode;
CmBx_WhCode.clear;
with AdoQry_tmp do
begin
Close;
// sql.text:= 'select WhCode+'' ''+WhName CodeName from Warehouse where PriceType=1 ';
sql.text:='Select WhCode+'' ''+WhName CodeName from Warehouse ';
open;
while not Eof do
begin
cmbx_WhCode.Items.Add(fieldbyname('CodeName').asstring);
Next;
end;
Close;
sql.text:='select MrpParamValueN '+
' from MrpParam '+
'where MrpParamCode=''Overqtydeny_Percent''';
open;
Overqtydeny_Percent:=fieldbyname('MrpParamValueN').asstring;
end;
cmbx_WhCode.ItemIndex:=0;
InitCmbx_Position(GetCode(Cmbx_WhCode.Text));
InitCmbX_WhEmployee(GetCode(Cmbx_WhCode.Text));
refreshall;
Frm_Sys_Detail:=TFrm_Sfc_MnInOverPlan_D.Create(Application);
Frm_Sys_Detail.SetFormParam(FMono,FDeptCode,FShift,HasNegative,getCode(Cmbx_WhCode.text),getCode(Cmbx_Position.text));
InitShiftCmBx(AdoQry_Tmp,Cmbox_Shift,True);
FindItemIndex(FShift);
end;
procedure TFrm_Sfc_MnInOverPlan_B.InitCmbx_Position(WhCode:String);
begin
Cmbx_Position.clear;
With AdoQry_Tmp do
begin
Close;
Sql.clear;
If (not FMOSpecial) then
Sql.Add(' select WhPositionCode,WhPositionName '+
' from WhPosition '+
' where WHCode='''+WhCode+''''+
' and WhPositionType<>1'+
' and BackFlushWhP=0 '+
' Order by WhPositionCode ')
Else
Sql.Add(' select WhPositionCode,WhPositionName '+
' from WhPosition '+
' where WHCode='''+WhCode+''''+
' and WhPositionType=2 '+
' Order by WhPositionCode ');
Open;
if not Eof then
begin
First;
while not Eof do
begin
Cmbx_Position.Items.Add(fieldbyname('WhPositionCode').AsString+' '+fieldbyname('WhPositionName').asstring);
Next;
end;
end;
end;
cmbx_Position.Itemindex:=0;
end;
procedure TFrm_Sfc_MnInOverPlan_B.DBGridEhKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
if key=vk_return then keybd_event(Vk_tab,Vk_tab,0,0);
end;
function TFrm_Sfc_MnInOverPlan_B.SetDeleteSql: String;
begin
Result:='Delete from MoLine '+
' where MoNo='''+Lbl_MoNo.Caption+''' '+
' and MoLineNo='+AdoQry_Main.fieldbyname('MoLineNo').AsString;
end;
procedure TFrm_Sfc_MnInOverPlan_B.Act_DeleteExecute(Sender: TObject);
begin
If (AdoQry_Main.fieldbyname('MoQty').AsFloat<>0) then
begin
DispInfo('订单中存在的记录不允许删除!',1);
Abort;
end;
if AdoQry_Main.fieldbyname('MoLineNo').AsString='' then
begin
DispInfo('没有记录可删除!',1);
Abort;
end;
With AdoQry_Tmp do
begin
Close;
Sql.clear;
Sql.Add('Select Count(*) As RecCount from MoLine '+
' Where MoNo='''+FMoNo+''''+
' and MoLineNo='+AdoQry_Main.fieldbyname('MoLineNo').AsString);
Open;
If fieldbyname('RecCount').AsInteger>=1 then
begin
DispInfo('不是新增的记录,不允许删除!',1);
Abort;
end;
end;
AdoQry_Main.Delete;
// inherited;
end;
procedure TFrm_Sfc_MnInOverPlan_B.SetFormParam(FrmParam1, FrmParam2,
FrmParam3, FrmParam4, FrmParam5, FrmParam6: String);
begin
FMoNo:=FrmParam1;
FDeptCode:=FrmParam2;
FShift:=FrmParam3;
HasNegative:=FrmParam4;
BillTypeCode:=FrmParam5;
IF FrmParam6='1' then
FMOSpecial:=True
Else
FMOSpecial:=False;
end;
procedure TFrm_Sfc_MnInOverPlan_B.Cmbx_WhCodeChange(Sender: TObject);
begin
inherited;
InitCmbx_Position(GetCode(Cmbx_WhCode.Text));
InitCmbx_WhEmployee(GetCode(Cmbx_WhCode.Text));
refreshall;
Frm_Sys_Detail.SetFormParam(FMono,FDeptCode,FShift,HasNegative,getCode(Cmbx_WhCode.text),getCode(Cmbx_Position.text));
end;
procedure TFrm_Sfc_MnInOverPlan_B.Act_SaveExecute(Sender: TObject);
var FlagFloat :Double;
i,m: integer; //循环控制变量
BeforeSaveError :Boolean;
Billno,Billid :String;
begin
inherited;
BeforeSaveError:=True;
Cmbx_WhCodeExit(Cmbx_WhCode);
Cmbx_PositionExit(Cmbx_Position);
DateCheck(Medt_Date);
if AdoQry_Main.RecordCount<1 then
begin
DispInfo('没有记录,不允许保存!',1);
abort;
end;
if AdoQry_Main.state<>dsBrowse then
AdoQry_Main.post;
AdoQry_Main.DisableControls;
if not CheckAllSame then
begin
DispInfo('所有单据行不能正负异号!',1);
AdoQry_Main.EnableControls;
DBGridEh.SetFocus;
abort;
end;
AdoQry_Main.EnableControls;
AdoQry_Main.Connection.beginTrans;
try
BeforeSaveError:=False;
Billno:=getno(AdoQry_Main.Connection,
getCode(Cmbx_WhCode.Text)+'R'+Formatdatetime('yymm',StrToDate(Medt_Date.Text)),
'InvBill');
With AdoQry_Tmp do
begin
Close;
Sql.clear;
AdoQry_tmp.sql.Add('insert InvInBill'+
'(InvBillno,'+
'whCode,'+
'InvBilldate,'+
'InvBillMonth,'+
'DeptCode,'+
'MoNo,'+
'BillTypeCode,'+
'EmployeeCode,'+
'Sfc_EmployeeCode,'+
'WhPositionCode,'+
'OverPlan,'+
'wh_EmployeeCode2,'+
'shiftType,'+
'InvBillremArk)'+
'Values('''+Billno+''','+
''''+getCode(Cmbx_WhCode.text)+''','+
''''+Trim(medt_Date.text)+''','+
''''+copy(medt_Date.text,1,7)+''','+
''''+getCode(FDeptCode)+''','+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -