RTFormwork/项目代码/RTBasicsV1/F02染色计划单/U_DyePlanCardInput.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

904 lines
26 KiB
ObjectPascal
Raw Permalink 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_DyePlanCardInput;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, BtnEdit, ComCtrls, cxStyles, cxCustomData,
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ToolWin,
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGrid, ADODB, DBClient,
cxCalendar, cxContainer, cxTextEdit, cxCurrencyEdit, cxDropDownEdit,
cxCheckBox, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
dxSkinsDefaultPainters, dxDateRanges, U_BaseInput, System.ImageList,
Vcl.ImgList, dxBarBuiltInMenu, cxGridCustomPopupMenu, cxGridPopupMenu,
cxButtonEdit, Vcl.Menus, cxPC;
type
TfrmDyePlanCardInput = class(TfrmBaseInput)
CDS_1: TClientDataSet;
DS_1: TDataSource;
ADO_Car: TADOQuery;
ADOQueryCmd: TADOQuery;
ADOQueryTmp: TADOQuery;
GPM_1: TcxGridPopupMenu;
Panel3: TPanel;
Panel5: TPanel;
Panel4: TPanel;
cxGrid1: TcxGrid;
TV1: TcxGridDBTableView;
V1SSel: TcxGridDBColumn;
V1Column1: TcxGridDBColumn;
V1Column5: TcxGridDBColumn;
TV1Column1: TcxGridDBColumn;
TV1Column5: TcxGridDBColumn;
TV1Column6: TcxGridDBColumn;
TV1Column7: TcxGridDBColumn;
V1Column2: TcxGridDBColumn;
V1Column3: TcxGridDBColumn;
TV1Column4: TcxGridDBColumn;
TV1Column3: TcxGridDBColumn;
V1Column6: TcxGridDBColumn;
V1Column4: TcxGridDBColumn;
TV1Column2: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
ToolBar1: TToolBar;
ToolButton4: TToolButton;
ADOQueryMain: TADOQuery;
DS_2: TDataSource;
CDS_2: TClientDataSet;
PM_2: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
PM_1: TPopupMenu;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
GPM_2: TcxGridPopupMenu;
TV1Column10: TcxGridDBColumn;
ToolButton5: TToolButton;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
cxPageControl1: TcxPageControl;
cxTabSheet3: TcxTabSheet;
cxTabSheet4: TcxTabSheet;
cxGrid3: TcxGrid;
TV3: TcxGridDBTableView;
cxGridDBColumn8: TcxGridDBColumn;
cxGridDBColumn9: TcxGridDBColumn;
cxGridDBColumn10: TcxGridDBColumn;
cxGridDBColumn11: TcxGridDBColumn;
cxGridDBColumn12: TcxGridDBColumn;
cxGridDBColumn13: TcxGridDBColumn;
cxGridDBColumn14: TcxGridDBColumn;
cxGridDBColumn15: TcxGridDBColumn;
cxGridDBColumn16: TcxGridDBColumn;
cxGridDBColumn17: TcxGridDBColumn;
cxGridDBColumn18: TcxGridDBColumn;
cxGridDBColumn19: TcxGridDBColumn;
cxGridDBColumn20: TcxGridDBColumn;
cxGridDBColumn21: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
Panel6: TPanel;
Label20: TLabel;
PCID: TEdit;
GPM_3: TcxGridPopupMenu;
CDS_3: TClientDataSet;
DS_3: TDataSource;
TV3Column1: TcxGridDBColumn;
TV3Column2: TcxGridDBColumn;
Button1: TButton;
TV1Column12: TcxGridDBColumn;
TV1Column13: TcxGridDBColumn;
TV1Column14: TcxGridDBColumn;
TV1Column15: TcxGridDBColumn;
TV1Column16: TcxGridDBColumn;
TV1Column17: TcxGridDBColumn;
TV3Column3: TcxGridDBColumn;
TV3Column4: TcxGridDBColumn;
TV3Column5: TcxGridDBColumn;
TV3Column6: TcxGridDBColumn;
TV3Column7: TcxGridDBColumn;
TV3Column8: TcxGridDBColumn;
Label13: TLabel;
Label14: TLabel;
Label18: TLabel;
Label19: TLabel;
Re_Width: TEdit;
Re_GramWeight: TEdit;
Re_Color: TEdit;
Re_ColorNo: TEdit;
Label21: TLabel;
REUnit: TComboBox;
Label22: TLabel;
RePCType: TComboBox;
TV1Column18: TcxGridDBColumn;
TV1Column19: TcxGridDBColumn;
ADO_Order: TADOQuery;
CDS_Color: TClientDataSet;
pnlkpkk: TPanel;
Label1: TLabel;
Label7: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
PCTime: TDateTimePicker;
carnum: TcxCurrencyEdit;
PCPiece: TcxCurrencyEdit;
PCType: TComboBox;
PCQty: TEdit;
Button2: TButton;
pnlOrder: TPanel;
cxGrid2: TcxGrid;
TV2: TcxGridDBTableView;
v1Column14: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
cxGridDBColumn5: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
cxGridDBColumn6: TcxGridDBColumn;
Tv1Column9: TcxGridDBColumn;
v2Column1: TcxGridDBColumn;
cxGridDBColumn2: TcxGridDBColumn;
cxGridDBColumn1: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn4: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
Tv1Column8: TcxGridDBColumn;
Tv1Column11: TcxGridDBColumn;
cxGrid2Level1: TcxGridLevel;
Label23: TLabel;
OrderNo: TBtnEditA;
Label4: TLabel;
Label9: TLabel;
Label11: TLabel;
Label10: TLabel;
C_Width: TEdit;
C_GramWeight: TEdit;
C_COLORNO: TEdit;
C_Color: TComboBox;
Label24: TLabel;
OrdQty: TEdit;
OrdUnit: TEdit;
TV3Column9: TcxGridDBColumn;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
procedure MenuItem2Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure PCIDKeyPress(Sender: TObject; var Key: Char);
procedure Button1Click(Sender: TObject);
procedure TV3DblClick(Sender: TObject);
procedure OrderNoBtnClick(Sender: TObject);
procedure C_ColorChange(Sender: TObject);
procedure TV3Column1PropertiesEditValueChanged(Sender: TObject);
private
FMainID: string;
FRollNum: integer;
FGC_BatchNo, FGC_Piece, FGC_STKID, FGC_Position: string;
FFromCoNo, FFromCoName, FSaleser, FC_Name: string;
procedure InitCard();
procedure InitOrder();
procedure InitGreyClothStk();
function GetCard(): Boolean;
procedure InitRepairCard(PPCID: string);
{ Private declarations }
public
FWorkshop, FPCIDS: string;
{ Public declarations }
end;
var
frmDyePlanCardInput: TfrmDyePlanCardInput;
implementation
uses
U_DataLink, U_ZDYHelp, U_RTFun, U_DyePlanForCardSel, U_DyeProcessSel,
U_DyeTechnicsSel, U_DyePlanCardSel, U_DyeGreyClothStkSel, U_DyeCardGlideEdit;
{$R *.dfm}
function TfrmDyePlanCardInput.GetCard(): Boolean;
var
MCustNo, MC_Name: string;
begin
try
CDS_3.DisableControls;
if CDS_3.IsEmpty then
raise Exception.Create('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>̿<EFBFBD><CCBF><EFBFBD>');
CDS_3.First;
while not CDS_3.eof do
begin
if Trim(MCustNo) = '' then
begin
MCustNo := trim(CDS_3.FieldByName('CustNo').AsString);
MC_Name := trim(CDS_3.FieldByName('C_Name').AsString);
end
else
begin
if MCustNo <> trim(CDS_3.FieldByName('CustNo').AsString) then
raise Exception.Create('<27><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>');
if MC_Name <> trim(CDS_3.FieldByName('C_Name').AsString) then
raise Exception.Create('<27><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>');
end;
if CDS_3.FieldByName('MvPiece').AsFloat > CDS_3.FieldByName('PSC_StkPiece').AsFloat then
raise Exception.Create('<27><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD>');
if CDS_3.FieldByName('MvQty').AsFloat > CDS_3.FieldByName('PSC_StkQty').AsFloat then
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD>');
CDS_3.Next;
end;
CDS_3.EnableControls;
Result := True;
except
Result := false;
CDS_3.EnableControls;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmDyePlanCardInput.InitOrder();
var
fsj: string;
begin
with Ado_Order do
begin
close;
sql.Clear;
sql.Add('select A.*,B.*');
sql.Add('from Dye_Plan_sub A ');
sql.Add('inner join Dye_Plan_Main B on B.MainID=A.mainID ');
sql.Add('where A.MainID=''' + trim(FMainID) + ''' ');
open;
end;
SCreateCDS(Ado_Order, CDS_Color);
SInitCDSData(Ado_Order, CDS_Color);
if not Ado_Order.IsEmpty then
begin
fsj := 'select distinct(C_Color) name from Dye_Plan_sub where mainid= ' + QuotedStr(Trim(FMainID));
SInitComBoxBySql(ADOQueryTmp, C_COLOR, False, fsj);
SCSHData(Ado_Order, pnlOrder, 2);
FC_Name := Trim(Ado_Order.FieldByName('C_Name').AsString);
FFromCoNo := Trim(Ado_Order.FieldByName('CustNo').AsString);
FFromCoName := Trim(Ado_Order.FieldByName('CustName').AsString);
FGC_BatchNo := Trim(Ado_Order.FieldByName('GC_BatchNo').AsString);
FGC_Piece := Trim(Ado_Order.FieldByName('GC_Piece').AsString);
FGC_STKID := Trim(Ado_Order.FieldByName('GC_STKID').AsString);
FGC_Position := Trim(Ado_Order.FieldByName('GC_Position').AsString);
// FRollNum :=Trim(Ado_Order.FieldByName('').AsString);
end;
end;
procedure TfrmDyePlanCardInput.InitRepairCard(PPCID: string);
begin
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select A.*');
sql.Add(',GlideList=[dbo].[F_Dye_Card_GlideList](A.PCID) ');
sql.Add(',MvPiece=PSC_StkPiece,MvQty=PSC_StkQty ');
sql.Add('from Dye_Plan_Card A ');
if TRIM(PPCID) = '' then
sql.Add('where 1=2 ')
else
sql.Add('where PCID= ' + Quotedstr(trim(PPCID)));
open;
end;
if TRIM(PPCID) = '' then
begin
SCreateCDS(ADOQueryTmp, CDS_3);
end
else
begin
SInitCDSData(ADOQueryTmp, CDS_3);
end;
end;
procedure TfrmDyePlanCardInput.InitGreyClothStk();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
Close;
sql.Clear;
sql.Add(' select A.* ');
sql.Add(' from BS_Cloth_IO A where isnull(STKName,'''')=''Ⱦɫ<C8BE><C9AB><EFBFBD><EFBFBD>'' ');
SQL.Add(' and A.IOFlag=''<27><><EFBFBD><EFBFBD>'' ');
SQL.Add(' and EXISTS(select * from [dbo].[F_Tool_SplitString](' + quotedstr(FGC_STKID) + ','';'' ) X where X.RTValue=A.StkId) ');
// ShowMessage(sql.Text);
Open;
end;
SCreateCDS(ADOQueryMain, CDS_2);
SInitCDSData(ADOQueryMain, CDS_2);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmDyePlanCardInput.MenuItem1Click(Sender: TObject);
begin
SelOKNo(CDS_1, True);
end;
procedure TfrmDyePlanCardInput.MenuItem2Click(Sender: TObject);
begin
SelOKNo(CDS_1, False);
end;
procedure TfrmDyePlanCardInput.N1Click(Sender: TObject);
begin
SelOKNo(CDS_2, True);
end;
procedure TfrmDyePlanCardInput.N2Click(Sender: TObject);
begin
SelOKNo(CDS_2, False);
end;
procedure TfrmDyePlanCardInput.OrderNoBtnClick(Sender: TObject);
begin
frmProductOrderListSel := TfrmProductOrderListSel.create(self);
with frmProductOrderListSel do
begin
FWorkshop := self.FWorkshop;
if ShowModal = 1 then
begin
fmainID := Order_Main.fieldbyname('mainID').asstring;
InitOrder();
InitGreyClothStk();
// InitCard();
// initGlide();
end;
free;
end;
end;
procedure TfrmDyePlanCardInput.PCIDKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
if Trim(PCID.Text) = '' then
exit;
InitRepairCard(PCID.Text);
PCID.Text := '';
end;
end;
procedure TfrmDyePlanCardInput.InitCard();
begin
with Ado_car do
begin
close;
sql.Clear;
sql.Add('select A.*');
sql.Add(',GlideList=[dbo].[F_Dye_Card_GlideList](A.PCID) ');
sql.Add('from Dye_Plan_Card A ');
sql.Add('where EXISTS(select X.RTValue from [dbo].[F_Tool_SplitString](' + Quotedstr(trim(FPCIDS)) + ', '';'' ) X where X.RTValue=A.PCID ) ');
open;
end;
SCreateCDS(Ado_car, CDS_1);
SInitCDSData(Ado_car, CDS_1);
end;
procedure TfrmDyePlanCardInput.FormDestroy(Sender: TObject);
begin
inherited;
frmDyePlanCardInput := nil;
end;
procedure TfrmDyePlanCardInput.Button1Click(Sender: TObject);
var
maxId: string;
begin
PCID.SetFocus;
if not GetCard() then
Exit;
if GetLSNo(ADOQueryCmd, maxId, 'CZ', 'Dye_Plan_Card', 3, 1) = False then
begin
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
Exit;
end;
FPCIDS := FPCIDS + maxId + ';';
try
ADOQueryCmd.Connection.BeginTrans;
CDS_3.DisableConstraints;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('select * from Dye_Plan_Card A where 1=2');
Open;
Append;
FieldByName('Filler').Value := trim(DName);
FieldByName('Workshop').Value := trim(FWorkshop);
FieldByName('PCType').Value := trim(RePCType.Text);
FieldByName('PCID').Value := trim(maxId);
FieldByName('PCTime').Value := formatdateTime('yyyy-MM-dd', now());
FieldByName('GC_BatchNo').Value := '';
FieldByName('GC_Piece').Value := '';
FieldByName('GC_STKID').Value := '';
FieldByName('GC_Position').Value := '';
FieldByName('C_Name').Value := trim(CDS_3.FieldByName('C_Name').AsString);
FieldByName('CustNo').Value := trim(CDS_3.FieldByName('CustNo').AsString);
FieldByName('CustName').Value := trim(CDS_3.FieldByName('CustName').AsString);
FieldByName('MainId').Value := trim(CDS_3.FieldByName('MainId').AsString);
FieldByName('SubId').Value := trim(CDS_3.FieldByName('SubId').AsString);
FieldByName('C_GramWeight').Value := trim(Re_GramWeight.Text);
FieldByName('C_Width').Value := trim(Re_Width.Text);
FieldByName('C_Color').Value := trim(Re_Color.Text);
FieldByName('PCUnit').Value := trim(ReUnit.Text);
FieldByName('C_ColorNo').Value := trim(Re_ColorNo.Text);
FieldByName('PCPiece').Value := 0;
FieldByName('PCQty').Value := 0;
post;
end;
with CDS_3 do
begin
first;
while not Eof do
begin
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('select * from Dye_Plan_Card_Move A where 1=2');
Open;
Append;
FieldByName('Filler').Value := trim(DName);
FieldByName('FromID').Value := trim(CDS_3.FieldByName('PCID').AsString);
FieldByName('ToID').Value := maxId;
FieldByName('MvPiece').Value := CDS_3.FieldByName('MvPiece').AsFloat;
FieldByName('MvQty').Value := CDS_3.FieldByName('MvQty').AsFloat;
post;
end;
Next;
end;
end;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_Dye_Card_Move ');
Sql.Add('@PCID=' + quotedstr(trim(maxId)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
begin
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
ADOQueryCmd.Connection.CommitTrans;
CDS_3.EnableConstraints;
except
ADOQueryCmd.Connection.RollbackTrans;
CDS_3.EnableConstraints;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
InitCard();
InitRepairCard('');
end;
procedure TfrmDyePlanCardInput.Button2Click(Sender: TObject);
var
i, k, fhxInt: integer;
maxId: string;
begin
if trim(C_Color.Text) = '' then
begin
application.MessageBox('<27><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
if trim(C_Width.Text) = '' then
begin
application.MessageBox('<27>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
if trim(C_GramWeight.Text) = '' then
begin
application.MessageBox('<27><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
if (StrToFloatDef(PCPiece.Text, 0) + StrToFloatDef(PCQty.Text, 0)) = 0 then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܶ<EFBFBD>Ϊ<EFBFBD>㣡', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
if strtointdef(trim(carNum.text), 0) <= 1 then
k := 1
else
k := strtointdef(trim(carNum.text), 0);
CDS_Color.Locate('C_Color', C_Color.Text, []);
CDS_1.Last;
for i := 1 to k do
begin
if GetLSNo(ADOQueryCmd, maxId, 'CZ', 'Dye_Plan_Card', 3, 1) = False then
begin
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
Exit;
end;
FPCIDS := FPCIDS + maxId + ';';
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('select * from Dye_Plan_Card A where 1=2');
Open;
Append;
FieldByName('OrderNo').Value := OrderNo.Text;
FieldByName('SubId').Value := CDS_Color.FieldByName('SubId').Value;
FieldByName('Mainid').Value := FMainid;
FieldByName('Filler').Value := trim(DName);
FieldByName('Workshop').Value := trim(FWorkshop);
FieldByName('PCType').Value := trim(PCType.Text);
FieldByName('PCID').Value := trim(maxId);
FieldByName('PCTime').Value := formatdateTime('yyyy-MM-dd', PCTime.DateTime);
FieldByName('GC_BatchNo').Value := trim(FGC_BatchNo);
FieldByName('GC_Piece').Value := trim(FGC_Piece);
FieldByName('GC_STKID').Value := trim(FGC_STKID);
FieldByName('GC_Position').Value := trim(FGC_Position);
FieldByName('CustNo').Value := trim(FFromCoNo);
FieldByName('CustName').Value := trim(FFromCoName);
FieldByName('Saleser').Value := trim(FSaleser);
FieldByName('C_Name').Value := trim(FC_Name);
FieldByName('C_GramWeight').Value := trim(C_GramWeight.Text);
FieldByName('C_Width').Value := trim(C_Width.Text);
FieldByName('C_Color').Value := trim(C_Color.Text);
FieldByName('PCUnit').Value := trim(OrdUnit.Text);
FieldByName('C_ColorNo').Value := trim(C_ColorNo.Text);
FieldByName('PCPiece').Value := StrtoIntDef(PCPiece.Text, 0);
FieldByName('PCQty').Value := StrtoFloatDef(PCQty.Text, 0);
post;
end;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_Dye_GreyCloth_Out ');
Sql.Add('@PCID=' + quotedstr(trim(maxId)));
Sql.Add(',@Filler=' + quotedstr(trim(DName)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
begin
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
InitCard();
InitGreyClothStk();
end;
procedure TfrmDyePlanCardInput.C_ColorChange(Sender: TObject);
begin
CDS_Color.Locate('C_Color', C_Color.Text, []);
C_COLOR.Text := CDS_Color.FieldByName('C_COLOR').AsString;
OrdQty.Text := CDS_Color.FieldByName('OrdQty').AsString;
OrdUnit.Text := CDS_Color.FieldByName('OrdUnit').AsString;
C_COLORNO.Text := CDS_Color.FieldByName('C_COLORNO').AsString;
end;
procedure TfrmDyePlanCardInput.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := cahide;
end;
procedure TfrmDyePlanCardInput.FormCreate(Sender: TObject);
begin
inherited;
PCTime.Date := DServerDate;
end;
procedure TfrmDyePlanCardInput.FormShow(Sender: TObject);
begin
inherited;
ReadCxGrid(self.Caption + 'TV1', Tv1, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
ReadCxGrid(self.Caption + 'TV2', Tv2, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
InitCard();
InitGreyClothStk();
InitRepairCard('');
end;
procedure TfrmDyePlanCardInput.ToolButton1Click(Sender: TObject);
var
MPCIDS: string;
begin
if CDS_1.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
with CDS_1 do
begin
DisableControls;
First;
while not Eof do
begin
if Fieldbyname('Ssel').AsBoolean then
begin
MPCIDS := MPCIDS + trim(CDS_1.FieldByName('PCID').AsString) + ';';
end;
Next;
end;
EnableControls;
end;
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select distinct GX=[dbo].[F_Dye_Card_GlideList](A.RTValue) from [dbo].[F_Tool_SplitString](' + quotedstr(MPCIDS) + ','';'') A ');
open;
end;
if ADOQueryTmp.RecordCount > 1 then
begin
Application.MessageBox('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>༭!', '<27><>ʾ', 0);
Exit;
end;
try
frmDyeCardGlideEdit := TfrmDyeCardGlideEdit.Create(Application);
with frmDyeCardGlideEdit do
begin
FPCIDS := MPCIDS;
FWorkshop := self.FWorkshop;
if ShowModal = 1 then
begin
InitCard();
end;
end;
finally
frmDyeCardGlideEdit.Free;
end;
end;
procedure TfrmDyePlanCardInput.ToolButton2Click(Sender: TObject);
begin
WriteCxGrid(self.Caption + 'TV1', Tv1, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
WriteCxGrid(self.Caption + 'TV2', Tv2, '<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmDyePlanCardInput.ToolButton3Click(Sender: TObject);
begin
close;
end;
procedure TfrmDyePlanCardInput.ToolButton4Click(Sender: TObject);
begin
if CDS_1.IsEmpty then
exit;
if CDS_1.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
try
with CDS_1 do
begin
DisableControls;
First;
while not Eof do
begin
if Fieldbyname('Ssel').AsBoolean then
begin
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_Dye_Card_Del ');
Sql.Add('@PCIDS=' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString)));
Sql.Add(',@DCode=' + quotedstr(Trim(DCode)));
Sql.Add(',@DName=' + quotedstr(Trim(DName)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
if (Trim(CDS_1.fieldbyname('PCType').AsString) = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>') or (Trim(CDS_1.fieldbyname('PCType').AsString) = <><C7B0><EFBFBD><EFBFBD>') then
begin
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_Dye_GreyCloth_Out_Del ');
Sql.Add('@PCID=' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end
else
begin
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_Dye_Card_Move_Del ');
Sql.Add('@PCID=' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
raise Exception.Create(PChar(Exception(ExceptObject).Message));
end;
end;
Next;
EnableControls;
end;
InitCard();
InitGreyClothStk();
end;
except
CDS_1.EnableControls;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmDyePlanCardInput.ToolButton5Click(Sender: TObject);
begin
carnum.SetFocus;
try
CDS_1.DisableControls;
CDS_1.First;
while not CDS_1.Eof do
begin
if CDS_1.Fieldbyname('Ssel').AsBoolean then
begin
ADOQueryCmd.Connection.BeginTrans;
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from Dye_Plan_Card A');
sql.Add('where PCID=''' + trim(CDS_1.fieldbyname('PCID').AsString) + '''');
open;
edit;
FieldByName('Editer').Value := Trim(DName);
FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTmp);
RTSetSaveDataCDS(ADOQueryCmd, Tv1, CDS_1, 'Dye_Plan_Card', 0);
post;
end;
if (Trim(CDS_1.fieldbyname('PCType').AsString) = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>') or (Trim(CDS_1.fieldbyname('PCType').AsString) = <><C7B0><EFBFBD><EFBFBD>') then
begin
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_Dye_GreyCloth_Out_Del ');
Sql.Add('@PCID=' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_Dye_GreyCloth_Out ');
Sql.Add('@PCID=' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString)));
Sql.Add(',@Filler=' + quotedstr(trim(DName)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
begin
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
end
else
begin
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_Dye_Card_Move ');
Sql.Add('@PCID=' + quotedstr(Trim(CDS_1.fieldbyname('PCID').AsString)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
begin
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
end;
ADOQueryCmd.Connection.CommitTrans;
except
ADOQueryCmd.Connection.RollbackTrans;
raise Exception.Create(PChar(Exception(ExceptObject).Message));
end;
end;
CDS_1.Next;
end;
CDS_1.EnableControls;
InitCard();
InitGreyClothStk();
except
CDS_1.EnableControls;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmDyePlanCardInput.TV3Column1PropertiesEditValueChanged(Sender: TObject);
var
mvalue: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
with CDS_3 do
begin
Edit;
FieldByName('MvPiece').Value := STRTOFLOATDEF(mvalue, 0);
if FieldByName('PSC_StkPiece').AsFloat > 0 then
FieldByName('MvQty').Value := STRTOFLOATDEF(mvalue, 0) * (FieldByName('PSC_StkQty').AsFloat / FieldByName('PSC_StkPiece').AsFloat)
else
FieldByName('MvQty').Value := 0;
Post;
end;
Tv3.Controller.EditingController.ShowEdit();
end;
procedure TfrmDyePlanCardInput.TV3DblClick(Sender: TObject);
begin
CDS_3.Delete;
end;
end.