941 lines
28 KiB
ObjectPascal
941 lines
28 KiB
ObjectPascal
unit U_DJBRK_Edit;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils,strutils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
||
cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxDropDownEdit,
|
||
ComCtrls, ToolWin, cxGridLevel, cxGridCustomTableView, cxGridTableView,
|
||
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient, cxButtonEdit,
|
||
cxTextEdit, StdCtrls, ExtCtrls, BtnEdit, RM_Dataset, RM_System,
|
||
RM_Common, RM_Class, RM_GridReport;
|
||
|
||
type
|
||
TfrmDJBRK_Edit = class(TForm)
|
||
cxGrid2: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v2Column1: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
v2Column6: TcxGridDBColumn;
|
||
cxGrid2Level1: TcxGridLevel;
|
||
ToolBar1: TToolBar;
|
||
TBSave: TToolButton;
|
||
TBClose: TToolButton;
|
||
DataSource3: TDataSource;
|
||
CDS_Main: TClientDataSet;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
v1Column12: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column10: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column15: TcxGridDBColumn;
|
||
v1Column19: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
v1Column11: TcxGridDBColumn;
|
||
Panel1: TPanel;
|
||
Panel2: TPanel;
|
||
GroupBox1: TGroupBox;
|
||
CRTime: TDateTimePicker;
|
||
Label1: TLabel;
|
||
Label8: TLabel;
|
||
InoutNo: TEdit;
|
||
Label2: TLabel;
|
||
CRType: TComboBox;
|
||
Label4: TLabel;
|
||
FactoryName: TBtnEditA;
|
||
ToolBar2: TToolBar;
|
||
TBADD: TToolButton;
|
||
TBdel: TToolButton;
|
||
v1Column2: TcxGridDBColumn;
|
||
cxGrid1: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
v2Column2: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
v2Column3: TcxGridDBColumn;
|
||
ADOMX: TADOQuery;
|
||
CDS_MX: TClientDataSet;
|
||
DSMX: TDataSource;
|
||
Panel3: TPanel;
|
||
Label3: TLabel;
|
||
QtyMX: TEdit;
|
||
TBPrint: TToolButton;
|
||
RM2: TRMGridReport;
|
||
RMDB_Main: TRMDBDataSet;
|
||
ADOQueryPrint: TADOQuery;
|
||
v1Column4: TcxGridDBColumn;
|
||
Label5: TLabel;
|
||
QtyFJ: TEdit;
|
||
v2Column4: TcxGridDBColumn;
|
||
ThreeColorBase: TcxStyleRepository;
|
||
SHuangSe: TcxStyle;
|
||
SkyBlue: TcxStyle;
|
||
Default: TcxStyle;
|
||
QHuangSe: TcxStyle;
|
||
Red: TcxStyle;
|
||
FontBlue: TcxStyle;
|
||
TextSHuangSe: TcxStyle;
|
||
FonePurple: TcxStyle;
|
||
FoneClMaroon: TcxStyle;
|
||
FoneRed: TcxStyle;
|
||
RowColor: TcxStyle;
|
||
handBlack: TcxStyle;
|
||
cxBlue: TcxStyle;
|
||
SHuangSeCu: TcxStyle;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBSaveClick(Sender: TObject);
|
||
procedure v2Column1PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure v2Column6PropertiesEditValueChanged(Sender: TObject);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure FactoryNameBtnClick(Sender: TObject);
|
||
procedure TBADDClick(Sender: TObject);
|
||
procedure QtyMXKeyPress(Sender: TObject; var Key: Char);
|
||
procedure TBPrintClick(Sender: TObject);
|
||
procedure Tv1CellClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
procedure Tv2CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
procedure TBdelClick(Sender: TObject);
|
||
procedure v2Column1PropertiesEditValueChanged(Sender: TObject);
|
||
procedure v1Column15PropertiesEditValueChanged(Sender: TObject);
|
||
procedure v1Column2PropertiesEditValueChanged(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
function SaveData():Boolean;
|
||
function YSData(Order_Main10:TClientDataSet):Boolean;
|
||
Procedure InitGrid();
|
||
Procedure initMJID();
|
||
Procedure PrintData(fMJID:string);
|
||
public
|
||
{ Public declarations }
|
||
fkeyNo:String;
|
||
fckName:String;
|
||
end;
|
||
var
|
||
frmDJBRK_Edit: TfrmDJBRK_Edit;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_RTFun,U_ClothContractListHZCX,U_ZDYHelp, U_ZdyAttachGYS,U_ProductOrderListSel,
|
||
U_ZdyAttachCP;
|
||
|
||
{$R *.dfm}
|
||
Procedure TfrmDJBRK_Edit.PrintData(fMJID:string);
|
||
var
|
||
fPrintFile:String;
|
||
Txt,fImagePath:string;
|
||
Moudle: THandle;
|
||
Makebar:TMakebar;
|
||
Mixtext:TMixtext;
|
||
begin
|
||
try
|
||
Moudle:=LoadLibrary('MakeQRBarcode.dll');
|
||
@Makebar:=GetProcAddress(Moudle,'Make');
|
||
@Mixtext:=GetProcAddress(Moudle,'MixText');
|
||
Txt:=Trim(fMJID);
|
||
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;
|
||
with ADOQueryPrint do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select A.*,C_CodeNameZW=(select Top 1 defnote3 from KH_Zdy_Attachment X where X.ZdyName=A.C_CodeName and Type=''CP'') ');
|
||
sql.Add(',C_colorName=(select Top 1 DEFstr6 from KH_Zdy_Attachment X where X.ZdyName=A.C_CodeName and X.DEFstr3=A.C_Color and Type=''CP'') ');
|
||
sql.Add(',factoryNameJZ=(select Top 1 zdyNameZ from KH_Zdy_Attachment X where X.ZdyName=A.factoryName and Type=''GYS'') ');
|
||
sql.Add(' from WFB_MJJY A') ;
|
||
SQL.Add(' where A.MJID='''+Trim(fMJID)+'''');
|
||
Open;
|
||
end;
|
||
|
||
fPrintFile:=ExtractFilePath(Application.ExeName)+'Report\ͨ<>ñ<EFBFBD>ǩ.rmf' ;
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RMVariables['QRBARCODE']:=fImagePath;
|
||
RM2.LoadFromFile(fPrintFile);
|
||
RM2.DefaultCopies:=1;
|
||
RM2.PrintReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD>ҵ<EFBFBD>'+trim(fPrintFile)),'<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
Procedure TfrmDJBRK_Edit.initMJID();
|
||
begin
|
||
try
|
||
with ADOMX do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from WFB_MJJY A');
|
||
sql.Add('where APID='+quotedstr(trim(CDS_Main.fieldByName('SPID').AsString)));
|
||
open;
|
||
end;
|
||
SCreateCDS20(ADOMX,CDS_MX);
|
||
SInitCDSData20(ADOMX,CDS_MX);
|
||
except
|
||
end;
|
||
end;
|
||
Procedure TfrmDJBRK_Edit.InitGrid();
|
||
begin
|
||
try
|
||
with adoqueryMain do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select *,C_CodeNameZW=(select Top 1 defnote3 from KH_Zdy_Attachment X where X.ZdyName=A.SPName and Type=''CP'') from CK_SXPB_CR A');
|
||
sql.Add('where SPID='+quotedstr(trim(fkeyNO)));
|
||
open;
|
||
end;
|
||
SCreateCDS20(adoqueryMain,CDS_Main);
|
||
SInitCDSData20(adoqueryMain,CDS_Main);
|
||
if not CDS_Main.IsEmpty then
|
||
begin
|
||
CRTime.Date:= CDS_Main.fieldbyname('CRTime').AsDateTime;
|
||
// CKName.ItemIndex:=CKName.Items.IndexOf(trim(CDS_Main.fieldbyname('CKName').AsString));
|
||
CRType.ItemIndex:=CRType.Items.IndexOf(trim(CDS_Main.fieldbyname('CRType').AsString));
|
||
// inoutNo.Text:=CDS_Main.fieldbyname('inoutNo').asstring;
|
||
factoryName.Text:=trim(CDS_Main.fieldbyname('factoryName').AsString);
|
||
end;
|
||
finally
|
||
end;
|
||
end;
|
||
|
||
|
||
function TfrmDJBRK_Edit.YSData(Order_Main10:TClientDataSet):Boolean;
|
||
var
|
||
CRID,YFID,PriceUnit,OrderUnit,FComTaiTou,FromSubID,khName:String;
|
||
fprice,huilv:double;
|
||
begin
|
||
Result:=False;
|
||
fprice:=0;
|
||
huilv:=0;
|
||
PriceUnit:='RMB';
|
||
khName:='';
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('update JYOrder_Sub SET Huilv=isnull((select Huilv from JYOrderCon_Sub X where X.SubId=JYOrder_Sub.SOrddefstr10),1) where Huilv=0');
|
||
execsql;
|
||
end;
|
||
with Order_Main10 do
|
||
begin
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select A.*,fPrice=dbo.F_Get_Order_Price(A.MainID,A.subID),B.customerNoName');
|
||
sql.Add(' from JYOrder_Sub A ');
|
||
sql.Add(' inner join JYOrder_main B on B.mainID=A.mainID ');
|
||
sql.Add(' Where subID='''+Trim(Order_Main10.fieldbyname('ORDSubIdRK').AsString)+'''');
|
||
Open;
|
||
end;
|
||
IF not ADOQueryTemp.IsEmpty then
|
||
begin
|
||
PriceUnit:=Trim(ADOQueryTemp.fieldbyname('PriceUnit').AsString);
|
||
OrderUnit:=Trim(ADOQueryTemp.fieldbyname('OrderUnit').AsString);
|
||
fPrice:= ADOQueryTemp.fieldbyname('fPrice').AsFloat;
|
||
huilv:= ADOQueryTemp.fieldbyname('huilv').AsFloat;
|
||
khName:= ADOQueryTemp.fieldbyname('customerNoName').AsString;
|
||
end;
|
||
IF huilv=0 then huilv:=1;
|
||
CRID:='0';
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select * from YF_Money_CR ');
|
||
sql.Add(' where mainID='''+Trim(CDS_Main.fieldbyname('SPID').AsString)+'''');
|
||
sql.Add(' and YFName=''<27>ͻ<EFBFBD><CDBB>˻<EFBFBD>'' ');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd,YFID,'CS','YF_Money_CR',3,1)=False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1>ƷӦ<C6B7><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('SPID').AsString);
|
||
FieldByName('CRID').Value:=StrToInt(CRID);
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
FieldByName('CRType').Value:='Ӧ<>տ<EFBFBD><D5BF>Ǽ<EFBFBD>';
|
||
FieldByName('CRFlag').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
||
FieldByName('QtyFlag').Value:=1;
|
||
FieldByName('FactoryName').Value:=Trim(KHName);
|
||
FieldByName('CRTime').Value:=Trim(FormatDateTime('yyyy-MM-dd',CDS_Main.fieldbyname('CRTime').AsDateTime));
|
||
FieldByName('YFType').Value:='<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('ps').Value:=-1*Order_Main10.fieldbyname('PiQty').AsFloat;
|
||
FieldByName('Qty').Value:=-1*Order_Main10.fieldbyname('Qty').AsFloat;
|
||
FieldByName('Price').Value:=fprice;
|
||
FieldByName('HuiLv').Value:=huilv;
|
||
FieldByName('BZType').Value:=Trim(PriceUnit);
|
||
// FieldByName('Money').Value:=-1*format('%.2f',[Order_Main10.fieldbyname('Qty').AsFloat*fprice]);
|
||
// FieldByName('BBMoney').Value:=-1*format('%.2f',[Order_Main10.fieldbyname('Qty').AsFloat*fprice*huilv]);
|
||
FieldByName('QtyUnit').Value:=Trim(Order_Main10.fieldbyname('QtyUnit').AsString);
|
||
FieldByName('ComTaiTou').Value:=Trim(KHName);
|
||
FieldByName('YFName').Value:='<27>ͻ<EFBFBD><CDBB>˻<EFBFBD>';
|
||
FieldByName('MainId').Value:=Trim(Order_Main10.fieldbyname('SPID').AsString);
|
||
FieldByName('subID').Value:='';
|
||
FieldByName('OrderNO').Value:=Trim(Order_Main10.fieldbyname('OrderNO').AsString);
|
||
FieldByName('P_CodeName').Value:=Trim(Order_Main10.fieldbyname('SPName').AsString);
|
||
FieldByName('P_Spec').Value:=Trim(Order_Main10.fieldbyname('SPSpec').AsString);
|
||
FieldByName('P_color').Value:=Trim(Order_Main10.fieldbyname('SPColor').AsString);
|
||
FieldByName('status').Value:='0';
|
||
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 Money=Price*Qty,BBMoney=Price*Qty*HuiLv');
|
||
sql.Add(' where YFID='''+Trim(YFID)+'''');
|
||
ExecSQL;
|
||
end;
|
||
|
||
//Next;
|
||
end;
|
||
end;
|
||
Result:=True;
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
function TfrmDJBRK_Edit.SaveData():Boolean;
|
||
var
|
||
Maxno:string;
|
||
begin
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
CDS_Main.DisableControls;
|
||
with CDS_Main do
|
||
begin
|
||
First;
|
||
while not eof do
|
||
begin
|
||
Maxno:=fieldbyName('SPID').AsString;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete from YF_Money_CR ');
|
||
sql.Add(' where mainID='''+Trim(Maxno)+'''');
|
||
sql.Add(' and YFName=''<27>ͻ<EFBFBD><CDBB>˻<EFBFBD>'' ');
|
||
execsql;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from CK_SXPB_CR where SPID='''+Trim(Maxno)+'''');
|
||
Open;
|
||
if IsEmpty then
|
||
begin
|
||
Append;
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
end
|
||
else
|
||
begin
|
||
Edit;
|
||
FieldByName('Editer').Value:=Trim(DName);
|
||
FieldByName('EditTime').Value:=SGetServerDate(ADOQueryTemp);
|
||
end;
|
||
FieldByName('SPID').Value:=Trim(Maxno);
|
||
FieldByName('FZSPID').Value:=Trim(Maxno);
|
||
FieldByName('CKName').Value:=trim(fckName);
|
||
FieldByName('CRTime').Value:=formatdateTime('yyyy-MM-dd',CRTime.DateTime);
|
||
FieldByName('CRType').Value:=trim(CRType.Text);
|
||
FieldByName('factoryName').Value:=trim(factoryName.Text);
|
||
FieldByName('CRFlag').Value:='<27><><EFBFBD><EFBFBD>';
|
||
FieldByName('CRQtyFlag').Value:=1;
|
||
RTSetSaveDataCDS(ADOQueryCmd,Tv1,CDS_Main,'CK_SXPB_CR',2);
|
||
FieldByName('PiQty').Value:=CDS_Main.fieldbyname('piQty').AsInteger;
|
||
FieldByName('Qty').Value:=CDS_Main.fieldbyname('Qty').AsFloat;
|
||
FieldByName('price').Value:=CDS_Main.fieldbyname('price').AsFloat;
|
||
FieldByName('money').Value:=CDS_Main.fieldbyname('money').AsFloat;
|
||
FieldByName('Qty1').Value:=CDS_Main.fieldbyname('Qty1').AsFloat;
|
||
FieldByName('RCQty').Value:=CDS_Main.fieldbyname('RCQty').AsFloat;
|
||
Post;
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update CK_SXPB_CR Set MXKCQty=(select sum(isnull(Qty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
|
||
sql.Add(',MXKCPiQty=(select sum(isnull(PiQty,0)*CRQtyFlag) from CK_SXPB_CR A where A.FZSPID=CK_SXPB_CR.SPID)');
|
||
sql.Add(' where SPID='''+Trim(Maxno)+'''');
|
||
ExecSQL;
|
||
end;
|
||
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' Update WFB_MJJY SET CKName=B.CKName,factoryName=B.FactoryName,BatchNo=B.BatchNO,C_CodeName=B.SPName,C_Color=B.SPColor,');
|
||
sql.Add(' MJTypeOther=B.QtyUnit,MJStr1=B.QtyUnit,MJStr2=''δ<><CEB4><EFBFBD><EFBFBD>'',MJFK=cast(isnull(B.SPMF,''0'') as decimal(18,2)),MJSJKZ=cast(isnull(B.SPKZ,''0'') as decimal(18,2)),');
|
||
sql.Add(' RCgangNo=B.RCGangNo,BCgangNo=B.RCGangNo,Filler=B.Filler,Filltime=B.Filltime ');
|
||
sql.Add(' FROM WFB_MJJY A ');
|
||
sql.Add(' inner join CK_SXPB_CR B on B.SPID=A.APID ');
|
||
sql.Add(' where A.APID='''+Trim(Maxno)+'''');
|
||
ExecSQL;
|
||
end;
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select A.SPID ');
|
||
sql.Add('from CK_SXPB_CR A');
|
||
sql.Add('inner join CK_SXPB_CR B on B.RCGangNo=A.RCgangNo and B.Qty=A.Qty and B.SPID<>A.SPID');
|
||
sql.Add('where A.SPID='''+Trim(Maxno)+''' and isnull(A.RCGangNo,'''')<>'''' ');
|
||
open;
|
||
end;
|
||
IF not ADOQueryTemp.IsEmpty then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><>ͬ<EFBFBD><EFBFBD><D7BA><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1>棡','<27><>ʾ',0);
|
||
exit;
|
||
end;
|
||
|
||
if Trim(CDS_Main.fieldbyname('CRType').AsString)='<27>ͻ<EFBFBD><CDBB>˻<EFBFBD>' then
|
||
begin
|
||
if not YSData(CDS_Main) then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
||
exit;
|
||
end;
|
||
end;
|
||
|
||
Next;
|
||
end;
|
||
end;
|
||
CDS_Main.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
TBPrint.Enabled:=true;
|
||
Result:=True;
|
||
except
|
||
Result:=False;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
||
end;
|
||
|
||
end;
|
||
procedure TfrmDJBRK_Edit.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(self.Caption,Tv1,'<27><><EFBFBD>첼<EFBFBD>ֿ<EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.FormShow(Sender: TObject);
|
||
var
|
||
fsj:String;
|
||
begin
|
||
ReadCxGrid(self.Caption,Tv1,'<27><><EFBFBD>첼<EFBFBD>ֿ<EFBFBD>');
|
||
InitGrid();
|
||
initMJID();
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.TBSaveClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then Exit;
|
||
|
||
if trim(factoryName.Text)='' then
|
||
begin
|
||
Application.MessageBox('<27>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if trim(CRType.Text)='' then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Main.Locate('SPName',null,[])=True then
|
||
begin
|
||
Application.MessageBox('Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Main.Locate('SPcolor',null,[])=True then
|
||
begin
|
||
Application.MessageBox('<27><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Main.Locate('Qty',null,[])=True then
|
||
begin
|
||
Application.MessageBox('<27>뵥<EFBFBD><EBB5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Main.Locate('QtyUnit',null,[])=True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Main.Locate('SPName','',[])=True then
|
||
begin
|
||
Application.MessageBox('Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Main.Locate('SPcolor','',[])=True then
|
||
begin
|
||
Application.MessageBox('<27><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Main.FieldByName('Qty').AsFloat=0 then
|
||
begin
|
||
Application.MessageBox('<27>뵥<EFBFBD><EBB5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if CDS_Main.Locate('QtyUnit','',[])=True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
|
||
|
||
IF not CDS_MX.IsEmpty then
|
||
begin
|
||
IF tv2.DataController.Summary.FooterSummaryValues[1]<> CDS_Main.fieldByName('PiQty').AsInteger then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>ϸƥ<CFB8><C6A5><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
|
||
//ModalResult:=1;
|
||
Exit;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.v2Column1PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZdyAttachCP:=TfrmZdyAttachCP.Create(Application);
|
||
with frmZdyAttachCP do
|
||
begin
|
||
if ShowModal=1 then
|
||
begin
|
||
with Self.CDS_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName('SPName').Value:=Trim(frmZdyAttachCP.CDS_HZ.fieldbyname('ZdyName').AsString);
|
||
FieldByName('SPSpec').Value:=Trim(frmZdyAttachCP.CDS_HZ.fieldbyname('DEFstr1').AsString);
|
||
FieldByName('SPColor').Value:=Trim(frmZdyAttachCP.CDS_HZ.fieldbyname('DEFstr3').AsString);
|
||
FieldByName('SPCF').Value:=Trim(frmZdyAttachCP.CDS_HZ.fieldbyname('DEFstr2').AsString);
|
||
FieldByName('SPMF').Value:=Trim(frmZdyAttachCP.CDS_HZ.fieldbyname('DEFstr7').AsString);
|
||
FieldByName('SPKZ').Value:=Trim(frmZdyAttachCP.CDS_HZ.fieldbyname('DEFstr8').AsString);
|
||
FieldByName('SPKZ').Value:=Trim(frmZdyAttachCP.CDS_HZ.fieldbyname('DEFstr8').AsString);
|
||
FieldByName('SPCode').Value:=Trim(frmZdyAttachCP.CDS_HZ.fieldbyname('ZdyCode').AsString);
|
||
FieldByName('CPID').Value:=Trim(frmZdyAttachCP.CDS_HZ.fieldbyname('ATID').AsString);
|
||
FieldByName('C_CodeNameZW').Value:=Trim(frmZdyAttachCP.CDS_HZ.fieldbyname('defnote3').AsString);
|
||
end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZdyAttachCP.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.v2Column6PropertiesEditValueChanged(
|
||
Sender: TObject);
|
||
var
|
||
fieldname:string;
|
||
begin
|
||
fieldname:=Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName;
|
||
with CDS_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName(Trim(fieldname)).Value:=TcxTextEdit(Sender).EditingText;
|
||
FieldByName('Money').Value:=strtofloat(format('%.2f',[FieldByName('Qty').AsFloat * FieldByName('Price').AsFloat]));
|
||
Post;
|
||
end;
|
||
Tv1.Controller.EditingController.ShowEdit();
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmDJBRK_Edit:=nil;
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.FormCreate(Sender: TObject);
|
||
begin
|
||
Panel2.Align:=alclient;
|
||
CRTime.DateTime:=now();
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.FactoryNameBtnClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmZdyAttachGYS:=TfrmZdyAttachGYS.Create(Application);
|
||
with frmZdyAttachGYS do
|
||
begin
|
||
if ShowModal=1 then
|
||
begin
|
||
factoryName.Text:=Trim(frmZdyAttachGYS.CDS_HZ.fieldbyname('ZdyName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZdyAttachGYS.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.TBADDClick(Sender: TObject);
|
||
var
|
||
fSPID:string;
|
||
begin
|
||
IF not CDS_MX.IsEmpty then
|
||
begin
|
||
IF tv2.DataController.Summary.FooterSummaryValues[1]<> CDS_Main.fieldByName('PiQty').AsInteger then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>ϸƥ<CFB8><C6A5><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
CopyAddRowCDS(CDS_Main);
|
||
if GetLSNo(ADOQueryCmd,fSPID,'','CK_SXPB_CR',3,1)=False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD>첼<EFBFBD><ECB2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
CDS_Main.edit;
|
||
CDS_Main.FieldByName('SPID').Value:=fSPID;
|
||
CDS_Main.FieldByName('PiQty').Value:=0;
|
||
CDS_Main.FieldByName('Qty').Value:=0;
|
||
CDS_Main.FieldByName('Qty1').Value:=0;
|
||
CDS_Main.FieldByName('RCQty').Value:=0;
|
||
CDS_Main.FieldByName('QtyUnit').Value:='M';
|
||
CDS_Main.FieldByName('RCQtyUnit').Value:='M';
|
||
CDS_Main.FieldByName('SPMF').Value:='';
|
||
CDS_Main.FieldByName('SPKZ').Value:='';
|
||
CDS_Main.FieldByName('RCgangNo').Value:='';
|
||
CDS_Main.Post;
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.QtyMXKeyPress(Sender: TObject; var Key: Char);
|
||
var
|
||
fMJID:string;
|
||
begin
|
||
If key=#13 then
|
||
begin
|
||
If CDS_Main.IsEmpty then
|
||
begin
|
||
application.MessageBox('<27><>Ʒ<EFBFBD><C6B7>Ϣû<CFA2><C3BB><EFBFBD><EFBFBD><EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8>Ϣ<EFBFBD><CFA2>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
IF strtofloatdef(QtyMX.Text,0)=0 then exit;
|
||
if GetLSNo(ADOQueryCmd,fMJID,'','APTM',4,1)=False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
try
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from WFB_MJJY A');
|
||
sql.Add('where 1=2');
|
||
open;
|
||
append;
|
||
Fieldbyname('mainID').Value:='';
|
||
Fieldbyname('subID').Value:='';
|
||
Fieldbyname('MJID').Value:=trim(fMJID);
|
||
Fieldbyname('MJXH').Value:=1;
|
||
Fieldbyname('MJQty1').Value:=strtofloatdef(QtyMX.Text,0);
|
||
Fieldbyname('MJlen').Value:=strtofloatdef(QtyMX.Text,0)+strtofloatdef(QtyFJ.Text,0);
|
||
Fieldbyname('APID').Value:=trim(CDS_Main.fieldbyname('SPID').AsString);
|
||
Fieldbyname('MJXH').Value:=1;
|
||
Fieldbyname('MJType').Value:='<27><>Ʒ';
|
||
Fieldbyname('MJStr2').Value:='δ<><CEB4><EFBFBD><EFBFBD>';
|
||
post;
|
||
end;
|
||
|
||
with CDS_MX do
|
||
begin
|
||
append;
|
||
Fieldbyname('MJID').Value:=trim(fMJID);
|
||
Fieldbyname('APID').Value:=trim(CDS_Main.fieldbyname('SPID').AsString);
|
||
Fieldbyname('MJQty1').Value:=strtofloatdef(QtyMX.Text,0);
|
||
Fieldbyname('MJlen').Value:=strtofloatdef(QtyMX.Text,0)+strtofloatdef(QtyFJ.Text,0);
|
||
post;
|
||
end;
|
||
|
||
with CDS_main do
|
||
begin
|
||
edit;
|
||
IF CDS_MX.IsEmpty then
|
||
Fieldbyname('Qty1').Value:=0
|
||
else
|
||
Fieldbyname('Qty1').Value:=tv2.DataController.Summary.FooterSummaryValues[0]-tv2.DataController.Summary.FooterSummaryValues[2];
|
||
post;
|
||
end;
|
||
{ IF varisnull(tv2.DataController.Summary.FooterSummaryValues[0]) then
|
||
begin
|
||
fRollNum:=0;
|
||
fQty:=0;
|
||
end
|
||
else
|
||
begin
|
||
fRollNum:=CDS_Sub.RecordCount;
|
||
fQty:=tv2.DataController.Summary.FooterSummaryValues[0];
|
||
end;
|
||
with CDS_Main do
|
||
begin
|
||
EDIT;
|
||
FieldByName('RollNum').Value:=fRollNum;
|
||
Fieldbyname('Qty').Value:=fQty;
|
||
FieldbyName('Money').Value:=format('%.0f',[FieldByName('Qty').AsFloat * FieldByName('Price').AsFloat]);
|
||
post;
|
||
end; }
|
||
QtyMX.Text:='';
|
||
except
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.TBPrintClick(Sender: TObject);
|
||
begin
|
||
IF CDS_Main.IsEmpty then exit;
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select MJID from WFB_MJJY');
|
||
sql.Add('where APID='''+trim(CDS_Main.fieldbyName('SPID').AsString)+''' ');
|
||
open;
|
||
end;
|
||
IF ADOQueryTemp.IsEmpty then exit;
|
||
while not ADOQueryTemp.Eof do
|
||
begin
|
||
sleep(200);
|
||
Printdata(ADOQueryTemp.fieldbyName('MJID').AsString);
|
||
ADOQueryTemp.next;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.Tv1CellClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
initMJID();
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.Tv2CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
IF CDS_MX.IsEmpty then exit;
|
||
with ADOQueryTemp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from WFB_MJJY where MJID='''+trim(CDS_MX.fieldbyName('MJID').AsString)+'''');
|
||
open;
|
||
end;
|
||
IF trim(ADOQueryTemp.fieldbyName('MJStr2').AsString)<>'δ<><CEB4><EFBFBD><EFBFBD>' then
|
||
begin
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>⣬<EFBFBD><E2A3AC><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('delete from WFB_MJJY where MJID='''+trim(CDS_MX.fieldbyName('MJID').AsString)+'''');
|
||
execsql;
|
||
end;
|
||
CDS_MX.Delete;
|
||
with CDS_main do
|
||
begin
|
||
edit;
|
||
IF CDS_MX.IsEmpty then
|
||
Fieldbyname('Qty1').Value:=0
|
||
else
|
||
Fieldbyname('Qty1').Value:=tv2.DataController.Summary.FooterSummaryValues[0]-tv2.DataController.Summary.FooterSummaryValues[2];
|
||
post;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.TBdelClick(Sender: TObject);
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from WFB_MJJY where isnull(APID,'''')='''+Trim(CDS_Main.fieldbyname('SPID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if not ADOQueryTemp.IsEmpty then
|
||
begin
|
||
Application.MessageBox('<27>Ѽ<EFBFBD><D1BC>鲻<EFBFBD><E9B2BB>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('delete from WFB_MJJY where APID='''+trim(CDS_Main.fieldbyName('SPID').AsString)+'''');
|
||
execsql;
|
||
end;
|
||
CDS_Main.Delete;
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.v2Column1PropertiesEditValueChanged(
|
||
Sender: TObject);
|
||
var
|
||
mvalue:string;
|
||
begin
|
||
mvalue:=TcxTextEdit(Sender).EditingText;
|
||
|
||
IF trim(mvalue)='' then exit;
|
||
|
||
IF rightBstr(trim(mvalue),1)<>'#'THEN
|
||
BEGIn
|
||
mvalue:=trim(mvalue)+'#';
|
||
END;
|
||
|
||
|
||
with CDS_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName('SPName').Value:=Trim(mvalue);
|
||
Post;
|
||
end;
|
||
|
||
|
||
with ADOQueryTemp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select * from KH_Zdy_Attachment A ');
|
||
sql.Add('where zdyName='+quotedstr(trim(CDS_Main.fieldbyname('SPName').AsString)));
|
||
open;
|
||
end;
|
||
IF ADOQueryTemp.IsEmpty then
|
||
begin
|
||
application.MessageBox('Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
||
with CDS_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName('SPName').Value:='';
|
||
Post;
|
||
end;
|
||
end
|
||
else
|
||
begin
|
||
with CDS_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName('C_CodeNameZW').Value:=Trim(ADOQueryTemp.fieldbyname('defnote3').AsString);
|
||
Post;
|
||
end;
|
||
end;
|
||
self.tv1.Controller.EditingController.ShowEdit();
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.v1Column15PropertiesEditValueChanged(
|
||
Sender: TObject);
|
||
var
|
||
mvalue:string;
|
||
begin
|
||
mvalue:=TcxTextEdit(Sender).EditingText;
|
||
|
||
IF trim(mvalue)='' then exit;
|
||
|
||
IF rightBstr(trim(mvalue),1)<>'#'THEN
|
||
BEGIn
|
||
mvalue:=trim(mvalue)+'#';
|
||
END;
|
||
|
||
|
||
with CDS_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName('SPColor').Value:=Trim(mvalue);
|
||
Post;
|
||
end;
|
||
self.tv1.Controller.EditingController.ShowEdit();
|
||
end;
|
||
|
||
procedure TfrmDJBRK_Edit.v1Column2PropertiesEditValueChanged(
|
||
Sender: TObject);
|
||
var
|
||
mvalue:string;
|
||
begin
|
||
mvalue:=TcxTextEdit(Sender).EditingText;
|
||
|
||
IF trim(mvalue)='' then exit;
|
||
|
||
with CDS_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName('batchNo').Value:=Trim(mvalue);
|
||
Post;
|
||
end;
|
||
self.tv1.Controller.EditingController.ShowEdit();
|
||
{
|
||
with ADOQueryTemp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select top 1 * from CK_SXPB_CR where batchNo='''+trim(CDS_Main.fieldbyName('batchNo').AsString)+''' ');
|
||
open;
|
||
IF not IsEmpty then
|
||
begin
|
||
with CDS_Main do
|
||
begin
|
||
Edit;
|
||
FieldByName('SPName').Value:=Trim(ADOQueryTemp.fieldbyName('SPName').AsString);
|
||
Post;
|
||
end;
|
||
end;
|
||
end; }
|
||
end;
|
||
|
||
end.
|