unit U_GDRKList; //

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, cxPC, cxCheckBox, cxDropDownEdit;

type
  TfrmGDRKList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBClose: TToolButton;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    TBExport: TToolButton;
    Order_Main: TClientDataSet;
    Panel1: TPanel;
    Label4: TLabel;
    GDPerson: TEdit;
    Label2: TLabel;
    FactoryName: TEdit;
    Label3: TLabel;
    BPCode: TEdit;
    Label10: TLabel;
    DQFactoryName: TEdit;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1OrderNo: TcxGridDBColumn;
    v1PSName: TcxGridDBColumn;
    v1Column20: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1GDPerson: TcxGridDBColumn;
    v1FactoryName: TcxGridDBColumn;
    v1ToFactoryName: TcxGridDBColumn;
    v1QtyUnit: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    Label5: TLabel;
    BPName: TEdit;
    v1Column18: TcxGridDBColumn;
    v1Column19: TcxGridDBColumn;
    v1Column27: TcxGridDBColumn;
    v1Column28: TcxGridDBColumn;
    Label6: TLabel;
    BPSpec: TEdit;
    Label1: TLabel;
    TaiTou: TEdit;
    v1Column3: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    Label7: TLabel;
    ColorName: TEdit;
    Label8: TLabel;
    GangNo: TEdit;
    Label9: TLabel;
    KZ: TEdit;
    Label11: TLabel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    v1Column5: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    v1Column10: TcxGridDBColumn;
    v1Column11: TcxGridDBColumn;
    Label12: TLabel;
    ColorType: TComboBox;
    v1Column12: TcxGridDBColumn;
    v1Column13: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure FPNoChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
    procedure v1Column11CustomDrawCell(Sender: TcxCustomGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
      var ADone: Boolean);
    procedure v1Column7CustomDrawCell(Sender: TcxCustomGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
      var ADone: Boolean);
    procedure ColorTypeChange(Sender: TObject);
    procedure v1Column18CustomDrawCell(Sender: TcxCustomGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
      var ADone: Boolean);
  private
    FInt,PFInt:Integer;
    canshu1:string;
    procedure InitGrid();
    procedure InitGridWSql(fsj:string);
    procedure InitForm();
    function  DelData():Boolean;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmGDRKList: TfrmGDRKList;

implementation
uses
  U_DataLink,U_RTFun;

{$R *.dfm}

procedure TfrmGDRKList.FormDestroy(Sender: TObject);
begin
  frmGDRKList:=nil;
end;

procedure TfrmGDRKList.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TfrmGDRKList.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('跟单成品入库列表',Tv1,'跟单管理');
end;

procedure TfrmGDRKList.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.Add(' exec P_View_GDCPRK :BegDate,:EndDate ');
      Parameters.ParamByName('BegDate').Value:=Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date));
      Parameters.ParamByName('EndDate').Value:=Trim(FormatDateTime('yyyy-MM-dd',EndDate.Date));
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;

end;

procedure TfrmGDRKList.InitGridWSql(fsj:string);
begin

end;

procedure TfrmGDRKList.InitForm();
begin
  EndDate.DateTime:=SGetServerDate10(ADOQueryTemp)+1;
  BegDate.DateTime:=SGetServerDate10(ADOQueryTemp);
  ReadCxGrid('跟单成品入库列表',Tv1,'跟单管理');
end;

procedure TfrmGDRKList.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;

function TfrmGDRKList.DelData():Boolean;
begin

end;

procedure TfrmGDRKList.TBExportClick(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then Exit;
  TcxGridToExcel(Self.Caption,cxGrid1);
end;

procedure TfrmGDRKList.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
  TBFind.Click;
end;

procedure TfrmGDRKList.FPNoChange(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 TfrmGDRKList.FormShow(Sender: TObject);
begin
  InitForm();
end;

procedure TfrmGDRKList.FormCreate(Sender: TObject);
begin
  canshu1:=Trim(DParameters1);
end;

procedure TfrmGDRKList.cxTabControl1Change(Sender: TObject);
begin
  InitGrid();
  TBFind.Click;
end;

procedure TfrmGDRKList.v1Column11CustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
  Id:Integer;
begin

  Id:=TV1.GetColumnByFieldName('TPJGSHQty').Index;
  if Id<0 then Exit;
  if AViewInfo.GridRecord.Values[id]=Null then Exit;
  if AViewInfo.GridRecord.Values[id]<0 then
  begin
    ACanvas.Brush.Color:=clRed;
  end;
end;

procedure TfrmGDRKList.v1Column7CustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
  Id:Integer;
begin

  Id:=TV1.GetColumnByFieldName('TPZGHSHZ').Index;
  if Id<0 then Exit;
  if AViewInfo.GridRecord.Values[id]=Null then Exit;
  if AViewInfo.GridRecord.Values[id]<0 then
  begin
    ACanvas.Brush.Color:=clRed;
  end;
end;

procedure TfrmGDRKList.ColorTypeChange(Sender: TObject);
begin
  TBFind.Click;
end;

procedure TfrmGDRKList.v1Column18CustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
  Id:Integer;
  Id10:Integer;
begin

  Id:=TV1.GetColumnByFieldName('TPPS').Index;
  Id10:=TV1.GetColumnByFieldName('WCPS').Index;
  if Id<0 then Exit;
  if Id10<0 then Exit;
  if AViewInfo.GridRecord.Values[id]=Null then Exit;
  if AViewInfo.GridRecord.Values[id10]=Null then Exit;
  if AViewInfo.GridRecord.Values[id]<>AViewInfo.GridRecord.Values[id10] then
  begin
    ACanvas.Brush.Color:=clRed;
  end;
end;

end.
