D7wmguihua/桂华管理系统/U_ProductOrder_Ph10.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

2165 lines
70 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_ProductOrder_Ph10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses,
cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxGrid, DBClient, cxCheckBox, cxCalendar, cxSplitter,
RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport, RM_e_Xls,
Menus, cxPC, cxContainer, cxTextEdit, cxCurrencyEdit;
type
TfrmProductOrder_Ph10 = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBAdd: TToolButton;
TBEdit: TToolButton;
TBDel: TToolButton;
TBPrint: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
Label1: TLabel;
Tv1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
cxGridPopupMenu1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
Label3: TLabel;
OrderNo: TEdit;
TBExport: TToolButton;
v1OrderNo: TcxGridDBColumn;
v1JGFactoryName: TcxGridDBColumn;
v1OrdDate: TcxGridDBColumn;
v1DeliveryDate: TcxGridDBColumn;
v1OrdPerson1: TcxGridDBColumn;
v1ConNo: TcxGridDBColumn;
Order_Main: TClientDataSet;
RM1: TRMGridReport;
RMDBMain: TRMDBDataSet;
RMXLSExport1: TRMXLSExport;
v1CustomerNoName: TcxGridDBColumn;
Label4: TLabel;
CustomerNoName: TEdit;
v1MPRTCodeName: TcxGridDBColumn;
v1PRTOrderQty: TcxGridDBColumn;
PopupMenu1: TPopupMenu;
N2: TMenuItem;
ToolButton1: TToolButton;
Label2: TLabel;
JGFactoryName: TEdit;
Label5: TLabel;
OrdPerson1: TEdit;
Label6: TLabel;
PRTCF: TEdit;
Label7: TLabel;
PRTColor: TEdit;
Label8: TLabel;
PRTCodeName: TEdit;
Label9: TLabel;
ConNo: TEdit;
v1Column8: TcxGridDBColumn;
v1OrdDefStr1: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
Label10: TLabel;
PRTSpec: TEdit;
Label11: TLabel;
OrdDefStr1: TEdit;
Label12: TLabel;
PRTKZ: TEdit;
Label13: TLabel;
PRTMF: TEdit;
ToolButton2: TToolButton;
ADOQueryPrint: TADOQuery;
CDS_Print: TClientDataSet;
ToolButton3: TToolButton;
ComboBox1: TComboBox;
v1Column2: TcxGridDBColumn;
v1PRTRollNum: TcxGridDBColumn;
cxTabControl1: TcxTabControl;
ToolBar2: TToolBar;
TV2: TcxGridDBTableView;
cxGrid2Level1: TcxGridLevel;
cxGrid2: TcxGrid;
del: TToolButton;
V2Column1: TcxGridDBColumn;
V2Column2: TcxGridDBColumn;
V2Column3: TcxGridDBColumn;
V2Column4: TcxGridDBColumn;
V2Column5: TcxGridDBColumn;
phwc: TToolButton;
phok: TToolButton;
fh: TToolButton;
V2Column7: TcxGridDBColumn;
V2Column8: TcxGridDBColumn;
V2Column9: TcxGridDBColumn;
ADO_PH: TADOQuery;
DS_PH: TDataSource;
CDS_PH: TClientDataSet;
V2Column10: TcxGridDBColumn;
Panel3: TPanel;
Panel2: TPanel;
Edit1: TEdit;
Label14: TLabel;
ToolButton4: TToolButton;
v1PRTColor: TcxGridDBColumn;
V2C_Color: TcxGridDBColumn;
ToolButton5: TToolButton;
TBPrint1: TToolButton;
ADOPrint: TADOQuery;
RMDB_MD: TRMDBDataSet;
RMGridReport1: TRMGridReport;
RMXLSExport2: TRMXLSExport;
Label15: TLabel;
CRdate: TDateTimePicker;
V2Column6: TcxGridDBColumn;
V2Column11: TcxGridDBColumn;
ToolButton6: TToolButton;
v1Ssel: TcxGridDBColumn;
V2Column12: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
V2Filler: TcxGridDBColumn;
V2PHYG: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
CheckBox1: TCheckBox;
v1P_NO: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
Tbcpfh: TToolButton;
TBPrint2: TToolButton;
fRoll1: TcxCurrencyEdit;
fnum1: TcxCurrencyEdit;
Label17: TLabel;
Label16: TLabel;
V2defstr2: TcxGridDBColumn;
ToolButton7: TToolButton;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure TBFindClick(Sender: TObject);
procedure TBEditClick(Sender: TObject);
procedure TBDelClick(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure TBPrintClick(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure TBAddClick(Sender: TObject);
procedure OrderNoChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Tv1CellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure TBTPClick(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure Tv1StylesGetContentStyle(Sender: TcxCustomGridTableView;
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
out AStyle: TcxStyle);
procedure v1DeliveryDateCustomDrawCell(Sender: TcxCustomGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure OrderNoKeyPress(Sender: TObject; var Key: Char);
procedure ConNoKeyPress(Sender: TObject; var Key: Char);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure phwcClick(Sender: TObject);
procedure cxTabControl1Change(Sender: TObject);
procedure phokClick(Sender: TObject);
procedure delClick(Sender: TObject);
procedure fhClick(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure TBPrint1Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView;
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
ANewItemRecordFocusingChanged: Boolean);
procedure TbcpfhClick(Sender: TObject);
procedure TBPrint2Click(Sender: TObject);
procedure ToolButton7Click(Sender: TObject);
private
DQdate:TDateTime;
TblCprk:string;
procedure InitGrid();
procedure InitPH();
procedure InitForm();
function DelData():Boolean;
procedure InitGridFH();
procedure Query_MJ(mjid:string);
function SaveData():Boolean;
function YSData(Order_Main10:TClientDataSet):Boolean;
function SaveEjK(FNO,FID,fBCID,fCkNO:string):boolean;
procedure CreateTable();
procedure DropTable();
{ Private declarations }
public
fDParameters1:string;
FFInt,FCloth:Integer;
{ Public declarations }
end;
var
frmProductOrder_Ph10: TfrmProductOrder_Ph10;
implementation
uses
U_DataLink,U_OrderInPut,U_Fun,U_CKProductBCPKCListSel10,U_CKProductBCPKCListSel,
U_CKSMEdit;
{$R *.dfm}
procedure TfrmProductOrder_Ph10.DropTable();
var
strSQL:string;
begin
// TblCprk := '[##CP_INOut123' + trim(DCode) + IntToStr(Handle)+formatdatetime('hhnnsszzz',time) + ']';
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
strSQL := 'IF OBJECT_ID(''tempdb..' + TblCprk + ''') IS NOT NULL DROP TABLE ' + TblCprk;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
SQL.Add(strSQL);
ExecSQL;
end;
end;
procedure TfrmProductOrder_Ph10.CreateTable();
var
strSQL:string;
begin
TblCprk := '[##CP_PH' + trim(DCode) + IntToStr(Handle)+formatdatetime('hhnnsszzz',time) + ']';
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
strSQL := 'IF OBJECT_ID(''tempdb..' + TblCprk + ''') IS NOT NULL DROP TABLE ' + TblCprk + #13
+ 'CREATE TABLE ' + TblCprk + ' ('
+ 'MainID VARCHAR(20),'
+ 'subID VARCHAR(20),'
+ 'P_NO VARCHAR(20),'
+ 'BCID Varchar(20))'#13;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
SQL.Add(strSQL);
ExecSQL;
end;
end;
function TfrmProductOrder_Ph10.SaveEjK(FNO,FID,fBCID,fCkNO:string):boolean;
var
fkcID:integer;
Filler:string;
FillTime:TdateTime;
begin
result:=false;
try
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.add('Update BP_Kcid Set kcid=kcid+1');
sql.Add('select kcid from BP_Kcid');
Open;
end;
fkcID:=ADOQueryCmd.fieldbyname('kcid').AsInteger;
with CDS_PH do
begin
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from BP_InOut');
sql.Add('where 1=2 ');
open;
end;
// fkcID:=strtoint(RightBStr(trim(FNO),length(FNO)-3)+trim(FID));
ADOQueryCmd.Append;
ADOQueryCmd.FieldByName('CRNO').Value:=trim(FNO);
ADOQueryCmd.FieldByName('CRID').Value:=FID;
ADOQueryCmd.FieldByName('CRTime').Value:=formatdateTime('yyyy-MM-dd',CRdate.Date);
ADOQueryCmd.FieldByName('CKName').Value:='<27><EFBFBD>ֿ<EFBFBD>';
ADOQueryCmd.FieldByName('CRType').Value:='<27><EFBFBD><E3B6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
ADOQueryCmd.FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
ADOQueryCmd.FieldByName('mainID').Value:=trim(fieldbyname('mainID').AsString);
ADOQueryCmd.FieldByName('subID').Value:=trim(fieldbyname('subID').AsString);
ADOQueryCmd.FieldByName('MJID').Value:=trim(fieldbyname('MJID').AsString);
ADOQueryCmd.FieldByName('MJXH').Value:=trim(fieldbyname('MJXH').AsString);
ADOQueryCmd.FieldByName('CPTYPE').Value:=trim(fieldbyname('MJType').AsString);
ADOQueryCmd.FieldByName('P_Code').Value:=trim(fieldbyname('C_Code').AsString);
ADOQueryCmd.FieldByName('P_CodeName').Value:=trim(fieldbyname('C_CodeName').AsString);
ADOQueryCmd.FieldByName('P_spec').Value:=trim(fieldbyname('C_spec').AsString);
ADOQueryCmd.FieldByName('P_Color').Value:=trim(fieldbyname('C_Color').AsString);
// ADOQueryCmd.FieldByName('P_MF').Value:=fieldbyname('P_MF').AsFloat;
// ADOQueryCmd.FieldByName('P_KZ').Value:=fieldbyname('P_KZ').AsFloat;
ADOQueryCmd.FieldByName('RollNum').Value:=fieldbyname('RollNum').AsFloat;
ADOQueryCmd.FieldByName('Qty').Value:=fieldbyname('Qty').AsFloat;
ADOQueryCmd.FieldByName('QtyUnit').Value:=trim(fieldbyname('KCQtyUnit').AsString);
ADOQueryCmd.FieldByName('note').Value:='';
ADOQueryCmd.FieldByName('Filler').Value:=trim(DName);
ADOQueryCmd.FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTemp);
ADOQueryCmd.FieldByName('gangNO').Value:=trim(fieldbyname('BCgangNO').AsString);
ADOQueryCmd.FieldByName('packNo').Value:=trim(fieldbyname('packNo').AsString);
ADOQueryCmd.FieldByName('defstr2').Value:=trim(fieldbyname('defstr2').AsString);
ADOQueryCmd.FieldByName('fromMainID').Value:=trim(fCkNO);
ADOQueryCmd.FieldByName('FromSubID').Value:=trim(FbcID);
ADOQueryCmd.FieldByName('kcID').Value:=fkcID;
ADOQueryCmd.Post;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from BP_KC');
sql.Add('where 1=2 ');
open;
end;
ADOQueryCmd.Append;
ADOQueryCmd.FieldByName('kcID').Value:=fkcID;
ADOQueryCmd.FieldByName('CKName').Value:='<27><EFBFBD>ֿ<EFBFBD>';
ADOQueryCmd.FieldByName('CRType').Value:='<27><EFBFBD><E3B6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
ADOQueryCmd.FieldByName('CRNO').Value:=trim(fNo);
ADOQueryCmd.FieldByName('CRID').Value:=fID;
ADOQueryCmd.FieldByName('CRTime').Value:=formatdateTime('yyyy-MM-dd',CRdate.Date);
ADOQueryCmd.FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
ADOQueryCmd.FieldByName('mainID').Value:=trim(fieldbyname('mainID').AsString);
ADOQueryCmd.FieldByName('subID').Value:=trim(fieldbyname('subID').AsString);
ADOQueryCmd.FieldByName('MJXH').Value:=trim(fieldbyname('MJXH').AsString);
ADOQueryCmd.FieldByName('MJID').Value:=trim(fieldbyname('MJID').AsString);
ADOQueryCmd.FieldByName('CPType').Value:=trim(fieldbyname('MJType').AsString);
ADOQueryCmd.FieldByName('P_Code').Value:=trim(fieldbyname('C_Code').AsString);
ADOQueryCmd.FieldByName('P_CodeName').Value:=trim(fieldbyname('C_CodeName').AsString);
ADOQueryCmd.FieldByName('P_spec').Value:=trim(fieldbyname('C_spec').AsString);
ADOQueryCmd.FieldByName('P_Color').Value:=trim(fieldbyname('C_Color').AsString);
// ADOQueryCmd.FieldByName('P_MF').Value:=fieldbyname('P_MF').AsFloat;
// ADOQueryCmd.FieldByName('P_KZ').Value:=fieldbyname('P_KZ').AsFloat;
ADOQueryCmd.FieldByName('RollNum').Value:=fieldbyname('RollNum').AsFloat;
ADOQueryCmd.FieldByName('Qty').Value:=fieldbyname('Qty').AsFloat;
ADOQueryCmd.FieldByName('QtyUnit').Value:=trim(fieldbyname('KCQtyUnit').AsString);
ADOQueryCmd.FieldByName('kcID').Value:=fkcID;
ADOQueryCmd.Post;
end;
result:=true;
except
end;
end;
function TfrmProductOrder_Ph10.YSData(Order_Main10:TClientDataSet):Boolean;
var
CRID,YFID,Price,PriceUnit,OrderUnit,FComTaiTou,customName:String;
begin
Result:=False;
with Order_Main10 do
begin
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add('select * from YF_Money_KC where FactoryName='''+Trim('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯')+'''');
sql.Add(' and YFDefFlag1=1 ');
Open;
end;
if not ADOQueryTemp.IsEmpty then
begin
CRID:=ADOQueryTemp.fieldbyname('CRID').AsString;
end
else
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YF_Money_CRID set CRID=CRID+1');
sql.Add('select * from YF_Money_CRID ');
Open;
end;
CRID:=ADOQueryCmd.fieldbyname('CRID').AsString;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from YF_Money_KC where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('CRID').Value:=StrToInt(CRID);
FieldByName('FactoryName').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯';
FieldByName('ZdyStr1').Value:=<><D3A6><EFBFBD><EFBFBD>';
FieldByName('YFDefFlag1').Value:=1;
Post;
end;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_CR ');
sql.Add(' where MainID='''+Trim(Order_Main10.fieldbyname('MainID').AsString)+'''');
sql.Add(' and subID='''+Trim(Order_Main10.fieldbyname('subID').AsString)+'''');
sql.Add(' and YFName=''<27><><EFBFBD>۽<EFBFBD><DBBD><EFBFBD>'' ');
Open;
end;
if ADOQueryTemp.IsEmpty then
begin
if GetLSNo(ADOQueryCmd,YFID,'CF','YF_Money_CR',4,1)=False then
begin
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_CR where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('YFID').Value:=Trim(YFID);
FieldByName('YFTypeId').Value:=Trim(Order_Main10.fieldbyname('MainId').AsString);
FieldByName('CRID').Value:=StrToInt(CRID);
FieldByName('Filler').Value:=Trim(DName);
FieldByName('CRType').Value:=<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>';
FieldByName('CRFlag').Value:=<><D3A6><EFBFBD><EFBFBD>';
FieldByName('QtyFlag').Value:=1;
FieldByName('FactoryName').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯';
FieldByName('CRTime').Value:=Trim(FormatDateTime('yyyy-MM-dd',CRdate.Date));
FieldByName('YFType').Value:='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('Price').Value:=Order_Main10.fieldbyname('PRTPrice').Value;
FieldByName('HuiLv').Value:=1;
FieldByName('BZType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('QtyUnit').Value:='M';
FieldByName('ComTaiTou').Value:=Trim(Order_Main10.fieldbyname('CustomerNoName').AsString);
FieldByName('YFName').Value:='<27><><EFBFBD>۽<EFBFBD><DBBD><EFBFBD>';
FieldByName('P_CodeName').Value:=Trim(Order_Main10.fieldbyname('PRTCodeName').AsString);
FieldByName('P_Color').Value:=Trim(Order_Main10.fieldbyname('PRTColor').AsString);
FieldByName('MainId').Value:=Trim(Order_Main10.fieldbyname('Mainid').AsString);
FieldByName('subID').Value:=Trim(Order_Main10.fieldbyname('subID').AsString);
FieldByName('YFDefFlag1').Value:=1;
// FieldByName('status').Value:='1';
Post;
end;
end
else
begin
YFID:=Trim(ADOQueryTemp.fieldbyname('YFID').AsString);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('update YF_Money_CR Set Qty=(select isnull(Sum(Qty),0) from CK_BanCP_CR A ');
sql.Add(' where A.mainID=YF_Money_CR.mainID and A.subiD=YF_Money_CR.subiD and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' )');
sql.Add(',PS=(select isnull(count(*),0) from CK_BanCP_CR A ');
sql.Add(' where A.mainID=YF_Money_CR.mainID and A.subiD=YF_Money_CR.subiD and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' )');
sql.Add(',CRTime=(select min(CRTime) from CK_BanCP_CR A ');
sql.Add(' where A.mainID=YF_Money_CR.mainID and A.subiD=YF_Money_CR.subiD and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' )');
sql.Add(' where YFID='''+Trim(YFID)+'''');
ExecSQL;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YF_Money_CR Set Money=Price*Qty,BBMoney=Price*Qty*HuiLv');
sql.Add(' where YFID='''+Trim(YFID)+'''');
ExecSQL;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YF_Money_KC Set KCMoney=(select isnull(Sum(Money*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
sql.Add(',KCBBMoney=(select isnull(Sum(BBMoney*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
sql.Add(' where CRID='+CRID);
ExecSQL;
end;
end;
Result:=True;
end;
function TfrmProductOrder_Ph10.SaveData():Boolean;
var
phID:string;
begin
Result:=false;
ADOQueryCmd.Connection.BeginTrans;
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from CK_BanCP_PH ');
sql.Add('where mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and subID='+quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
execsql;
end;
with CDS_PH do
begin
DisableControls;
first;
while not eof do
begin
if fieldbyname('qty').AsFloat=0 then continue;
if GetLSNo(ADOQueryTemp,phID,'PH','CK_BanCP_PH',4,1)=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from CK_BanCP_PH ');
sql.Add('where mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and subID='+quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
open;
end;
ADOQueryCmd.Append;
ADOQueryCmd.FieldByName('phID').Value:=trim(phID);
ADOQueryCmd.FieldByName('conNo').Value:=trim(fieldbyname('conNo').AsString);
ADOQueryCmd.FieldByName('MainID').Value:=trim(Order_Main.fieldbyname('MainID').AsString);
ADOQueryCmd.FieldByName('SubID').Value:=trim(Order_Main.fieldbyname('SubID').AsString);
ADOQueryCmd.FieldByName('PMainID').Value:=trim(fieldbyname('PMainID').AsString);
ADOQueryCmd.FieldByName('PSubID').Value:=trim(fieldbyname('PSubID').AsString);
ADOQueryCmd.FieldByName('mjID').Value:=trim(fieldbyname('mjID').AsString);
ADOQueryCmd.FieldByName('CRID').Value:=trim(fieldbyname('CRID').AsString);
ADOQueryCmd.FieldByName('qtyunit').Value:=trim(fieldbyname('kcqtyunit').AsString);
ADOQueryCmd.FieldByName('qty').Value:=fieldbyname('qty').AsFloat;
ADOQueryCmd.FieldByName('Rollnum').Value:=fieldbyname('Rollnum').AsFloat;
ADOQueryCmd.FieldByName('Filler').Value:=trim(DName);
ADOQueryCmd.FieldByName('FillTime').Value:=date();
ADOQueryCmd.Post;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from CK_BanCP_KC ');
sql.Add('where mjid='+quotedstr(trim(CDS_PH.fieldbyname('mjid').AsString)));
sql.Add('and CRID='+quotedstr(trim(CDS_PH.fieldbyname('CRID').AsString)));
open;
edit;
fieldbyname('kcstatus').Value:='1';
post;
end;
next;
end;
first;
EnableControls;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from JYOrder_sub ');
sql.Add('where mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and subID='+quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
open;
edit;
fieldbyname('substatus').Value:='2';
post;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
Result:=true;
except
ADOQueryCmd.Connection.RollbackTrans;
end;
end;
procedure TfrmProductOrder_Ph10.Query_MJ(mjid:string);
begin
with ADOQueryTemp do
begin
close;
sql.Clear;
sql.Add('select A.*,Rollnum=A.kcRollNum,Qty=A.kcQty,B.mjxh,D.mainID,D.subID,D.C_Code,D.C_CodeName,D.C_Spec,F.conNo ');
sql.Add('from CK_BanCP_KC A ');
sql.Add('inner join WFB_MJJY B on B.mjid=A.mjid ');
sql.Add('inner join Contract_Sub D on D.MainId=B.mainID and D.SubId=b.subID ');
sql.Add('inner join Contract_main F on F.MainId=F.mainID ');
sql.Add('where A.mjID='+quotedstr(trim(mjid)));
open;
if IsEmpty then
begin
application.MessageBox('<27>˾<EFBFBD><CBBE>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
exit;
end
else if CDS_PH.Locate('mjid',fieldbyname('MjID').AsString,[]) then
begin
application.MessageBox('<27>˾<EFBFBD><CBBE><EFBFBD><EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD>!','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
exit;
end
else
begin
CDS_PH.Append;
CDS_PH.FieldByName('conNo').Value:=trim(fieldbyname('conNo').AsString);
CDS_PH.FieldByName('mjid').Value:=trim(fieldbyname('mjid').AsString);
// CDS_PH.FieldByName('mjxh').Value:=trim(fieldbyname('mjxh').AsString);
CDS_PH.FieldByName('C_CodeName').Value:=trim(fieldbyname('C_CodeName').AsString);
CDS_PH.FieldByName('C_Spec').Value:=trim(fieldbyname('C_Spec').AsString);
CDS_PH.FieldByName('PMainID').Value:=trim(fieldbyname('MainID').AsString);
CDS_PH.FieldByName('PSubID').Value:=trim(fieldbyname('SubID').AsString);
CDS_PH.FieldByName('kcqtyunit').Value:=trim(fieldbyname('kcqtyunit').AsString);
CDS_PH.FieldByName('kcqty').Value:=fieldbyname('kcqty').AsFloat;
CDS_PH.FieldByName('kcRollnum').Value:=fieldbyname('kcRollnum').AsFloat;
CDS_PH.FieldByName('Qty').Value:=fieldbyname('kcqty').AsFloat;
CDS_PH.FieldByName('RollNum').Value:=fieldbyname('kcRollnum').AsFloat;
CDS_PH.FieldByName('CRID').Value:=fieldbyname('CRID').AsFloat;
CDS_PH.Post;
end;
end;
end;
procedure TfrmProductOrder_Ph10.InitPH();
begin
if ADOQueryMain.Active=False then Exit;
if Order_Main.IsEmpty THEN EXIT;
try
ADO_PH.DisableControls;
with ADO_PH do
begin
Close;
sql.Clear;
Filtered:=False;
sql.Add('select A.*,B.KCKGQty,B.KCQty,B.KCQtyUnit,B.kcRollNum,B.CPType,B.C_Code,C.kckw,B.C_CodeName,B.C_Spec,B.C_Color,B.RCGangNo,E.MJType,E.apID,B.mjxh ');
sql.Add('from CK_BanCP_PH A ');
sql.Add('INNER join CK_BanCP_KC B on B.CRID=A.CRID ');
sql.Add('LEFT join CK_BanCP_CR C on C.CRID=B.CRID and CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
sql.Add('LEFT join WFB_MJJY E on A.MJID=E.MJID ');
sql.Add('where A.P_NO='+quotedstr(trim(Order_Main.fieldbyname('P_NO').asstring)));
// sql.Add('and A.subID='+quotedstr(trim(Order_Main.fieldbyname('subID').asstring)));
Open;
end;
SCreateCDS20(ADO_PH,CDS_PH);
SInitCDSData20(ADO_PH,CDS_PH);
finally
ADO_PH.EnableControls;
end;
end;
procedure TfrmProductOrder_Ph10.FormDestroy(Sender: TObject);
begin
frmProductOrder_Ph10:=nil;
end;
procedure TfrmProductOrder_Ph10.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmProductOrder_Ph10.FormCreate(Sender: TObject);
begin
cxgrid2.Align:=alClient;
// CreateTable();
//BegDate.DateTime:=SGetServerDateTime(ADOQueryTemp)-7;
//EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
DQdate:=SGetServerDate(ADOQueryTemp);
CRdate.DateTime:= DQdate;
cxTabControl1.TabIndex:=0;
del.Visible:=false;
phwc.Visible:=false;
phok.Visible:=false;
fh.Visible:=false;
Panel2.Visible:=false;
ToolButton4.Visible:=false;
TV2.OptionsData.Editing:=false;
ToolButton5.Visible:=false;
case cxTabControl1.TabIndex of
0:begin
del.Visible:=true;
phwc.Visible:=true;
Panel2.Visible:=true;
ToolButton4.Visible:=true;
TV2.OptionsData.Editing:=true;
end;
1:begin
phok.Visible:=true;
ToolButton5.Visible:=true;
end;
2:begin
fh.Visible:=true;
ToolButton5.Visible:=true;
end;
3:begin
end;
end;
application.ProcessMessages;
end;
procedure TfrmProductOrder_Ph10.TBCloseClick(Sender: TObject);
begin
Close;
if FCloth<>1 then
WriteCxGrid(self.Caption,Tv1,'<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
else
WriteCxGrid(self.Caption,Tv1,'<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmProductOrder_Ph10.InitGrid();
var
strwhere:string;
begin
strwhere:='';
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.add('exec P_View_Order_PH ') ;
sql.Add(' @begdate='''+FormatDateTime('yyyy-MM-dd',BegDate.DateTime)+''' ');
sql.Add(',@Enddate='''+FormatDateTime('yyyy-MM-dd',enddate.DateTime+1)+''' ');
sql.Add(',@P_status='+quotedstr(inttostr(cxTabControl1.TabIndex)));
sql.Add(',@WSql='+quotedstr(trim('')));
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
TBFind.Click;
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmProductOrder_Ph10.InitGridFH();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.Add('exec Order_QryList :MainId,:WSql');
Parameters.ParamByName('WSql').Value:=' and FillTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime))+''''
+' and FillTime<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.DateTime+1))+'''';
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmProductOrder_Ph10.InitForm();
begin
if FCloth<>1 then
ReadCxGrid(self.Caption,Tv1,'<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
else
ReadCxGrid(self.Caption,Tv1,'<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
BegDate.DateTime:=SGetServerDate10(ADOQueryTemp);
EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select Top 10* from JYOrder_Main Order by FillTime desc');
Open;
end;
ComboBox1.Clear;
with ADOQueryTemp do
begin
First;
while not Eof do
begin
ComboBox1.Items.Add(Trim(ADOQueryTemp.fieldbyname('OrderNO').AsString));
Next;
end;
end;
//InitGrid();
end;
procedure TfrmProductOrder_Ph10.TBFindClick(Sender: TObject);
begin
if ADOQueryMain.Active=False then Exit;
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
end;
procedure TfrmProductOrder_Ph10.TBEditClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
frmCKProductBCPKCListsel10:=TfrmCKProductBCPKCListsel10.create(self);
with frmCKProductBCPKCListsel10 do
begin
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
v2RollNum.Visible:=false;
v2RollNum.Hidden:=true;
v2Qty.Visible:=false;
v2Qty.Hidden:=true;
end;
fkeyNo:=self.Order_Main.fieldbyname('P_NO').AsString;
fType:=1;
if showmodal=1 then
begin
TBRafresh.Click;
end;
free;
end;
end;
procedure TfrmProductOrder_Ph10.TBDelClick(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
if cxTabControl1.TabIndex=0 then
begin
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update CK_BanCP_KC SET kcstatus=null ');
sql.Add('from CK_BanCP_KC A ');
sql.Add('inner join CK_BanCP_PH B on B.CRID=A.CRID ');
sql.Add('where B.P_NO='+quotedstr(trim(Order_Main.fieldbyname('P_NO').AsString)));
execsql;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from CK_BanCP_PH ');
sql.Add('where P_NO='+quotedstr(trim(Order_Main.fieldbyname('P_NO').AsString)));
execsql;
end;
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
TBRafresh.Click;
except
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
end;
end;
end;
function TfrmProductOrder_Ph10.DelData():Boolean;
begin
try
Result:=false;
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete JYOrder_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
sql.Add('delete JYOrder_Sub where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
{with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Sub where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
Open;
if IsEmpty then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete JYOrder_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
end;
end;
if Trim(Order_Main.fieldbyname('SubId').AsString)='' then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete JYOrder_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
end; }
ADOQueryCmd.Connection.CommitTrans;
Result:=True;
except
ADOQueryCmd.Connection.RollbackTrans;
Result:=False;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><ECB3A3>','<27><>ʾ',0);
end;
end;
procedure TfrmProductOrder_Ph10.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then Exit;
SelExportData(Tv1,ADOQueryMain,'<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD>б<EFBFBD>');
end;
procedure TfrmProductOrder_Ph10.TBPrintClick(Sender: TObject);
var
fPrintFile:string;
Porderno,PRTCodeName,funit:string;
i,j:Integer;
begin
if Order_Main.IsEmpty then Exit;
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from JYOrder_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
Open;
end;
if ADOQueryTemp.FieldByName('OrdFlag1').AsBoolean=True then
begin
Application.MessageBox('<27>Ѵ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴδ<D9B4>ӡ!','<27><>ʾ',0);
Exit;
end;
end;
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>.rmf' ;
with ADOQueryPrint do
begin
Close;
sql.Clear;
sql.Add('select PRTRollNum=Cast('''' as varchar(200)),PRTOrderQty=Cast('''' as varchar(200)),PRTCodeName,PRTOrderQty2=Cast('''' as varchar(200)),PRTCodeName,PRTOrderQty3=Cast('''' as varchar(200)),PRTCodeName, ');
sql.add('PRTColor=Cast('''' as varchar(200))');
sql.Add(' from JYOrder_Sub ');
sql.Add(' where 1<>1 ');
Open;
end;
SCreateCDS20(ADOQueryPrint,CDS_Print);
SInitCDSData20(ADOQueryPrint,CDS_Print);
if CDS_Print.IsEmpty=False then CDS_Print.Delete;
with ADOQueryPrint do
begin
Close;
sql.Clear;
sql.Add('select *,case when PRTRollNum<>0 then ''ƥ'' else OrderUnit end Unit ');
sql.Add(' from JYOrder_Sub ');
sql.Add(' where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
Open;
end;
ADOQueryPrint.DisableControls;
CDS_Print.DisableControls;
with ADOQueryPrint do
begin
First;
while not Eof do
begin
if CDS_Print.IsEmpty then
begin
with CDS_Print do
begin
Append;
FieldByName('PRTCodeName').Value:=ADOQueryPrint.fieldbyname('PRTCodeName').Value;
FieldByName('PRTColor').Value:=ADOQueryPrint.fieldbyname('PRTColor').Value;
FieldByName('PRTRollNum').Value:=Trim(IntToStr(ADOQueryPrint.fieldbyname('PRTRollNum').AsInteger));
// FieldByName('PRTOrderQty').Value:=Trim(FloatToStr(ADOQueryPrint.fieldbyname('PRTOrderQty').Value));
if trim(ADOQueryPrint.FieldByName('unit').AsString) ='ƥ' then
FieldByName('PRTOrderQty').Value:=trim(ADOQueryPrint.fieldbyname('PRTColor').AsString)+'/'+Trim(IntToStr(ADOQueryPrint.fieldbyname('PRTRollNum').AsInteger))
+trim(ADOQueryPrint.FieldByName('unit').AsString)
else
FieldByName('PRTOrderQty').Value:=trim(ADOQueryPrint.fieldbyname('PRTColor').AsString)+'/'+Trim(floattoStr(ADOQueryPrint.fieldbyname('PRTOrderQty').AsFloat))
+trim(ADOQueryPrint.FieldByName('unit').AsString);
Post;
i:=1;
PRTCodeName:=Trim(ADOQueryPrint.fieldbyname('PRTCodeName').AsString);
funit:=Trim(ADOQueryPrint.fieldbyname('Unit').AsString);
end;
end else
begin
if (Trim(ADOQueryPrint.fieldbyname('PRTCodeName').AsString)=PRTCodeName) and (Trim(ADOQueryPrint.fieldbyname('Unit').AsString)=funit) then
begin
if i<3 then
begin
with CDS_Print do
begin
Edit;
FieldByName('PRTColor').Value:=Trim(FieldByName('PRTColor').AsString)+','
+Trim(ADOQueryPrint.fieldbyname('PRTColor').AsString);
FieldByName('PRTRollNum').Value:=Trim(FieldByName('PRTRollNum').AsString)+','+
Trim(IntToStr(ADOQueryPrint.fieldbyname('PRTRollNum').AsInteger));
// FieldByName('PRTOrderQty').Value:=Trim(FieldByName('PRTOrderQty').AsString)+','+Trim(FloatToStr(ADOQueryPrint.fieldbyname('PRTOrderQty').Value));
if i=1 then
begin
if trim(ADOQueryPrint.FieldByName('unit').AsString) ='ƥ' then
FieldByName('PRTOrderQty2').Value:=trim(ADOQueryPrint.fieldbyname('PRTColor').AsString)+'/'+Trim(IntToStr(ADOQueryPrint.fieldbyname('PRTRollNum').AsInteger))
+trim(ADOQueryPrint.FieldByName('unit').AsString)
else
FieldByName('PRTOrderQty2').Value:=trim(ADOQueryPrint.fieldbyname('PRTColor').AsString)+'/'+Trim(floattoStr(ADOQueryPrint.fieldbyname('PRTOrderQty').AsFloat))
+trim(ADOQueryPrint.FieldByName('unit').AsString);
end;
if i=2 then
begin
if trim(ADOQueryPrint.FieldByName('unit').AsString) ='ƥ' then
FieldByName('PRTOrderQty3').Value:=trim(ADOQueryPrint.fieldbyname('PRTColor').AsString)+'/'+Trim(IntToStr(ADOQueryPrint.fieldbyname('PRTRollNum').AsInteger))
+trim(ADOQueryPrint.FieldByName('unit').AsString)
else
FieldByName('PRTOrderQty3').Value:=trim(ADOQueryPrint.fieldbyname('PRTColor').AsString)+'/'+Trim(floattoStr(ADOQueryPrint.fieldbyname('PRTOrderQty').AsFloat))
+trim(ADOQueryPrint.FieldByName('unit').AsString);
end;
Post;
end;
i:=i+1;
end else
begin
with CDS_Print do
begin
Append;
FieldByName('PRTCodeName').Value:=ADOQueryPrint.fieldbyname('PRTCodeName').Value;
FieldByName('PRTColor').Value:=ADOQueryPrint.fieldbyname('PRTColor').Value;
FieldByName('PRTRollNum').Value:=Trim(IntToStr(ADOQueryPrint.fieldbyname('PRTRollNum').AsInteger));
// FieldByName('PRTOrderQty').Value:=Trim(FloatToStr(ADOQueryPrint.fieldbyname('PRTOrderQty').Value));
if trim(ADOQueryPrint.FieldByName('unit').AsString) ='ƥ' then
FieldByName('PRTOrderQty').Value:=trim(ADOQueryPrint.fieldbyname('PRTColor').AsString)+'/'+Trim(IntToStr(ADOQueryPrint.fieldbyname('PRTRollNum').AsInteger))
+trim(ADOQueryPrint.FieldByName('unit').AsString)
else
FieldByName('PRTOrderQty').Value:=trim(ADOQueryPrint.fieldbyname('PRTColor').AsString)+'/'+Trim(floattoStr(ADOQueryPrint.fieldbyname('PRTOrderQty').AsFloat))
+trim(ADOQueryPrint.FieldByName('unit').AsString);
Post;
i:=1;
PRTCodeName:=Trim(ADOQueryPrint.fieldbyname('PRTCodeName').AsString);
funit:=Trim(ADOQueryPrint.fieldbyname('Unit').AsString);
end;
end;
end else
begin
with CDS_Print do
begin
Append;
FieldByName('PRTCodeName').Value:=ADOQueryPrint.fieldbyname('PRTCodeName').Value;
FieldByName('PRTColor').Value:=ADOQueryPrint.fieldbyname('PRTColor').Value;
FieldByName('PRTRollNum').Value:=Trim(IntToStr(ADOQueryPrint.fieldbyname('PRTRollNum').AsInteger));
if trim(ADOQueryPrint.FieldByName('unit').AsString) ='ƥ' then
FieldByName('PRTOrderQty').Value:=trim(ADOQueryPrint.fieldbyname('PRTColor').AsString)+'/'+Trim(IntToStr(ADOQueryPrint.fieldbyname('PRTRollNum').AsInteger))
+trim(ADOQueryPrint.FieldByName('unit').AsString)
else
FieldByName('PRTOrderQty').Value:=trim(ADOQueryPrint.fieldbyname('PRTColor').AsString)+'/'+Trim(floattoStr(ADOQueryPrint.fieldbyname('PRTOrderQty').AsFloat))
+trim(ADOQueryPrint.FieldByName('unit').AsString);
Post;
i:=1;
PRTCodeName:=Trim(ADOQueryPrint.fieldbyname('PRTCodeName').AsString);
funit:=Trim(ADOQueryPrint.fieldbyname('Unit').AsString);
end;
end;
end;
Next;
end;
end;
ADOQueryPrint.EnableControls;
CDS_Print.EnableControls;
if FileExists(fPrintFile) then
begin
RMVariables['customerNoName']:=Trim(Order_Main.fieldbyname('customerNoName').AsString);
RMVariables['OrderNo']:=Trim(Order_Main.fieldbyname('OrderNo').AsString);
RMVariables['Note']:=Trim(Order_Main.fieldbyname('Note').AsString);
RMVariables['FHAddress']:=Trim(Order_Main.fieldbyname('FHAddress').AsString);
RMVariables['LXFS']:=Trim(Order_Main.fieldbyname('LXFS').AsString);
RMVariables['OrdDate']:=Order_Main.fieldbyname('OrdDate').Value;
RMVariables['OrdPerson1']:=Order_Main.fieldbyname('OrdPerson1').Value;
RM1.LoadFromFile(fPrintFile);
RM1.ShowReport;
end else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>.rmf'),'<27><>ʾ',0);
end;
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update JYOrder_Main Set OrdDefDate1=getdate(),OrdPerson1='''+Trim(DName)+''',OrdFlag1=1');
sql.Add(' where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
end;
end;
procedure TfrmProductOrder_Ph10.TBRafreshClick(Sender: TObject);
begin
if FFInt=1 then
begin
InitGridFH();
end else
begin
InitGrid();
end;
end;
procedure TfrmProductOrder_Ph10.TBAddClick(Sender: TObject);
var
maxno:string;
begin
frmCKProductBCPKCListsel10:=TfrmCKProductBCPKCListsel10.create(self);
with frmCKProductBCPKCListsel10 do
begin
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
v2RollNum.Visible:=false;
v2RollNum.Options.Editing:=false;
v2RollNum.Hidden:=true;
v2Qty.Visible:=false;
v2Qty.Options.Editing:=false;
v2Qty.Hidden:=true;
end;
fkeyNo:='';
fType:=0;
if showmodal=1 then
begin
TBRafresh.Click;
end;
free;
end;
end;
procedure TfrmProductOrder_Ph10.OrderNoChange(Sender: TObject);
begin
if ADOQueryMain.Active=False then Exit;
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
end;
procedure TfrmProductOrder_Ph10.FormShow(Sender: TObject);
begin
InitForm();
end;
procedure TfrmProductOrder_Ph10.Tv1CellDblClick(
Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
// if ToolButton1.Visible=False then Exit;
// ToolButton1.Click;
end;
procedure TfrmProductOrder_Ph10.TBTPClick(Sender: TObject);
var
FQty,FQty1,FMxQty,FPQty,FMxQtyS,FPQtyS:String;
begin
end;
procedure TfrmProductOrder_Ph10.CheckBox1Click(Sender: TObject);
begin
IF Order_Main.IsEmpty then exit;
with Order_Main do
begin
DisableControls;
first;
while not eof do
begin
edit;
fieldbyname('ssel').Value:=checkbox1.Checked;
post;
next;
end;
First;
EnableControls;
end;
end;
procedure TfrmProductOrder_Ph10.CheckBox2Click(Sender: TObject);
begin
TBRafresh.Click;
end;
procedure TfrmProductOrder_Ph10.Tv1StylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
id,id10:Integer;
begin
{try
if Tv1.GroupedItemCount=0 then
begin
Id:=Tv1.GetColumnByFieldName('DeliveryDate').Index-tv1.GroupedItemCount;
Id10:=Tv1.GetColumnByFieldName('SubStatus').Index-tv1.GroupedItemCount;
if Trim(VarToStr(ARecord.Values[id]))='' then Exit;
if Id<0 then Exit;
if ARecord.Values[id10]='<27><><EFBFBD><EFBFBD>' then exit;
if (ARecord.Values[id]-DQdate)>=4 then Exit;
if ((ARecord.Values[id]-DQdate)>=0) and ((ARecord.Values[id]-DQdate)<4) then
AStyle:=DataLink_.QHuangSe
else
if ARecord.Values[id]-DQdate<0 then
begin
AStyle:=DataLink_OrderManage.FenHongS;
end;
end else
begin
end;
except
end; }
end;
procedure TfrmProductOrder_Ph10.v1DeliveryDateCustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
{ Id:=TV1.GetColumnByFieldName('DeliveryDate').Index;//;-TV1.GroupedItemCount;
Id10:=TV1.GetColumnByFieldName('SubStatus').Index;
if Id<0 then Exit;
if AViewInfo.GridRecord.Values[Id10]='<27><><EFBFBD><EFBFBD>' then Exit;
if AViewInfo.GridRecord.Values[Id]-SGetServerDate(ADOQueryTemp)>=4 then Exit;
if ((AViewInfo.GridRecord.Values[id]-SGetServerDate10(ADOQueryTemp))>=0) and ((AViewInfo.GridRecord.Values[id]-SGetServerDate(ADOQueryTemp))<4) then
ACanvas.Brush.Color:=clYellow
else
if (AViewInfo.GridRecord.Values[id])-(SGetServerDate10(ADOQueryTemp)<0) then
begin
ACanvas.Brush.Color:=clRed;
end;
begin
ACanvas.Brush.Color:=clRed;
end else
if AViewInfo.GridRecord.Values[Id]='Purple' then
begin
ACanvas.Brush.Color:=clPurple;
end else
if AViewInfo.GridRecord.Values[Id]='Olive' then
begin
ACanvas.Brush.Color:=clOlive;
end else
if AViewInfo.GridRecord.Values[Id]='Teal' then
begin
ACanvas.Brush.Color:=clTeal;
end else
if AViewInfo.GridRecord.Values[Id]='Background' then
begin
ACanvas.Brush.Color:=clBackground;
end; }
end;
procedure TfrmProductOrder_Ph10.N1Click(Sender: TObject);
var
fPrintFile:string;
Porderno:string;
begin
if Order_Main.IsEmpty then Exit;
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>10.rmf' ;
SDofilter(ADOQueryMain,' OrderNoM='''+Trim(Order_Main.fieldbyname('OrderNoM').AsString)+'''');
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
Porderno:=Trim(Order_Main.fieldbyname('OrderNoM').AsString);
if FileExists(fPrintFile) then
begin
//RMVariables['begindate']:=begindate.DateTime;
//RMVariables['enddate']:=enddate.DateTime;
//RMVariables['printtime']:=Now;
//RMVariables['printer']:=Trim(gUserName);
RM1.LoadFromFile(fPrintFile);
RM1.ShowReport;
end else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>10.rmf'),'<27><>ʾ',0);
end;
SDofilter(ADOQueryMain,'');
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
Order_Main.Locate('ordernoM',Porderno,[]);
end;
procedure TfrmProductOrder_Ph10.N2Click(Sender: TObject);
var
fPrintFile:string;
Porderno:string;
begin
if Order_Main.IsEmpty then Exit;
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>.rmf' ;
SDofilter(ADOQueryMain,' OrderNoM='''+Trim(Order_Main.fieldbyname('OrderNoM').AsString)+'''');
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
Porderno:=Trim(Order_Main.fieldbyname('OrderNoM').AsString);
if FileExists(fPrintFile) then
begin
//RMVariables['begindate']:=begindate.DateTime;
//RMVariables['enddate']:=enddate.DateTime;
//RMVariables['printtime']:=Now;
//RMVariables['printer']:=Trim(gUserName);
RM1.LoadFromFile(fPrintFile);
RM1.ShowReport;
end else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\<5C><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>.rmf'),'<27><>ʾ',0);
end;
SDofilter(ADOQueryMain,'');
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
Order_Main.Locate('ordernoM',Porderno,[]);
end;
procedure TfrmProductOrder_Ph10.ToolButton1Click(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
try
frmOrderInPut:=TfrmOrderInPut.Create(Application);
with frmOrderInPut do
begin
PState:=1;
FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
ToolBar2.Visible:=False;
TBSave.Visible:=False;
ScrollBox1.Enabled:=False;
Tv1.OptionsSelection.CellSelect:=False;
if ShowModal=1 then
begin
end;
end;
finally
frmOrderInPut.Free;
end;
end;
procedure TfrmProductOrder_Ph10.ToolButton2Click(Sender: TObject);
begin
if Order_Main.IsEmpty then Exit;
try
frmOrderInPut:=TfrmOrderInPut.Create(Application);
with frmOrderInPut do
begin
PState:=1;
CopyInt:=99;
FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
if ShowModal=1 then
begin
end;
end;
finally
frmOrderInPut.Free;
end;
end;
procedure TfrmProductOrder_Ph10.ToolButton3Click(Sender: TObject);
begin
ModalResult:=1;
end;
procedure TfrmProductOrder_Ph10.OrderNoKeyPress(Sender: TObject;
var Key: Char);
begin
{ if Key=#13 then
begin
if Length(OrderNoM.Text)<3 then Exit;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.add('exec P_View_Order :begdate,:enddate,:WSql') ;
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
Parameters.ParamByName('WSql').Value:=' and A.Filler='''+Trim(DName)+'''';
end;
begin
Parameters.ParamByName('WSql').Value:=' and orderno like '''+'%'+Trim(OrderNoM.Text)+'%'+'''';
end;
Parameters.ParamByName('begdate').Value:='1899-01-01';
Parameters.ParamByName('enddate').Value:='2050-01-01';
ExecSQL;
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end; }
end;
procedure TfrmProductOrder_Ph10.ConNoKeyPress(Sender: TObject;
var Key: Char);
begin
{ if Key=#13 then
begin
if Length(conno.Text)<3 then Exit;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
sql.Clear;
sql.add('exec P_View_Order :begdate,:enddate,:WSql') ;
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
Parameters.ParamByName('WSql').Value:=' and A.Filler='''+Trim(DName)+'''';
end;
begin
Parameters.ParamByName('WSql').Value:=' and conno like '''+'%'+Trim(conno.Text)+'%'+'''';
end;
Parameters.ParamByName('begdate').Value:='1899-01-01';
Parameters.ParamByName('enddate').Value:='2050-01-01';
ExecSQL;
Open;
end;
SCreateCDS20(ADOQueryMain,Order_Main);
SInitCDSData20(ADOQueryMain,Order_Main);
finally
ADOQueryMain.EnableControls;
end;
end; }
end;
procedure TfrmProductOrder_Ph10.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
if key=#13 then
begin
Query_MJ(Edit1.Text);
end;
end;
procedure TfrmProductOrder_Ph10.phwcClick(Sender: TObject);
var
phRollNum,phQty:double;
begin
if cds_ph.IsEmpty then exit;
with CDS_PH do
begin
DisableControls;
first;
while not eof do
begin
if (trim(fieldbyname('C_CodeName').AsString)<>trim(Order_Main.FieldByName('PRTCodeName').AsString))
or (trim(fieldbyname('C_Color').AsString)<>trim(Order_Main.FieldByName('PRTColor').AsString)) then
begin
application.MessageBox('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
EnableControls;
exit;
end;
next;
end;
first;
EnableControls;
end;
phRollNum:=0;
phQty:=0;
with CDS_PH do
begin
DisableControls;
first;
while not eof do
begin
phRollNum:=phRollNum+ CDS_PH.fieldbyname('RollNum').AsFloat;
phQty:=phQty+ CDS_PH.fieldbyname('Qty').AsFloat;
next;
end;
first;
EnableControls;
end;
if (phRollNum<>Order_Main.FieldByName('PRTRollNum').AsFloat) or
(phQty<>Order_Main.FieldByName('PRTOrderQty').AsFloat) then
begin
if Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFB5BD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',32+4)<>IDYES then Exit;
end;
if SaveData() then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ<EFBFBD><CABE>Ϣ');
TBRafresh.Click;
end
else
begin
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
end;
end;
procedure TfrmProductOrder_Ph10.cxTabControl1Change(Sender: TObject);
begin
TBEdit.Visible:=false;
TBDel.Visible:=false;
Tbcpfh.Visible:=false;
TBPrint1.Visible:=false;
TBPrint2.Visible:=false;
case cxTabControl1.TabIndex of
0:begin
TBEdit.Visible:=true;
TBDel.Visible:=true;
Tbcpfh.Visible:=true;
end;
1:begin
TBPrint1.Visible:=true;
// TBPrint2.Visible:=true;
end;
end;
{ del.Visible:=false;
phwc.Visible:=false;
phok.Visible:=false;
fh.Visible:=false;
Panel2.Visible:=false;
ToolButton4.Visible:=false;
TV2.OptionsData.Editing:=false;
ToolButton5.Visible:=false;
TBPrint1.Visible:=false;
ToolButton6.Visible:=false;
case cxTabControl1.TabIndex of
0:begin
del.Visible:=true;
phwc.Visible:=true;
Panel2.Visible:=true;
ToolButton4.Visible:=true;
TV2.OptionsData.Editing:=true;
end;
1:begin
fh.Visible:=true;
ToolButton5.Visible:=true;
if fDParameters1='<27><>Ȩ<EFBFBD><C8A8>' then
ToolButton6.Visible:=true;
end;
2:begin
TBPrint1.Visible:=true;
end;
end; }
application.ProcessMessages;
initGrid();
end;
procedure TfrmProductOrder_Ph10.phokClick(Sender: TObject);
begin
if cds_ph.IsEmpty then exit;
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from JYOrder_sub ');
sql.Add('where mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and subID='+quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
open;
edit;
fieldbyname('substatus').Value:='2';
post;
end;
application.MessageBox('<27><><EFBFBD><EFBFBD>ȷ<EFBFBD>ϳɹ<CFB3><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
TBRafresh.Click;
except
application.MessageBox('<27><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
end;
end;
procedure TfrmProductOrder_Ph10.delClick(Sender: TObject);
begin
if cds_ph.IsEmpty then exit;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from CK_BanCP_PH ');
sql.Add('where PHID='+quotedstr(trim(cds_ph.fieldbyname('PHID').AsString)));
execsql;
end;
cds_ph.Delete;
end;
procedure TfrmProductOrder_Ph10.fhClick(Sender: TObject);
var
CKOrdNo,maxno,rkNo:string;
fRoll,i:integer;
fNum:double;
begin
if cds_ph.IsEmpty then exit;
if Order_Main.Locate('ssel',true,[])=false then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
{ fRoll:=0;
fNum:=0;
with Order_Main do
begin
First;
DisableControls;
while not eof do
begin
if FieldByName('ssel').AsBoolean then
begin
fRoll:=fRoll+ Fieldbyname('PH_RollNum').AsInteger;
fNum:=fNum+ Fieldbyname('PH_Qty').AsFloat;
end;
next;
end;
First;
EnableControls
end;
IF fRoll<>strtointdef(trim(froll1.Text),0) then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end;
IF fnum<>strtofloatdef(trim(fnum1.Text),0) then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
exit;
end; }
ADOQueryCmd.Connection.BeginTrans;
try
Order_Main.First;
Order_Main.DisableControls;
CDS_ph.DisableControls;
while not Order_Main.eof do
begin
IF Order_Main.FieldByName('ssel').AsBoolean then
begin
initPH();
if GetLSNo(ADOQueryCmd,CKOrdNo,'CK','CK_BanCP_CR',3,1)=False then
begin
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><E2B5A5>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
if Order_Main.FieldByName('customerNoName').AsString='<27><EFBFBD><E3B6AB><EFBFBD>в<EFBFBD>' then
begin
if GetLSNo(ADOQueryCmd,rkNo,'RK','BP_InOut',3,1)=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
Exit;
end;
end;
i:=1;
with CDS_ph do
begin
First;
while not eof do
begin
if GetLSNo(ADOQueryCmd,maxno,'CC','CK_BanCp_CR',4,1)=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_BanCp_CR where 1<>1');
Open;
end;
with ADOQueryCmd do
begin
Append;
FieldByName('BCID').Value:=Trim(maxno);
FieldByName('CRID').Value:=CDS_ph.fieldbyname('CRID').Value;
FieldByName('CRTime').Value:=FormatDateTime('yyyy-MM-dd',CRdate.DateTime);
FieldByName('KGQty').Value:=CDS_ph.fieldbyname('KGQty').AsFloat;
FieldByName('Qty').Value:=CDS_ph.fieldbyname('Qty').AsFloat;
FieldByName('RollNum').Value:=CDS_ph.fieldbyname('RollNum').AsFloat;
FieldByName('QtyUnit').Value:=CDS_ph.fieldbyname('QtyUnit').Value;
FieldByName('MJID').Value:=CDS_ph.fieldbyname('MJID').Value;
FieldByName('MainID').Value:=CDS_ph.fieldbyname('MainID').Value;
FieldByName('SubID').Value:=CDS_ph.fieldbyname('SubID').Value;
FieldByName('APID').Value:=CDS_ph.fieldbyname('apid').Value;
FieldByName('MJID').Value:=CDS_ph.fieldbyname('MJID').Value;
FieldByName('MJxh').Value:=CDS_ph.fieldbyname('MJxh').Value;
FieldByName('CPType').Value:=CDS_ph.fieldbyname('MJType').Value;
FieldByName('kckw').Value:=CDS_ph.fieldbyname('kckw').Value;
FieldByName('C_Code').Value:=trim(CDS_ph.fieldbyname('C_Code').AsString);
FieldByName('C_CodeName').Value:=trim(CDS_ph.fieldbyname('C_CodeName').AsString);
FieldByName('C_spec').Value:=trim(CDS_ph.fieldbyname('C_spec').AsString);
FieldByName('C_Color').Value:=trim(CDS_ph.fieldbyname('C_Color').AsString);
FieldByName('BCGangNO').Value:=trim(CDS_ph.fieldbyname('BCGangNO').AsString);
FieldByName('RCGangNO').Value:=trim(CDS_ph.fieldbyname('RCGangNO').AsString);
FieldByName('packNo').Value:=trim(CDS_ph.fieldbyname('packNo').AsString);
FieldByName('defstr2').Value:=trim(CDS_ph.fieldbyname('defstr2').AsString);
FieldByName('PHID').Value:=trim(CDS_ph.fieldbyname('PHID').AsString);
FieldByName('Filler').Value:=Trim(DName);
FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
FieldByName('CRType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('CPType').Value:=trim(CDS_ph.fieldbyname('CPType').AsString);
FieldByName('CKOrdNo').Value:=Trim(CKOrdNo);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_BanCp_PH where PHID='+quotedstr(trim(CDS_ph.fieldbyname('PHID').AsString)));
open;
edit;
fieldbyname('P_Status').Value:='1';
post;
end;
if Order_Main.FieldByName('customerNoName').AsString='<27><EFBFBD><E3B6AB><EFBFBD>в<EFBFBD>' then
begin
if not SaveEjK(rkNo,inttostr(i),maxno,CKOrdNo) then
begin
ADOQueryCmd.Connection.RollbackTrans;
exit;
end;
end;
i:=i+1;
next;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPDATE CK_BanCp_KC SET kcstatus=null,KCKgQty =A.KCKgQty -B.KgQty,KCQty =A.KCQty -B.Qty,KCRollNum =A.KCRollNum -B.RollNum ');
sql.Add('FROM CK_BanCp_KC A ');
sql.Add('INNER JOIN CK_BanCP_CR B on B.CRID=A.CRID ');
sql.Add('WHERE B.CKOrdNo ='+Quotedstr(trim(CKOrdNo)));
ExecSQL;
end;
end;
if trim(Order_Main.FieldByName('CustomerNoName').AsString)='<27><EFBFBD><E3B6AB><EFBFBD>в<EFBFBD>' then
begin
if not YSData(Order_Main) then
begin
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
exit;
end;
end;
end;
Order_Main.Next;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPDATE CK_BanCp_KC SET KCRollNum =1 ');
sql.Add('WHERE (KCQty<>0 or KCKgQty<>0)and KcRollNum=0 ');
ExecSQL;
end;
CDS_ph.EnableControls;
Order_Main.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
if Application.MessageBox(<><C8B7>Ҫ<EFBFBD><D2AA>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><E2B5A5><EFBFBD><EFBFBD>','<27><>ʾ',32+4)=IDYES then
begin
TBPrint1.Click;
end;
TBRafresh.Click;
CRdate.DateTime:= DQdate;
except
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
end;
end;
procedure TfrmProductOrder_Ph10.ToolButton4Click(Sender: TObject);
begin
{ if Order_Main.IsEmpty then exit;
frmCKProductBCPKCListsel:=TfrmCKProductBCPKCListsel.create(self);
with frmCKProductBCPKCListsel do
begin
if Trim(DParameters1)<>'<27><>Ȩ<EFBFBD><C8A8>' then
begin
v2RollNum.Visible:=false;
v2RollNum.Hidden:=true;
v2Qty.Visible:=false;
v2Qty.Hidden:=true;
end;
fmainID:= trim(self.Order_Main.FieldByName('mainID').AsString);
if showmodal=1 then
begin
CDS_PH.DisableControls;
CDS_SubSel.DisableControls;
CDS_SubSel.first;
while not CDS_SubSel.eof do
begin
if (not CDS_PH.Locate('CRID',trim(CDS_SubSel.fieldbyname('CRID').AsString),[])) then
begin
CDS_PH.Append;
CDS_PH.FieldByName('conNo').Value:=trim(CDS_SubSel.fieldbyname('conNo').AsString);
CDS_PH.FieldByName('mjid').Value:=trim(CDS_SubSel.fieldbyname('mjid').AsString);
// CDS_PH.FieldByName('mjxh').Value:=trim(fieldbyname('mjxh').AsString);
CDS_PH.FieldByName('C_CodeName').Value:=trim(CDS_SubSel.fieldbyname('C_CodeName').AsString);
CDS_PH.FieldByName('C_Spec').Value:=trim(CDS_SubSel.fieldbyname('C_Spec').AsString);
CDS_PH.FieldByName('C_Color').Value:=trim(CDS_SubSel.fieldbyname('C_Color').AsString);
CDS_PH.FieldByName('PMainID').Value:=trim(CDS_SubSel.fieldbyname('MainID').AsString);
CDS_PH.FieldByName('PSubID').Value:=trim(CDS_SubSel.fieldbyname('SubID').AsString);
CDS_PH.FieldByName('kcqtyunit').Value:=trim(CDS_SubSel.fieldbyname('kcqtyunit').AsString);
CDS_PH.FieldByName('kcqty').Value:=CDS_SubSel.fieldbyname('kcqty').AsFloat;
CDS_PH.FieldByName('kcRollnum').Value:=CDS_SubSel.fieldbyname('kcRollnum').AsFloat;
CDS_PH.FieldByName('Qty').Value:=CDS_SubSel.fieldbyname('kcqty').AsFloat;
CDS_PH.FieldByName('RollNum').Value:=CDS_SubSel.fieldbyname('kcRollnum').AsFloat;
CDS_PH.FieldByName('CRID').Value:=CDS_SubSel.fieldbyname('CRID').AsFloat;
CDS_PH.Post;
end;
CDS_SubSel.next;
end;
CDS_PH.EnableControls;
CDS_SubSel.EnableControls;
end;
free;
end;
TBRafresh.Click; }
end;
procedure TfrmProductOrder_Ph10.ToolButton5Click(Sender: TObject);
begin
if cds_ph.IsEmpty then exit;
if cxTabControl1.TabIndex=1 then
begin
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from JYOrder_sub ');
sql.Add('where mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and subID='+quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
open;
edit;
fieldbyname('substatus').Value:='0';
post;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update CK_BanCP_KC SET kcstatus=null ');
sql.Add('from CK_BanCP_KC A ');
sql.Add('inner join CK_BanCP_PH B on B.CRID=A.CRID ');
sql.Add('where B.mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and B.subID='+quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
execsql;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from CK_BanCP_PH ');
sql.Add('where mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and subID='+quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
execsql;
end;
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
TBRafresh.Click;
except
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
end;
end;
{ if cxTabControl1.TabIndex=1 then
begin
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from JYOrder_sub ');
sql.Add('where mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and subID='+quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
open;
edit;
fieldbyname('substatus').Value:='0';
post;
end;
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>ϳɹ<CFB3><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
TBRafresh.Click;
except
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
end;
end; }
end;
procedure TfrmProductOrder_Ph10.TBPrint1Click(Sender: TObject);
var
filepath,fOrderNo:string;
i:integer;
Txt,fImagePath:string;
Moudle: THandle;
Makebar:TMakebar;
Mixtext:TMixtext;
begin
if Order_Main.IsEmpty then exit;
if Order_Main.Locate('ssel',true,[])=false then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
createTable();
i:=0;
with Order_Main do
begin
DisableControls;
first;
while not eof do
begin
IF Fieldbyname('ssel').AsBoolean then
begin
IF i=0 then fOrderNo:=trim(fieldbyname('OrderNo').AsString);
IF (i>0) and (trim(fieldbyname('OrderNo').AsString)<> fOrderNo) then
begin
application.MessageBox('ѡ<><D1A1><EFBFBD>˲<EFBFBD>ͬ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>ӡ<EFBFBD><D3A1>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
EnableControls;
exit;
end;
with adoqueryCmd do
begin
Close;
SQL.Clear;
SQL.Add(' insert into '+TblCprk+'(mainID,subID,P_NO) values( ');
SQL.Add(' '+quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
SQL.Add(','+quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
SQL.Add(','+quotedstr(trim(Order_Main.fieldbyname('P_NO').AsString)));
sql.add(')');
execsql;
end;
i:=i+1;
end;
next;
end;
First;
EnableControls;
end;
with AdoPrint do
begin
close;
sql.Clear;
sql.Add('exec P_Do_PrintMd10 ');
sql.Add('@mainID='+quotedstr(trim(Order_Main.fieldbyname('MainID').AsString)));
sql.Add(',@TblCprk='+quotedstr(trim(TblCprk)));
sql.Add(',@flag='+quotedstr(trim('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㶫')));
open;
end;
try
filepath:=ExtractFilePath(Application.ExeName) + 'report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5><EFBFBD><EFBFBD>Сֽ<D0A1><D6BD>.rmf';
if not FileExists(Pchar(filepath)) then
begin
application.MessageBox(pchar('<27>ļ<EFBFBD>['+filepath+']<5D><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>'),'<27><>ʾ<EFBFBD><CABE>Ϣ',MB_IConError);
exit;
end;
try
Moudle:=LoadLibrary('MakeQRBarcode.dll');
@Makebar:=GetProcAddress(Moudle,'Make');
@Mixtext:=GetProcAddress(Moudle,'MixText');
Txt:=Trim(AdoPrint.fieldbyname('orderNo').AsString);
fImagePath:=ExtractFilePath(Application.ExeName)+'image\temp.bmp';
if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName)+'image')) then
CreateDirectory(pchar(ExtractFilePath(Application.ExeName)+'image'),nil);
if FileExists(fImagePath) then DeleteFile(fImagePath);
Makebar(pchar(Txt),Length(Txt),3,3,0,PChar(fImagePath),3);
except
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
exit;
end;
RMVariables['QRBARCODE']:=fImagePath;
RMVariables['dtxz'] :=FormatDateTime('yyyy-mm-dd',date());
RMVariables['zdr'] :=trim(DName);
RMVariables['Filler'] :=trim(Order_Main.fieldbyname('Filler').AsString);
RMGridReport1.LoadFromFile(filepath);
RMGridReport1.ShowReport;
finally
DropTable();
end;
end;
procedure TfrmProductOrder_Ph10.ToolButton6Click(Sender: TObject);
begin
if Order_Main.IsEmpty then exit;
frmCKProductBCPKCListsel:=TfrmCKProductBCPKCListsel.create(self);
with frmCKProductBCPKCListsel do
begin
fmainID:= trim(self.Order_Main.FieldByName('mainID').AsString);
if showmodal=1 then
begin
CDS_PH.DisableControls;
CDS_SubSel.DisableControls;
CDS_SubSel.first;
while not CDS_SubSel.eof do
begin
if (not CDS_PH.Locate('CRID',trim(CDS_SubSel.fieldbyname('CRID').AsString),[])) then
begin
CDS_PH.Append;
CDS_PH.FieldByName('conNo').Value:=trim(CDS_SubSel.fieldbyname('conNo').AsString);
CDS_PH.FieldByName('mjid').Value:=trim(CDS_SubSel.fieldbyname('mjid').AsString);
// CDS_PH.FieldByName('mjxh').Value:=trim(fieldbyname('mjxh').AsString);
CDS_PH.FieldByName('C_CodeName').Value:=trim(CDS_SubSel.fieldbyname('C_CodeName').AsString);
CDS_PH.FieldByName('C_Spec').Value:=trim(CDS_SubSel.fieldbyname('C_Spec').AsString);
CDS_PH.FieldByName('C_Color').Value:=trim(CDS_SubSel.fieldbyname('C_Color').AsString);
CDS_PH.FieldByName('PMainID').Value:=trim(CDS_SubSel.fieldbyname('MainID').AsString);
CDS_PH.FieldByName('PSubID').Value:=trim(CDS_SubSel.fieldbyname('SubID').AsString);
CDS_PH.FieldByName('kcqtyunit').Value:=trim(CDS_SubSel.fieldbyname('kcqtyunit').AsString);
CDS_PH.FieldByName('kcqty').Value:=CDS_SubSel.fieldbyname('kcqty').AsFloat;
CDS_PH.FieldByName('kcRollnum').Value:=CDS_SubSel.fieldbyname('kcRollnum').AsFloat;
CDS_PH.FieldByName('Qty').Value:=CDS_SubSel.fieldbyname('kcqty').AsFloat;
CDS_PH.FieldByName('RollNum').Value:=CDS_SubSel.fieldbyname('kcRollnum').AsFloat;
CDS_PH.FieldByName('CRID').Value:=CDS_SubSel.fieldbyname('CRID').AsFloat;
CDS_PH.Post;
end;
CDS_SubSel.next;
end;
CDS_PH.EnableControls;
CDS_SubSel.EnableControls;
end;
free;
end;
TBRafresh.Click;
end;
procedure TfrmProductOrder_Ph10.Tv1FocusedRecordChanged(
Sender: TcxCustomGridTableView; APrevFocusedRecord,
AFocusedRecord: TcxCustomGridRecord;
ANewItemRecordFocusingChanged: Boolean);
begin
if Order_Main.IsEmpty then exit;
initPH();
end;
procedure TfrmProductOrder_Ph10.TbcpfhClick(Sender: TObject);
begin
fh.Click;
end;
procedure TfrmProductOrder_Ph10.TBPrint2Click(Sender: TObject);
var
filepath,fOrderNo:string;
i:integer;
begin
if Order_Main.IsEmpty then exit;
if Order_Main.Locate('ssel',true,[])=false then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
createTable();
i:=0;
with Order_Main do
begin
DisableControls;
first;
while not eof do
begin
IF Fieldbyname('ssel').AsBoolean then
begin
IF i=0 then fOrderNo:=trim(fieldbyname('OrderNo').AsString);
IF (i>0) and (trim(fieldbyname('OrderNo').AsString)<> fOrderNo) then
begin
application.MessageBox('ѡ<><D1A1><EFBFBD>˲<EFBFBD>ͬ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>ӡ<EFBFBD><D3A1>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
EnableControls;
exit;
end;
with adoqueryCmd do
begin
Close;
SQL.Clear;
SQL.Add(' insert into '+TblCprk+'(mainID,subID,P_NO) values( ');
SQL.Add(' '+quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
SQL.Add(','+quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
SQL.Add(','+quotedstr(trim(Order_Main.fieldbyname('P_NO').AsString)));
sql.add(')');
execsql;
end;
i:=i+1;
end;
next;
end;
First;
EnableControls;
end;
with AdoPrint do
begin
close;
sql.Clear;
sql.Add('exec P_Do_PrintMd10 ');
sql.Add('@mainID='+quotedstr(trim(Order_Main.fieldbyname('MainID').AsString)));
sql.Add(',@TblCprk='+quotedstr(trim(TblCprk)));
sql.Add(',@flag='+quotedstr(trim('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㶫')));
open;
end;
try
filepath:=ExtractFilePath(Application.ExeName) + 'report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5><EFBFBD><EFBFBD>.rmf';
if not FileExists(Pchar(filepath)) then
begin
application.MessageBox(pchar('<27>ļ<EFBFBD>['+filepath+']<5D><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>'),'<27><>ʾ<EFBFBD><CABE>Ϣ',MB_IConError);
exit;
end;
RMVariables['dtxz'] :=FormatDateTime('yyyy-mm-dd',date());
RMVariables['zdr'] :=trim(DName);
RMVariables['Filler'] :=trim(Order_Main.fieldbyname('Filler').AsString);
RMGridReport1.LoadFromFile(filepath);
RMGridReport1.ShowReport;
finally
DropTable();
end;
end;
procedure TfrmProductOrder_Ph10.ToolButton7Click(Sender: TObject);
begin
try
frmCKSMEdit:=TfrmCKSMEdit.Create(Application);
with frmCKSMEdit do
begin
if ShowModal=1 then
begin
end;
end;
finally
frmCKSMEdit.Free;
end;
end;
end.