unit U_MLSCDXZ;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
  cxStyles, dxSkinsCore,    
   dxSkinDarkRoom,  
     
     
     
    
    
    
   dxSkinOffice2013White,  
    dxSkinSharpPlus, 
  dxSkinSpringTime,   
  dxSkinsDefaultPainters,   
   dxSkinscxPCPainter, cxCustomData, cxFilter, cxData,
  cxDataStorage, cxEdit, cxNavigator, DB, cxDBData, DBClient, ADODB, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
  cxGridCustomView, cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxCheckBox;

type
  Tfrmmlscdxz = class(TForm)
    tlb1: TToolBar;
    btnTBRafresh: TToolButton;
    btnTBFind: TToolButton;
    btnTBClose: TToolButton;
    pnl1: TPanel;
    lbl1: TLabel;
    lbl2: TLabel;
    lbl3: TLabel;
    lbl4: TLabel;
    lbl5: TLabel;
    lbl6: TLabel;
    KHConNo: TEdit;
    ConNo: TEdit;
    chk1: TCheckBox;
    KHNo: TEdit;
    KHName: TEdit;
    GYNoteZ: TEdit;
    Note: TEdit;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1KHNo: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    Tv1Column2: TcxGridDBColumn;
    Tv1Column3: TcxGridDBColumn;
    Tv1Column4: TcxGridDBColumn;
    Tv1Column5: TcxGridDBColumn;
    Tv1Column1: TcxGridDBColumn;
    v1KHLXR: TcxGridDBColumn;
    Tv1Column6: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    DataSource1: TDataSource;
    Order_Main: TClientDataSet;
    ADOQueryTemp: TADOQuery;
    Tv1Column7: TcxGridDBColumn;
    Tv1Column8: TcxGridDBColumn;
    Tv1Column9: TcxGridDBColumn;
    Tv1Column10: TcxGridDBColumn;
    Tv1Column11: TcxGridDBColumn;
    Tv1Column12: TcxGridDBColumn;
    Tv1Column13: TcxGridDBColumn;
    Tv1Column14: TcxGridDBColumn;
    Tv1Column15: TcxGridDBColumn;
    Tv1Column16: TcxGridDBColumn;
    dtpBegDate: TDateTimePicker;
    dtpEndDate: TDateTimePicker;
    btn1: TToolButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btnTBRafreshClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure btnTBFindClick(Sender: TObject);
    procedure btnTBCloseClick(Sender: TObject);
    procedure ConNoChange(Sender: TObject);
    procedure btn1Click(Sender: TObject);
  private
    procedure InitGrid();
    procedure InitForm();
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmmlscdxz: Tfrmmlscdxz;

implementation

uses
  U_DataLink, U_RTFun, U_ZDYHelp;
{$R *.dfm}

procedure Tfrmmlscdxz.InitForm();
begin
  dtpBegDate.Date := SGetServerDateMBeg(ADOQueryTemp);
  dtpEndDate.Date := SGetServerDate(ADOQueryTemp);
  ReadCxGrid(self.Caption + '面料生产单选择', Tv1, '面料生产单选择');
  InitGrid();

end;

procedure Tfrmmlscdxz.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.Add('select *  ');
      sql.Add(' from MLSC A  ');
      sql.Add(' inner join MLSC_Sub B on A.MainID=B.MainID  ');
      sql.Add(' where A.CRTime>=''' + Trim(FormatDateTime('yyyy-MM-dd', dtpBegDate.Date)) + '''');
      sql.Add(' and A.CRTime<''' + Trim(FormatDateTime('yyyy-MM-dd', dtpEndDate.Date + 1)) + '''');
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_Main);
    SInitCDSData20(ADOQueryMain, Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure Tfrmmlscdxz.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  ModalResult := 1;
end;

procedure Tfrmmlscdxz.btnTBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;

procedure Tfrmmlscdxz.FormShow(Sender: TObject);
begin
  InitForm();
end;

procedure Tfrmmlscdxz.btnTBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active = False then
    Exit;
  SDofilter(ADOQueryMain, SGetFilters(pnl1, 1, 2));
  SCreateCDS20(ADOQueryMain, Order_Main);
  SInitCDSData20(ADOQueryMain, Order_Main);
end;

procedure Tfrmmlscdxz.btnTBCloseClick(Sender: TObject);
begin
  Close;
  writeCxGrid(self.Caption + '面料生产单选择', Tv1, '面料生产单选择');
end;

procedure Tfrmmlscdxz.ConNoChange(Sender: TObject);
begin
  if ADOQueryMain.Active = False then
    Exit;
  SDofilter(ADOQueryMain, SGetFilters(pnl1, 1, 2));
  SCreateCDS20(ADOQueryMain, Order_Main);
  SInitCDSData20(ADOQueryMain, Order_Main);
end;

procedure Tfrmmlscdxz.btn1Click(Sender: TObject);
begin
  ModalResult := 1;
end;

end.

