373 lines
10 KiB
ObjectPascal
373 lines
10 KiB
ObjectPascal
unit U_TatWBPlanCardInPut;
|
||
|
||
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, cxCalendar, cxButtonEdit, cxSplitter, RM_Common, RM_Class,
|
||
RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, cxTextEdit, cxCheckBox, cxPC,
|
||
Menus, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu,
|
||
dxDateRanges, BtnEdit, U_BaseInput, System.ImageList, Vcl.ImgList,
|
||
dxScrollbarAnnotations, cxImageList, dxSkinsCore,
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
dxSkinOffice2013White,
|
||
|
||
|
||
dxSkinSharpPlus,
|
||
|
||
dxSkinsDefaultPainters,
|
||
|
||
dxSkinWXI, ;
|
||
|
||
type
|
||
TfrmTatWBPlanCardInPut = class(TfrmBaseInput)
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
RMXLSExport1: TRMXLSExport;
|
||
Panel2: TPanel;
|
||
DS_1: TDataSource;
|
||
CDS_1: TClientDataSet;
|
||
PopupMenu1: TPopupMenu;
|
||
N2: TMenuItem;
|
||
N3: TMenuItem;
|
||
Panel4: TPanel;
|
||
Panel1: TPanel;
|
||
Label8: TLabel;
|
||
Label2: TLabel;
|
||
Label6: TLabel;
|
||
Label4: TLabel;
|
||
WB_YarnQty: TEdit;
|
||
edtCardQty: TEdit;
|
||
WB_Spec: TEdit;
|
||
WB_YarnLen: TEdit;
|
||
Note: TRichEdit;
|
||
GPM_2: TcxGridPopupMenu;
|
||
Label7: TLabel;
|
||
WBData: TDateTimePicker;
|
||
Label10: TLabel;
|
||
FtyCoName: TBtnEditC;
|
||
Label18: TLabel;
|
||
TWPId: TEdit;
|
||
Label19: TLabel;
|
||
Label12: TLabel;
|
||
WBNo: TBtnEditC;
|
||
Panel3: TPanel;
|
||
cxPageControl1: TcxPageControl;
|
||
cxGrid1: TcxGrid;
|
||
TV1: TcxGridDBTableView;
|
||
v2Column10: TcxGridDBColumn;
|
||
cxGridDBColumn1: TcxGridDBColumn;
|
||
v2Column2: TcxGridDBColumn;
|
||
v2Column6: TcxGridDBColumn;
|
||
TV1Column2: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
Panel5: TPanel;
|
||
Panel6: TPanel;
|
||
Label21: TLabel;
|
||
cxGrid2: TcxGrid;
|
||
TV2: TcxGridDBTableView;
|
||
cxGridDBColumn2: TcxGridDBColumn;
|
||
cxGridDBColumn3: TcxGridDBColumn;
|
||
cxGridDBColumn4: TcxGridDBColumn;
|
||
cxGridDBColumn5: TcxGridDBColumn;
|
||
cxGridDBColumn8: TcxGridDBColumn;
|
||
cxGridLevel2: TcxGridLevel;
|
||
ToolBar1: TToolBar;
|
||
TBSave: TToolButton;
|
||
ToolButton2: TToolButton;
|
||
TBClose: TToolButton;
|
||
CDS_2: TClientDataSet;
|
||
DS_2: TDataSource;
|
||
GPM_1: TcxGridPopupMenu;
|
||
ToolButton1: TToolButton;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBSaveClick(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FtyCoNameBtnUpClick(Sender: TObject);
|
||
procedure FtyCoNameBtnDnClick(Sender: TObject);
|
||
procedure WB_CodeBtnDnClick(Sender: TObject);
|
||
procedure WB_MachNoBtnUpClick(Sender: TObject);
|
||
procedure WBNoBtnUpClick(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
private
|
||
function TestData(): Boolean;
|
||
procedure InitYarn();
|
||
{ Private declarations }
|
||
public
|
||
FTWPId, FWB_Type: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmTatWBPlanCardInPut: TfrmTatWBPlanCardInPut;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_ZDYHelp, U_LabelPrint, U_CompanySel, U_YarnInfoSel,
|
||
U_WarpBeamInfoSel;
|
||
|
||
{$R *.dfm}
|
||
procedure TfrmTatWBPlanCardInPut.InitYarn();
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.* ');
|
||
sql.Add(' from Tat_WB_Plan A ');
|
||
sql.Add(' where A.TWPId=''' + Trim(FTWPId) + '''');
|
||
Open;
|
||
end;
|
||
if FWB_Type = '<27><><EFBFBD><EFBFBD>' then
|
||
begin
|
||
WB_Spec.Text := ADOQueryTemp.FieldByName('WB_Spec').AsString;
|
||
edtCardQty.Text := ADOQueryTemp.FieldByName('WB_Qty').AsString;
|
||
WB_YarnLen.Text := ADOQueryTemp.FieldByName('WB_YarnLen').AsString;
|
||
WB_YarnQty.Text := ADOQueryTemp.FieldByName('WB_YarnQty').AsString;
|
||
end
|
||
else
|
||
begin
|
||
WB_Spec.Text := ADOQueryTemp.FieldByName('WB_Spec').AsString;
|
||
WB_YarnQty.Text := ADOQueryTemp.FieldByName('WB_Qty_YJMJZGS').AsString;
|
||
edtCardQty.Text := ADOQueryTemp.FieldByName('WB_Qty_YJJZZS').AsString;
|
||
WB_YarnLen.Text := ADOQueryTemp.FieldByName('WB_Qty_YJMJZMS').AsString;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.* ');
|
||
sql.Add(' from Tat_WB_Plan_Yarn A ');
|
||
sql.Add(' where YRType=''<27><><EFBFBD>ᾭ˿'' and A.TWPId=''' + Trim(FTWPId) + '''');
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADOQueryTemp, CDS_1);
|
||
SInitCDSData(ADOQueryTemp, CDS_1);
|
||
SCreateCDS(ADOQueryTemp, CDS_2);
|
||
SInitCDSData(ADOQueryTemp, CDS_2);
|
||
end;
|
||
|
||
function TfrmTatWBPlanCardInPut.TestData(): Boolean;
|
||
begin
|
||
try
|
||
|
||
if StrToIntDef(WB_YarnQty.Text, 0) = 0 then
|
||
raise Exception.Create('ͷ<>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
|
||
if StrToIntDef(WB_YarnLen.Text, 0) = 0 then
|
||
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȳ<EFBFBD><C8B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>');
|
||
|
||
Result := True;
|
||
except
|
||
Result := false;
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlanCardInPut.WBNoBtnUpClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmWarpBeamInfoSel := TfrmWarpBeamInfoSel.Create(Application);
|
||
with frmWarpBeamInfoSel do
|
||
begin
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
Self.WBNo.Text := Trim(frmWarpBeamInfoSel.CDS_Main.fieldbyname('WBNo').AsString);
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmWarpBeamInfoSel.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlanCardInPut.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlanCardInPut.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
ReadCxGrid(Trim(self.Caption) + 'Tv2', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD>Ῠ');
|
||
WBData.DateTime := SGetServerDate(ADOQueryTemp);
|
||
|
||
TWPId.Text := FTWPId;
|
||
|
||
if FWB_Type = '<27><><EFBFBD><EFBFBD>' then
|
||
TV1.OptionsData.Editing := False;
|
||
|
||
InitYarn();
|
||
end;
|
||
|
||
procedure TfrmTatWBPlanCardInPut.FtyCoNameBtnDnClick(Sender: TObject);
|
||
begin
|
||
TBtnEditC(Sender).TxtCode := '';
|
||
TBtnEditC(Sender).Text := '';
|
||
end;
|
||
|
||
procedure TfrmTatWBPlanCardInPut.FtyCoNameBtnUpClick(Sender: TObject);
|
||
begin
|
||
try
|
||
frmCompanySel := TfrmCompanySel.Create(Application);
|
||
with frmCompanySel do
|
||
begin
|
||
FCoType := '<27><>Ӧ<EFBFBD><D3A6>';
|
||
if ShowModal = 1 then
|
||
begin
|
||
FtyCoName.TxtCode := Trim(CDS_1.fieldbyname('CoCode').AsString);
|
||
FtyCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmCompanySel.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlanCardInPut.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlanCardInPut.TBSaveClick(Sender: TObject);
|
||
var
|
||
MWBCID: string;
|
||
i, j: integer;
|
||
begin
|
||
if TestData() = false then
|
||
exit;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
////////////////// <20><><EFBFBD><EFBFBD><EFBFBD>Ῠ //////////////////////
|
||
if GetLSNo(ADOQueryTemp, MWBCID, 'ZK1', 'Tat_WB_Card', 3, 1) = False then
|
||
begin
|
||
raise Exception.Create('ȡ<><C8A1>Ʊ<EFBFBD><C6B1>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!');
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' insert into Tat_WB_Card(WBCID,WBNo,TWPId,WB_Spec,WB_YarnQty,WB_YarnLen ');
|
||
sql.Add(' ,WBData,FtyCoNo,FtyCoName');
|
||
sql.Add(' ,WB_Type,Note,FillId,Filler) values');
|
||
|
||
for i := 1 to StrToIntdef(edtCardQty.Text, 1) do
|
||
begin
|
||
if i > 1 then
|
||
sql.Add(',');
|
||
sql.Add(' (' + Quotedstr(Trim(MWBCID) + IntToStr(i)));
|
||
sql.Add(',' + Quotedstr(Trim(WBNO.Text)));
|
||
sql.Add(',' + Quotedstr(Trim(FTWPId)));
|
||
sql.Add(',' + Quotedstr(Trim(WB_Spec.Text)));
|
||
sql.Add(',' + (Trim(WB_YarnQty.Text)));
|
||
sql.Add(',' + (Trim(WB_YarnLen.Text)));
|
||
sql.Add(',' + Quotedstr(Trim(FormatDateTime('yyyy-MM-dd', WBData.DateTime))));
|
||
sql.Add(',' + Quotedstr(Trim(FtyCoName.TxtCode)));
|
||
sql.Add(',' + Quotedstr(Trim(FtyCoName.Text)));
|
||
sql.Add(',' + Quotedstr(FWB_Type));
|
||
sql.Add(',' + Quotedstr(Trim(Note.Text)));
|
||
sql.Add(',' + Quotedstr(Trim(DCode)));
|
||
sql.Add(',' + Quotedstr(Trim(DName)));
|
||
sql.Add(' )');
|
||
|
||
end;
|
||
|
||
for i := 1 to StrToIntdef(edtCardQty.Text, 1) do
|
||
begin
|
||
sql.Add(' insert into Tat_WB_Card_Yarn(YRId,WBCID,Y_Code,Y_Name,Brand,Y_Color,Y_Ratio');
|
||
sql.Add(',Filler) values');
|
||
CDS_1.DisableControls;
|
||
CDS_1.first;
|
||
j := 1;
|
||
while not CDS_1.eof do
|
||
begin
|
||
if j > 1 then
|
||
sql.Add(',');
|
||
sql.Add(' (' + Quotedstr(Trim(MWBCID) + IntToStr(i) + IntToStr(j)));
|
||
sql.Add(',' + Quotedstr(Trim(MWBCID) + IntToStr(i)));
|
||
sql.Add(',' + Quotedstr(Trim(CDS_1.FieldByName('Y_Code').AsString)));
|
||
sql.Add(',' + Quotedstr(Trim(CDS_1.FieldByName('Y_Name').AsString)));
|
||
sql.Add(',' + Quotedstr(Trim(CDS_1.FieldByName('Brand').AsString)));
|
||
sql.Add(',' + Quotedstr(Trim(CDS_1.FieldByName('Y_Color').AsString)));
|
||
sql.Add(',' + Quotedstr(Trim(CDS_1.FieldByName('Y_Ratio').AsString)));
|
||
sql.Add(',' + Quotedstr(Trim(DName)));
|
||
sql.Add(' )');
|
||
|
||
CDS_1.Next;
|
||
j := j + 1;
|
||
end;
|
||
CDS_1.enableControls;
|
||
end;
|
||
// ShowMessage(sql.Text);
|
||
ExecSQL;
|
||
end;
|
||
|
||
////////////////// <20><><EFBFBD><EFBFBD><EFBFBD>Ῠ //////////////////////
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
ModalResult := 1;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlanCardInPut.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
CDS_1.Delete;
|
||
end;
|
||
|
||
procedure TfrmTatWBPlanCardInPut.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(Trim(self.Caption) + 'Tv2', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD>Ῠ');
|
||
end;
|
||
|
||
procedure TfrmTatWBPlanCardInPut.WB_CodeBtnDnClick(Sender: TObject);
|
||
begin
|
||
TBtnEditC(Sender).Text := '';
|
||
TBtnEditC(Sender).TxtCode := '';
|
||
|
||
end;
|
||
|
||
procedure TfrmTatWBPlanCardInPut.WB_MachNoBtnUpClick(Sender: TObject);
|
||
var
|
||
fsj: string;
|
||
FWZ: Integer;
|
||
begin
|
||
fsj := Trim(TEdit(Sender).Hint);
|
||
FWZ := Pos('/', fsj);
|
||
try
|
||
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag := Copy(fsj, 1, FWZ - 1);
|
||
flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ);
|
||
if ShowModal = 1 then
|
||
begin
|
||
TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
end.
|
||
|