📄 sfc_enter_mounitmnrequest.pas
字号:
procedure TFrm_Sfc_Enter_MoUnitMnRequest.DBGridEhGetCellParams(Sender: TObject;
Column: TColumnEh; AFont: TFont; var Background: TColor;
State: TGridDrawState);
begin
inherited;
//DBGRID中的颜色控制,如果结构虚项,则红色,替代虚项,蓝色
if (gdSelected in State)or(gdFocused in State) then
begin
Background:=clNavy;
AFont.Color:=clWindow;
end
end;
procedure TFrm_Sfc_Enter_MoUnitMnRequest.cmbbx_WhEmployeeExit(Sender: TObject);
begin
inherited;
showdbgrid;
end;
procedure TFrm_Sfc_Enter_MoUnitMnRequest.initprint;
begin
//初始化未保存打印的打印报表
{ Frm_Sfc_MnOut_NotSave_P.QLWHCode.Caption:=cmbbx_WhCode.text;
Frm_Sfc_MnOut_NotSave_P.QLWhPositionCode.Caption:=cmbbx_WhPositionCode.text;
Frm_Sfc_MnOut_NotSave_P.qlWhEmployee.Caption:=cmbbx_WhEmployee.text;
Frm_Sfc_MnOut_NotSave_P.QLInvBillNo.Caption:=Extedt_Billno.text;
Frm_Sfc_MnOut_NotSave_P.QLDeptCode.Caption:=lbl_Dept.Caption;
Frm_Sfc_MnOut_NotSave_P.QLshifttime.Caption:=cmbbx_Shift.text;
Frm_Sfc_MnOut_NotSave_P.QLInvBillDate.Caption:=medt_Date.text;
Frm_Sfc_MnOut_NotSave_P.QLMONo.Caption:=lbl_Mono.Caption;
Frm_Sfc_MnOut_NotSave_P.QLMoLineNo.Caption:=lbl_MoLineno.Caption;
Frm_Sfc_MnOut_NotSave_P.qlItemCodeName.Caption:=lbl_Item.Caption;
Frm_Sfc_MnOut_NotSave_P.QLWH_EmployeeCodea.Caption:='';
Frm_Sfc_MnOut_NotSave_P.QLWH_EmployeeCode.Caption:='';
Frm_Sfc_MnOut_NotSave_P.qlmemo.Caption:=Extedt_memo.text;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select EmployeeCode,EmployeeName from Employee where EmployeeCode='''+userCode+'''');
open;
end;
Frm_Sfc_MnOut_NotSave_P.QLEmployeeCodeA.Caption:=AdoQry_tmp.fieldbyname('EmployeeCode').asstring+' '+AdoQry_tmp.fieldbyname('EmployeeName').asstring;
Frm_Sfc_MnOut_NotSave_P.QLEmployeeCode.Caption:=AdoQry_tmp.fieldbyname('EmployeeCode').asstring+' '+AdoQry_tmp.fieldbyname('EmployeeName').asstring;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select moqty from MoLine where mono='''+lbl_Mono.Caption+''' and MoLineno='+lbl_MoLineno.Caption);
open;
end;
Frm_Sfc_MnOut_NotSave_P.qlmoqty.Caption:=AdoQry_tmp.fieldbyname('moqty').asstring;
Frm_Sfc_MnOut_NotSave_P.QuickRep1.DataSet:=AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataSet :=AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataField :='ItemCode';
Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataSet := AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataField :='moCtrlqty';
Frm_Sfc_MnOut_NotSave_P.QRExpr2.Expression:='COPY(AdoQry_Body.ItemName,1,44)';
Frm_Sfc_MnOut_NotSave_P.QRExpr3.Expression :='COPY(AdoQry_Body.ItemName,45,16)';
Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataSet :=AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataField :='UomName';
Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataSet :=AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataField :='moRequestqty';
Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataSet :=AdoQry_Body;
Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataField:='MoRealqty';
// Frm_Sfc_MnOut_NotSave_P.QRDBText3.DataSet :=AdoQry_Body;
// Frm_Sfc_MnOut_NotSave_P.QRDBText3.DataField:='BilllineremArk';
}
end;
procedure TFrm_Sfc_Enter_MoUnitMnRequest.AdoQry_BodyAfterInsert(DataSet: TDataSet);
begin
inherited;
AdoQry_Body.Cancel;
end;
procedure TFrm_Sfc_Enter_MoUnitMnRequest.DataSource1DataChange(Sender: TObject;
Field: TField);
begin
inherited;
if status='ReadOnly' then
act_Save.Enabled :=False
else
act_Save.Enabled :=True;
end;
procedure TFrm_Sfc_Enter_MoUnitMnRequest.DBGridEh1GetCellParams(Sender: TObject;
Column: TColumnEh; AFont: TFont; var Background: TColor;
State: TGridDrawState);
begin
inherited;
if TDBGridEh(Sender).DataSource.DataSet.RecNo mod 2=1 then
Background:=$f0f0f0
else
Background:=clWindow;
if (gdSelected in State)or(gdFocused in State) then
begin
Background:=clNavy;
AFont.Color:=clWindow;
end
else
begin
AFont.Color:=clBlack;
end;
end;
procedure TFrm_Sfc_Enter_MoUnitMnRequest.cmbbx_WhEmployeeChange(
Sender: TObject);
begin
inherited;
// Showdbgrid;
end;
procedure TFrm_Sfc_Enter_MoUnitMnRequest.cmbbx_ShiftChange(
Sender: TObject);
begin
inherited;
ShowDbgrid;
end;
procedure TFrm_Sfc_Enter_MoUnitMnRequest.CheckBox1Click(Sender: TObject);
var BookMArk,SqlText : String;
begin
inherited;
BookMArk := AdoQry_Body.BookmArk;
if CheckBox1.Checked then
begin
SqlText := 'select * from #MnItemList Order by ItemCode,IsTotal';
ExecuteSql(AdoQry_Body,SqlText,0);
AdoQry_Body.BookmArk := BookMArk;
Exit;
end;
SqlText := 'select * from #MnItemList where IsTotal=1';
ExecuteSql(AdoQry_Body,SqlText,0);
Try
AdoQry_Body.BookmArk := BookMArk;
except
end;
end;
procedure TFrm_Sfc_Enter_MoUnitMnRequest.AdoQry_BodyBeforeEdit(
DataSet: TDataSet);
begin
inherited;
If AdoQry_Body.fieldbyname('IsTotal').AsInteger = 0 Then Abort;
end;
procedure TFrm_Sfc_Enter_MoUnitMnRequest.Button1Click(Sender: TObject);
var SqlText : String;
TmpAdoQry : TAdoQuery;
TmpAdoQry1 : TAdoQuery;
begin
inherited;
If Act_Save.Enabled then
begin
DispInfo('请先保存数据!',3);
abort;
end;
TmpAdoQry := TAdoQuery.Create(self);
TmpAdoQry.Connection := Dbconnect;
TmpAdoQry.EnableBCD := False;
TmpAdoQry1 := TAdoQuery.Create(self);
TmpAdoQry1.Connection := Dbconnect;
TmpAdoQry1.EnableBCD := False;
Try
SqlText := 'select Distinct #MnItemList.MoNo,#MnItemList.MoLineNo,MoLine.ItemCode,Item.ItemName from #MnItemList '
+' join MoLine on (#MnItemList.MoNo=MoLine.MoNo and #MnItemList.MoLineNo=MoLine.MoLineNo) '
+' left join Item on MoLine.ItemCode=Item.ItemCode '
+' where IsTotal=0 '
+' and ThisRequestQty>0 ';
ExecuteSql(TmpAdoQry1,SqlText,0);
while Not TmpAdoQry1.Eof do
begin
SqlText := 'select #MnItemList.*,Item.ItemName from #MnItemList '
+' left join Item on #MnItemList.ItemCode=Item.ItemCode '
+' where IsTotal=0 '
+' and ThisRequestQty>0 '
+' and MoNo='+QuotedStr(TmpAdoQry1.fieldbyname('MoNo').AsString)
+' and MoLineNO='+TmpAdoQry1.fieldbyname('MoLineNO').AsString;
ExecuteSql(TmpAdoQry,SqlText,0);
Application.CreateForm(TFrm_Sfc_MnOut_NotSave_P,Frm_Sfc_MnOut_NotSave_P);
Frm_Sfc_MnOut_NotSave_P.SetFormParam('',getCode(cmbbx_WhCode.text),'0201','Print',ModuleCode,'');
Frm_Sfc_MnOut_NotSave_P.QLWHCode.Caption:=cmbbx_WhCode.text;
Frm_Sfc_MnOut_NotSave_P.QLWhPositionCode.Caption:=cmbbx_WhPositionCode.text;
Frm_Sfc_MnOut_NotSave_P.qlWhEmployee.Caption:=cmbbx_WhEmployee.text;
Frm_Sfc_MnOut_NotSave_P.QLInvBillNo.Caption:=Extedt_Billno.text;
Frm_Sfc_MnOut_NotSave_P.QLDeptCode.Caption:=Edt_Dept.Text;
Frm_Sfc_MnOut_NotSave_P.QLshifttime.Caption:=cmbbx_Shift.text;
Frm_Sfc_MnOut_NotSave_P.QLInvBillDate.Caption:=medt_Date.text;
Frm_Sfc_MnOut_NotSave_P.QLMONo.Caption:=TmpAdoQry1.fieldbyname('MoNo').AsString;
Frm_Sfc_MnOut_NotSave_P.QLMoLineNo.Caption:=TmpAdoQry1.fieldbyname('MoLineNo').AsString;
Frm_Sfc_MnOut_NotSave_P.qlItemCodeName.Caption:=TmpAdoQry1.fieldbyname('ItemCode').AsString+' '+TmpAdoQry1.fieldbyname('ItemName').AsString;
Frm_Sfc_MnOut_NotSave_P.QLWH_EmployeeCodea.Caption:='';
Frm_Sfc_MnOut_NotSave_P.QLWH_EmployeeCode.Caption:='';
Frm_Sfc_MnOut_NotSave_P.qlmemo.Caption:=Extedt_memo.text;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select EmployeeCode,EmployeeName from Employee where EmployeeCode='''+userCode+'''');
open;
end;
Frm_Sfc_MnOut_NotSave_P.QLEmployeeCodeA.Caption:=AdoQry_tmp.fieldbyname('EmployeeCode').asstring+' '+AdoQry_tmp.fieldbyname('EmployeeName').asstring;
Frm_Sfc_MnOut_NotSave_P.QLEmployeeCode.Caption:=AdoQry_tmp.fieldbyname('EmployeeCode').asstring+' '+AdoQry_tmp.fieldbyname('EmployeeName').asstring;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select moqty from MoLine where mono='''+TmpAdoQry1.fieldbyname('MoNo').AsString+''' and MoLineno='+TmpAdoQry1.fieldbyname('MoLineNo').AsString);
open;
end;
Frm_Sfc_MnOut_NotSave_P.qlmoqty.Caption:=AdoQry_tmp.fieldbyname('moqty').asstring;
Frm_Sfc_MnOut_NotSave_P.QuickRep1.DataSet:=TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataSet :=TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataField :='ItemCode';
Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataSet := TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataField :='moCtrlqty';
// Frm_Sfc_MnOut_NotSave_P.QRExpr2.Expression:='COPY(TmpAdoQry.ItemName,1,44)';
// Frm_Sfc_MnOut_NotSave_P.QRExpr3.Expression :='COPY(TmpAdoQry.ItemName,45,16)';
Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataSet := TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataField :='UomName';
Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataSet := TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataField :='ThisRequestqty';
Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataSet := TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataField:='MoRealqty';
// Frm_Sfc_MnOut_NotSave_P.QRDBText3.DataSet :=TmpAdoQry;
// Frm_Sfc_MnOut_NotSave_P.QRDBText3.DataField:='RemArk';
Frm_Sfc_MnOut_NotSave_P.SetDBConnect(AdoQry_tmp.Connection);
Frm_Sfc_MnOut_NotSave_P.release;
TmpAdoQry1.Next;
end;
Finally
if Assigned(TmpAdoQry) then TmpAdoQry.free;
if Assigned(TmpAdoQry1) then TmpAdoQry1.free;
end;
end;
procedure TFrm_Sfc_Enter_MoUnitMnRequest.Button2Click(Sender: TObject);
var SqlText : String;
TmpAdoQry : TAdoQuery;
TmpAdoQry1 : TAdoQuery;
begin
inherited;
If Act_Save.Enabled then
begin
DispInfo('请先保存数据!',3);
abort;
end;
TmpAdoQry := TAdoQuery.Create(self);
TmpAdoQry.Connection := Dbconnect;
TmpAdoQry.EnableBCD := False;
TmpAdoQry1 := TAdoQuery.Create(self);
TmpAdoQry1.Connection := Dbconnect;
TmpAdoQry1.EnableBCD := False;
Try
SqlText := 'select Distinct #MnItemList.MoNo,#MnItemList.MoLineNo,MoLine.ItemCode,Item.ItemName from #MnItemList '
+' join MoLine on (#MnItemList.MoNo=MoLine.MoNo and #MnItemList.MoLineNo=MoLine.MoLineNo) '
+' left join Item on MoLine.ItemCode=Item.ItemCode '
+' where IsTotal=0 '
+' and ThisRequestQty>0 ';
ExecuteSql(TmpAdoQry1,SqlText,0);
while Not TmpAdoQry1.Eof do
begin
SqlText := 'select #MnItemList.*,Item.ItemName from #MnItemList '
+' left join Item on #MnItemList.ItemCode=Item.ItemCode '
+' where IsTotal=0 '
+' and ThisRequestQty>0 '
+' and MoNo='+QuotedStr(TmpAdoQry1.fieldbyname('MoNo').AsString)
+' and MoLineNO='+TmpAdoQry1.fieldbyname('MoLineNO').AsString;
ExecuteSql(TmpAdoQry,SqlText,0);
Application.CreateForm(TFrm_Sfc_MnOut_NotSave_P,Frm_Sfc_MnOut_NotSave_P);
Frm_Sfc_MnOut_NotSave_P.SetFormParam('',getCode(cmbbx_WhCode.text),'0201','Preview',ModuleCode,'');
Frm_Sfc_MnOut_NotSave_P.QLWHCode.Caption:=cmbbx_WhCode.text;
Frm_Sfc_MnOut_NotSave_P.QLWhPositionCode.Caption:=cmbbx_WhPositionCode.text;
Frm_Sfc_MnOut_NotSave_P.qlWhEmployee.Caption:=cmbbx_WhEmployee.text;
Frm_Sfc_MnOut_NotSave_P.QLInvBillNo.Caption:=Extedt_Billno.text;
Frm_Sfc_MnOut_NotSave_P.QLDeptCode.Caption:=Edt_Dept.Text;
Frm_Sfc_MnOut_NotSave_P.QLshifttime.Caption:=cmbbx_Shift.text;
Frm_Sfc_MnOut_NotSave_P.QLInvBillDate.Caption:=medt_Date.text;
Frm_Sfc_MnOut_NotSave_P.QLMONo.Caption:=TmpAdoQry1.fieldbyname('MoNo').AsString;
Frm_Sfc_MnOut_NotSave_P.QLMoLineNo.Caption:=TmpAdoQry1.fieldbyname('MoLineNo').AsString;
Frm_Sfc_MnOut_NotSave_P.qlItemCodeName.Caption:=TmpAdoQry1.fieldbyname('ItemCode').AsString+' '+TmpAdoQry1.fieldbyname('ItemName').AsString;
Frm_Sfc_MnOut_NotSave_P.QLWH_EmployeeCodea.Caption:='';
Frm_Sfc_MnOut_NotSave_P.QLWH_EmployeeCode.Caption:='';
Frm_Sfc_MnOut_NotSave_P.qlmemo.Caption:=Extedt_memo.text;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select EmployeeCode,EmployeeName from Employee where EmployeeCode='''+userCode+'''');
open;
end;
Frm_Sfc_MnOut_NotSave_P.QLEmployeeCodeA.Caption:=AdoQry_tmp.fieldbyname('EmployeeCode').asstring+' '+AdoQry_tmp.fieldbyname('EmployeeName').asstring;
Frm_Sfc_MnOut_NotSave_P.QLEmployeeCode.Caption:=AdoQry_tmp.fieldbyname('EmployeeCode').asstring+' '+AdoQry_tmp.fieldbyname('EmployeeName').asstring;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select moqty from MoLine where mono='''+TmpAdoQry1.fieldbyname('MoNo').AsString+''' and MoLineno='+TmpAdoQry1.fieldbyname('MoLineNo').AsString);
open;
end;
Frm_Sfc_MnOut_NotSave_P.qlmoqty.Caption:=AdoQry_tmp.fieldbyname('moqty').asstring;
Frm_Sfc_MnOut_NotSave_P.QuickRep1.DataSet:=TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataSet :=TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText10.DataField :='ItemCode';
Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataSet := TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText1.DataField :='moCtrlqty';
// Frm_Sfc_MnOut_NotSave_P.QRExpr2.Expression:='COPY(TmpAdoQry.ItemName,1,44)';
// Frm_Sfc_MnOut_NotSave_P.QRExpr3.Expression :='COPY(TmpAdoQry.ItemName,45,16)';
Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataSet := TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText12.DataField :='UomName';
Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataSet := TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText15.DataField :='ThisRequestqty';
Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataSet := TmpAdoQry;
Frm_Sfc_MnOut_NotSave_P.QRDBText2.DataField:='MoRealqty';
// Frm_Sfc_MnOut_NotSave_P.QRDBText3.DataSet :=TmpAdoQry;
// Frm_Sfc_MnOut_NotSave_P.QRDBText3.DataField:='RemArk';
Frm_Sfc_MnOut_NotSave_P.SetDBConnect(AdoQry_tmp.Connection);
Frm_Sfc_MnOut_NotSave_P.release;
TmpAdoQry1.Next;
end;
Finally
if Assigned(TmpAdoQry) then TmpAdoQry.free;
if Assigned(TmpAdoQry1) then TmpAdoQry1.free;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -