unit U_TatClothInList_ZDDY; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView, cxGridBandedTableView, cxGridDBBandedTableView, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridDBTableView, cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient, cxDropDownEdit, cxCheckBox, RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, Menus, cxCalendar, MovePanel, Math, Clipbrd, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, cxTextEdit, dxDateRanges, dxBarBuiltInMenu, U_BaseList, cxPC, System.StrUtils, cxContainer, dxCore, cxDateUtils, cxMaskEdit, dxScrollbarAnnotations, cxProgressBar, dxSkinsCore, dxSkinsDefaultPainters; type TfrmTatClothInList_ZDDY = class(TfrmBaseList) ToolBar1: TToolBar; TBRafresh: TToolButton; TBExport: TToolButton; TBClose: TToolButton; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; DS_1: TDataSource; GPM_1: TcxGridPopupMenu; CDS_1: TClientDataSet; ToolButton4: TToolButton; PM_1: TPopupMenu; PM11: TMenuItem; ToolButton1: TToolButton; N1: TMenuItem; N2: TMenuItem; cxPageControl1: TcxPageControl; cxTabSheet1: TcxTabSheet; Pnl_F2: TPanel; Label1: TLabel; Label4: TLabel; Label6: TLabel; Label9: TLabel; Label13: TLabel; DateTimePicker3: TDateTimePicker; DateTimePicker4: TDateTimePicker; Edit1: TcxTextEdit; Edit2: TcxTextEdit; Edit4: TcxTextEdit; BatchNo: TcxTextEdit; Edit8: TcxTextEdit; GPM_2: TcxGridPopupMenu; CDS_2: TClientDataSet; DS_2: TDataSource; cxGrid2: TcxGrid; TV2: TcxGridDBTableView; cxGridDBColumn2: TcxGridDBColumn; cxGridDBColumn3: TcxGridDBColumn; cxGridDBColumn4: TcxGridDBColumn; cxGridDBColumn7: TcxGridDBColumn; cxGridDBColumn8: TcxGridDBColumn; cxGridDBColumn9: TcxGridDBColumn; cxGridDBColumn10: TcxGridDBColumn; cxGridDBColumn11: TcxGridDBColumn; cxGridDBColumn12: TcxGridDBColumn; cxGridDBColumn13: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; PM_2: TPopupMenu; MenuItem3: TMenuItem; TV2Column1: TcxGridDBColumn; TV2Column5: TcxGridDBColumn; BegDate2: TcxDateEdit; EndDate2: TcxDateEdit; chk_F2: TcxCheckBox; TV2Column2: TcxGridDBColumn; TV2Column3: TcxGridDBColumn; TV2Column4: TcxGridDBColumn; Label2: TLabel; IONO: TcxTextEdit; Timer1: TTimer; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure orderNoKeyPress(Sender: TObject; var Key: Char); procedure TBRKCXClick(Sender: TObject); procedure JYTypeChange(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure cxPageControl1Change(Sender: TObject); procedure CDS_1BeforeOpen(DataSet: TDataSet); procedure Tv1DataControllerFilterBeforeChange(Sender: TcxDBDataFilterCriteria; ADataSet: TDataSet; const AFilterText: string); procedure Tv1TcxGridDBDataControllerTcxDataSummaryFooterSummaryItems6GetText(Sender: TcxDataSummaryItem; const AValue: Variant; AIsFooter: Boolean; var AText: string); procedure ToolButton4Click(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure PM11Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure MenuItem3Click(Sender: TObject); procedure TV2CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); procedure Timer1Timer(Sender: TObject); private CurrentPage, RecordsNumber: Integer; lstCust: TStringList; procedure InitGrid(WSql: string); procedure InitPage(); procedure SetStatus(); { Private declarations } public canshu1, canshu2, FWorkshop: string; { Public declarations } end; implementation uses U_DataLink, U_RTFun, U_LabelPrint; {$R *.dfm} procedure TfrmTatClothInList_ZDDY.InitPage(); begin CurrentPage := 1; case cxPageControl1.ActivePageIndex of 0: begin InitGrid(SGetHintFilters(Pnl_F2, 1, 2)); end; end; if CDS_2.IsEmpty then begin exit; end else begin ToolButton1.Click; end; end; procedure TfrmTatClothInList_ZDDY.SetStatus(); begin end; procedure TfrmTatClothInList_ZDDY.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; FreeAndNil(lstCust); Action := caFree; end; procedure TfrmTatClothInList_ZDDY.FormCreate(Sender: TObject); begin inherited; lstCust := TStringList.Create; EndDate2.Date := SGetServerDateTime(ADOQueryTemp); BegDate2.Date := EndDate2.Date; FWorkshop := trim(Self.fParameters3); end; procedure TfrmTatClothInList_ZDDY.InitGrid(WSql: string); begin if Trim(WSql) <> '' then WSql := ' and ' + WSql; case cxPageControl1.ActivePageIndex of 0: begin if chk_F2.Checked then begin WSql := WSql + ' and IOTime>=' + quotedstr(FormatDateTime('yyyy-MM-dd', BegDate2.Date)); WSql := WSql + ' and IOTime<' + quotedstr(FormatDateTime('yyyy-MM-dd', enddate2.Date + 1)); end; with ADOQueryMain do begin Close; sql.Clear; sql.Add(' select IOTime=CONVERT(VARCHAR(10),IOTime,120),IONO,IOType,ConNO,OrderNo,MainID,SubID,C_Code,C_Name,BatchNo'); sql.Add(' ,COUNT(PieceNo) SumPieceNo,sum(GrossWeight) SumGrossWeight,sum(Tare) SumTare,sum(NetWeight) SumNetWeight'); sql.Add(' ,Sum(Meter) SumMeter,Sum(Yardage) SumYardage'); sql.Add(' from V_Tat_Cloth_IO A where IOFlag=''入库'' and PrintFlag = 0 '); sql.Add(WSql); sql.Add(' GROUP BY CONVERT(VARCHAR(10),IOTime,120),IONO,IOType,ConNO,OrderNo,MainID,SubID,C_Code,C_Name,BatchNo'); // ShowMessage(SQL.Text); Open; end; SCreateCDS(ADOQueryMain, CDS_2); SInitCDSData(ADOQueryMain, CDS_2); end; end; end; procedure TfrmTatClothInList_ZDDY.TBRafreshClick(Sender: TObject); begin CurrentPage := 1; InitPage(); end; procedure TfrmTatClothInList_ZDDY.CDS_1BeforeOpen(DataSet: TDataSet); begin lstCust.Clear; end; procedure TfrmTatClothInList_ZDDY.cxPageControl1Change(Sender: TObject); begin SetStatus(); end; procedure TfrmTatClothInList_ZDDY.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmTatClothInList_ZDDY.FormShow(Sender: TObject); begin inherited; canshu1 := self.fParameters1; canshu2 := self.fParameters2; FWorkshop := self.fParameters3; ReadCxGrid(trim(self.Caption) + 'Tv2', Tv2, '梭织坯布仓库'); CurrentPage := 1; RecordsNumber := 500; SetStatus(); InitPage(); end; procedure TfrmTatClothInList_ZDDY.orderNoKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin CurrentPage := 1; InitPage(); end; end; procedure TfrmTatClothInList_ZDDY.PM11Click(Sender: TObject); begin SelOKNo(CDS_1, true); end; procedure TfrmTatClothInList_ZDDY.TBRKCXClick(Sender: TObject); var MCIIDS, MIOIDS, MSTKIDS, MPCIDS: string; begin if CDS_1.IsEmpty then Exit; if not CDS_1.Locate('SSel', True, []) then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; MCIIDS := ''; MIOIDS := ''; MSTKIDS := ''; MPCIDS := ''; CDS_1.DisableControls; with CDS_1 do begin First; while not Eof do begin if CDS_1.fieldbyname('SSel').AsBoolean then begin MCIIDS := MCIIDS + (Trim(CDS_1.fieldbyname('CIID').AsString)) + ','; MIOIDS := MIOIDS + (Trim(CDS_1.fieldbyname('IOID').AsString)) + ','; MSTKIDS := MSTKIDS + (Trim(CDS_1.fieldbyname('STKID').AsString)) + ','; MPCIDS := MPCIDS + (Trim(CDS_1.fieldbyname('PCID').AsString)) + ','; end; Next; end; end; MCIIDS := leftBstr(trim(MCIIDS), length(MCIIDS) - 1); MIOIDS := leftBstr(trim(MIOIDS), length(MIOIDS) - 1); MSTKIDS := leftBstr(trim(MSTKIDS), length(MSTKIDS) - 1); CDS_1.Locate('SSel', True, []); CDS_1.EnableControls; if Application.MessageBox('确定要执行操作吗?', '提示', 32 + 4) <> IDYES then Exit; try ADOQueryCmd.Connection.BeginTrans; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('insert into Tat_Need_Up(UType,UDataId,UOperation,UOperator,UModule,UDetails) '); sql.Add('values(''梭织坯布入库'' '); sql.Add(',' + quotedstr(MPCIDS)); sql.Add(',''撤销入库'' '); sql.Add(',' + quotedstr(DName)); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(MSTKIDS)); sql.Add(') '); execsql; end; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Tat_Cloth_ReIn '); Sql.Add('@StkIds=' + quotedstr(trim(MSTKIDS))); Sql.Add(',@IOIDS=' + quotedstr(trim(MIOIDS))); Sql.Add(',@FillId=' + Quotedstr(DCode)); Sql.Add(',@Filler=' + Quotedstr(DName)); // ShowMessage(sql.Text); Open; end; if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then begin raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString))); end; ADOQueryCmd.Connection.CommitTrans; // with ADOQueryCmd do // begin // Close; // sql.Clear; // sql.Add('exec P_Tat_Card_PSC '); // execsql; // end; InitPage(); except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmTatClothInList_ZDDY.Timer1Timer(Sender: TObject); begin TBRafresh.Click; end; procedure TfrmTatClothInList_ZDDY.Tv1DataControllerFilterBeforeChange(Sender: TcxDBDataFilterCriteria; ADataSet: TDataSet; const AFilterText: string); begin lstCust.Clear; end; procedure TfrmTatClothInList_ZDDY.Tv1TcxGridDBDataControllerTcxDataSummaryFooterSummaryItems6GetText(Sender: TcxDataSummaryItem; const AValue: Variant; AIsFooter: Boolean; var AText: string); begin if lstCust <> nil then AText := IntToStr(lstCust.Count); end; procedure TfrmTatClothInList_ZDDY.TV2CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); begin // if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('sh').Index] <> null then // if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('sh').Index] > 8 then // ACanvas.Brush.Color := $B3DEF5; end; procedure TfrmTatClothInList_ZDDY.JYTypeChange(Sender: TObject); begin CurrentPage := 1; InitPage(); end; procedure TfrmTatClothInList_ZDDY.MenuItem3Click(Sender: TObject); begin Clipboard.SetTextBuf(PChar(Trim(CDS_2.fieldbyname(TV2.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString))); end; procedure TfrmTatClothInList_ZDDY.N1Click(Sender: TObject); begin SelOKNo(CDS_1, false); end; procedure TfrmTatClothInList_ZDDY.ToolButton1Click(Sender: TObject); begin if CDS_2.IsEmpty then Exit; try frmLabelPrint := TfrmLabelPrint.Create(Application); with frmLabelPrint do begin FLMType := 'TatClothIn1'; FFiltration1 := Trim(self.CDS_2.fieldbyname('IONO').AsString); if ShowModal = 1 then begin end; end; finally frmLabelPrint.Free; end; end; procedure TfrmTatClothInList_ZDDY.ToolButton2Click(Sender: TObject); var WSql: string; begin if CDS_1.IsEmpty then Exit; if not CDS_1.Locate('SSel', True, []) then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; WSql := ''; CDS_1.DisableControls; with CDS_1 do begin First; while not Eof do begin if CDS_1.fieldbyname('SSel').AsBoolean then begin if WSql <> '' then begin WSql := WSql + ',' + QuotedStr(Trim(CDS_1.fieldbyname('CIID').AsString)); end else begin WSql := QuotedStr(Trim(CDS_1.fieldbyname('CIID').AsString)); end; end; Next; end; end; CDS_1.Locate('SSel', True, []); CDS_1.EnableControls; try frmLabelPrint := TfrmLabelPrint.Create(Application); with frmLabelPrint do begin FLMType := 'TatClothIn2'; FFiltration1 := WSql; if ShowModal = 1 then begin end; end; finally frmLabelPrint.Free; end; end; procedure TfrmTatClothInList_ZDDY.ToolButton4Click(Sender: TObject); begin WriteCxGrid(trim(self.Caption) + 'Tv2', Tv2, '梭织坯布仓库'); end; end.