unit U_JYDayList;

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, cxCheckBox, cxCalendar, cxSplitter, RM_Dataset, RM_System,
  RM_Common, RM_Class, RM_GridReport, RM_e_Xls, Menus, MovePanel, cxTextEdit,
  cxContainer, cxCurrencyEdit, BtnEdit, RM_e_main, RM_e_htm, RM_e_Graphic,
  RM_e_Jpeg, RM_e_txt, RM_e_csv, RM_E_llPDF, Math, Clipbrd, cxPC,
  cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu;

type
  TfrmJYDayList = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    Label3: TLabel;
    OrderNo: TEdit;
    TBExport: TToolButton;
    Order_Main: TClientDataSet;
    conNO: TEdit;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    MJID: TEdit;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    v1Column10: TcxGridDBColumn;
    v1Column11: TcxGridDBColumn;
    v1Column12: TcxGridDBColumn;
    Label4: TLabel;
    MJType: TComboBox;
    v1Column13: TcxGridDBColumn;
    Label5: TLabel;
    MPRTCodeName: TEdit;
    Label6: TLabel;
    MJStr2: TComboBox;
    v1Column17: TcxGridDBColumn;
    v1Column19: TcxGridDBColumn;
    Label12: TLabel;
    factoryName: TEdit;
    v1Column20: TcxGridDBColumn;
    v1Column21: TcxGridDBColumn;
    Filler: TComboBox;
    v1Column22: TcxGridDBColumn;
    v1Column23: TcxGridDBColumn;
    v1Column24: TcxGridDBColumn;
    MovePanel2: TMovePanel;
    v1Column27: TcxGridDBColumn;
    v1Column28: TcxGridDBColumn;
    v1Column14: TcxGridDBColumn;
    v1Column15: TcxGridDBColumn;
    v1MKXS: TcxGridDBColumn;
    Mjstr4: TEdit;
    PrtColor: TEdit;
    v1Column31: TcxGridDBColumn;
    v1Column32: TcxGridDBColumn;
    v1Column33: TcxGridDBColumn;
    KHConNO: TEdit;
    Label19: TLabel;
    v1Column34: TcxGridDBColumn;
    v1Column36: TcxGridDBColumn;
    v1Column39: TcxGridDBColumn;
    Panel6: TPanel;
    Label31: TLabel;
    LBCPAP: TLabel;
    BTLP: TButton;
    BTNP: TButton;
    TCBNOR: TComboBox;
    IsJYTime: TCheckBox;
    v1Column42: TcxGridDBColumn;
    v1Column16: TcxGridDBColumn;
    Label1: TLabel;
    RKOrdID: TEdit;
    v1Column18: TcxGridDBColumn;
    lbl1: TLabel;
    APID: TEdit;
    Label2: TLabel;
    RCGangNo: TEdit;
    v1Column25: TcxGridDBColumn;
    v1Column26: TcxGridDBColumn;
    v1Column29: TcxGridDBColumn;
    v1Column30: TcxGridDBColumn;
    v1Column35: TcxGridDBColumn;
    Label11: TLabel;
    lidan: TEdit;
    Label13: TLabel;
    YWY: TEdit;
    v1Column37: TcxGridDBColumn;
    v1Column38: TcxGridDBColumn;
    v1Column40: TcxGridDBColumn;
    Label14: TLabel;
    KuanHao: TEdit;
    v1Column41: TcxGridDBColumn;
    v1Column43: TcxGridDBColumn;
    v1Column44: TcxGridDBColumn;
    Label16: TLabel;
    IsOutRange: TEdit;
    v1Column45: TcxGridDBColumn;
    v1Column46: TcxGridDBColumn;
    v1Column47: TcxGridDBColumn;
    v1Column48: TcxGridDBColumn;
    chkDP: TCheckBox;
    Label17: TLabel;
    PBLY: TEdit;
    v1Column49: TcxGridDBColumn;
    v1Column50: TcxGridDBColumn;
    Label18: TLabel;
    CDlist: TEdit;
    Tv1Column1: TcxGridDBColumn;
    Tv1Column2: TcxGridDBColumn;
    Panel2: TPanel;
    Panel3: TPanel;
    Tv1Column3: TcxGridDBColumn;
    ToolButton1: TToolButton;
    RM2: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    ADOQueryPrint: TADOQuery;
    ComboBox1: TComboBox;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    Panel4: TPanel;
    Tv1Column4: TcxGridDBColumn;
    Tv1Column5: TcxGridDBColumn;
    Tv1Column6: TcxGridDBColumn;
    Tv1Column7: TcxGridDBColumn;
    Tv1Column8: TcxGridDBColumn;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure OrderNoKeyPress(Sender: TObject; var Key: Char);
    procedure MJIDKeyPress(Sender: TObject; var Key: Char);
    procedure BTLPClick(Sender: TObject);
    procedure BTNPClick(Sender: TObject);
    procedure TCBNORChange(Sender: TObject);
    procedure conNOKeyPress(Sender: TObject; var Key: Char);
    procedure MJStr2Change(Sender: TObject);
    procedure MJTypeChange(Sender: TObject);
    procedure KHConNOKeyPress(Sender: TObject; var Key: Char);
    procedure RKOrdIDKeyPress(Sender: TObject; var Key: Char);
    procedure cxTabControl1Change(Sender: TObject);
    procedure chkDPClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
      var ADone: Boolean);
    procedure Panel2Click(Sender: TObject);
    procedure Panel3Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure ToolButton5Click(Sender: TObject);
    procedure Panel4Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
  private
    DQdate: TDateTime;
    FLeft, FTop: Integer;
    CurrentPage, RecordsNumber: Integer;
    procedure InitGrid(GJFW: string);
    procedure InitForm();
    procedure PrintCKMDG(MRKOrdID: string);
    { Private declarations }
  public
    FFInt: Integer;
    canshu1: string;
    { Public declarations }
  end;

var
  frmJYDayList: TfrmJYDayList;

implementation

uses
  U_DataLink, U_OrderInPut, U_RTFun, U_ProductOrderListSel,
  U_SysLogHelp,U_Fun;

{$R *.dfm}


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

procedure TfrmJYDayList.FormCreate(Sender: TObject);
begin
  cxgrid1.Align := alClient;
  DQdate := SGetServerDate(ADOQueryTemp);
end;

procedure TfrmJYDayList.TBCloseClick(Sender: TObject);
begin
  //WriteCxGrid('检验报告JF1', Tv1, '检验管理');
  if Trim(DName)='ADMIN' then
  begin
    WriteCxGridAll(trim(self.Caption), Tv1,ADOQueryCmd,ADOQueryTemp);
  end;
  Close;
end;



procedure TfrmJYDayList.InitGrid(GJFW: string);
var
  fwhere, Pwhere,FCDList,FCD,CDWhere: string;
begin
  MovePanel2.Left := (self.Width - MovePanel2.Width) div 2;
  MovePanel2.Visible := True;
  MovePanel2.Refresh;
  if IsJYTime.Checked then
  begin
    fwhere := ' and Filltime>' + quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime));
    fwhere := fwhere + ' and Filltime<=' + quotedstr(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1));
  end;

  Pwhere := SGetFilters(Panel1, 1, 2);

  if chkDP.Checked then
  begin
    //十公斤以上，米数20米
    Pwhere := Pwhere + ' and ( MJMaoZ>10 or MJLen>20 )';
  end;

  if trim(fwhere) <> '' then
  begin
    if Trim(Pwhere)<>'' then
    begin
      fwhere := fwhere + ' and ' + trim(Pwhere);
    end else
    begin
      fwhere := fwhere;
    end;
  end
  else
  begin
    fwhere := ' and ' + trim(Pwhere);
  end;
  if GJFW = '高损耗' then
  begin
    fwhere:=fwhere+' and  ABS(PCBFB)>=15 and ChuLiFlag=0 ';
  end;
  if GJFW = '低损耗' then
  begin
    fwhere:=fwhere+' and  ABS(PCBFB)>=10 and  ABS(PCBFB)<15 and ChuLiFlag=0';
  end;
  if GJFW = '已处理' then
  begin
    fwhere:=fwhere+' and  ChuLiFlag=1 ';
  end;
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.Add('exec P_Page_ClothInfo_Day ');
      sql.Add('@pageIndex=' + inttostr(CurrentPage));
      sql.Add(',@pageSize=' + inttostr(RecordsNumber));
      sql.Add(',@criteria= ' + quotedstr(fwhere));
//      ShowMessage(sql.Text);
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_Main);
    SInitCDSData20(ADOQueryMain, Order_Main);
    LBCPAP.Caption := inttostr(CurrentPage) + '/' + inttostr(ceil(Order_Main.FieldByName('TotalCount').AsInteger / RecordsNumber));
    MovePanel2.Visible := false;
  finally
    ADOQueryMain.EnableControls;
    MovePanel2.Visible := false;
  end;
end;



procedure TfrmJYDayList.InitForm();
var
  fsj: string;
begin
  ReadCxGridAll(trim(self.Caption), Tv1);
  fsj := 'select distinct(Filler) name from WFB_MJJY   ';
  SInitComBoxBySql(ADOQueryCmd, Filler, False, fsj);
  EndDate.Date:=DQdate;
  BegDate.Date:=DQdate-2;
end;

procedure TfrmJYDayList.TBExportClick(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then
    Exit;
  SelExportData(Tv1, ADOQueryMain, '检验报告');
end;

procedure TfrmJYDayList.TBRafreshClick(Sender: TObject);
begin
  OrderNo.SetFocus;

  CurrentPage := 1;
  InitGrid('');

end;

procedure TfrmJYDayList.FormShow(Sender: TObject);
begin
  CurrentPage := 1;
  RecordsNumber := 500;
  InitForm();
end;

procedure TfrmJYDayList.Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  FLeft := X;
  FTop := Y;
end;



procedure TfrmJYDayList.OrderNoKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    if Length(OrderNo.Text) < 4 then
      Exit;
    CurrentPage := 1;
    InitGrid('');
  end;
end;



procedure TfrmJYDayList.MJIDKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    if Length(MJID.Text) < 4 then
      Exit;
    CurrentPage := 1;
    InitGrid('');
  end;
end;

procedure TfrmJYDayList.BTLPClick(Sender: TObject);
begin
  if CurrentPage > 1 then
    CurrentPage := CurrentPage - 1;
  InitGrid('');
end;

procedure TfrmJYDayList.BTNPClick(Sender: TObject);
begin
  if CurrentPage < Order_Main.FieldByName('TotalCount').AsInteger / RecordsNumber then
    CurrentPage := CurrentPage + 1;
  InitGrid('');
end;

procedure TfrmJYDayList.TCBNORChange(Sender: TObject);
begin
  RecordsNumber := StrToInt(TCBNOR.Text);
  CurrentPage := 1;
  InitGrid('');
end;

procedure TfrmJYDayList.conNOKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    CurrentPage := 1;
    InitGrid('');
  end;
end;

procedure TfrmJYDayList.MJStr2Change(Sender: TObject);
begin
  CurrentPage := 1;
  InitGrid('');
end;

procedure TfrmJYDayList.MJTypeChange(Sender: TObject);
begin
  CurrentPage := 1;
  InitGrid('');
end;

procedure TfrmJYDayList.KHConNOKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    CurrentPage := 1;
    InitGrid('');
  end;
end;

procedure TfrmJYDayList.RKOrdIDKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    CurrentPage := 1;
    InitGrid('');
  end;
end;

procedure TfrmJYDayList.cxTabControl1Change(Sender: TObject);
begin
  CurrentPage := 1;
  InitGrid('');
end;

procedure TfrmJYDayList.chkDPClick(Sender: TObject);
begin
  OrderNo.SetFocus;

  CurrentPage := 1;
  InitGrid('');

end;

procedure TfrmJYDayList.FormDestroy(Sender: TObject);
begin
  frmJYDayList:=nil;
end;

procedure TfrmJYDayList.Tv1CustomDrawCell(Sender: TcxCustomGridTableView;
  ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
  var ADone: Boolean);
var
  Fsunhao:Double;
begin
  Fsunhao := AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('PCBFB').Index];

  if Fsunhao < 0 then
    Fsunhao := -Fsunhao;
  if Fsunhao >=15 then
    ACanvas.Brush.Color := $4763FF;
  if (Fsunhao >=10) and (Fsunhao <15) then
    ACanvas.Brush.Color := $00FFFF;
  if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('ChuLiFlag').Index]=True then
    ACanvas.Brush.Color :=clSkyBlue;
end;

procedure TfrmJYDayList.Panel2Click(Sender: TObject);
begin
  InitGrid('高损耗');
end;

procedure TfrmJYDayList.Panel3Click(Sender: TObject);
begin
  InitGrid('低损耗');
end;

procedure TfrmJYDayList.ToolButton1Click(Sender: TObject);
begin
  if Trim(Order_Main.fieldbyname('RKOrdID').AsString) = '' then
    exit;
  PrintCKMDG(Trim(Order_Main.fieldbyname('RKOrdID').AsString));
end;
procedure TfrmJYDayList.PrintCKMDG(MRKOrdID: string);
var
  fPrintFile: string;
  Txt, fImagePath: string;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  if Order_Main.IsEmpty then
    Exit;
  ExportFtErpFile('仓库码单.rmf', ADOQueryTemp);
  with Order_Main do
  begin

    with ADOQueryPrint do
    begin
      Close;
      SQL.Clear;
      sql.Add(' exec P_Print_RKMDGangNo ');
      SQL.Add(' @RKOrdID=''' + Trim(MRKOrdID) + '''');
      Open;
    end;
    try
      Moudle := LoadLibrary('MakeQRBarcode.dll');
      @Makebar := GetProcAddress(Moudle, 'Make');
      @Mixtext := GetProcAddress(Moudle, 'MixText');
      Txt := Trim(ADOQueryPrint.fieldbyname('RKOrdID').AsString);
      fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
      if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
        CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
      if FileExists(fImagePath) then
        DeleteFile(fImagePath);
      Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
    except
      application.MessageBox('条形码生成失败！', '提示信息', MB_ICONERROR);
      exit;
    end;
    fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\仓库码单.rmf';
    if FileExists(fPrintFile) then
    begin
      RMVariables['QRBARCODE'] := fImagePath;
      RM2.LoadFromFile(fPrintFile);
      Rm2.DefaultCopies := strtointdef(trim(ComboBox1.Text), 1);
//      RM2.PrintReport;
      RM2.ShowReport;
    end
    else
    begin
      Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0);
      Exit;
    end;

  end;

end;


procedure TfrmJYDayList.ToolButton2Click(Sender: TObject);
var
  fPrintFile: string;
  Txt, fImagePath: string;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  if Order_Main.IsEmpty then
    Exit;
  ExportFtErpFile('三联仓库码单.rmf', ADOQueryTemp);
  with Order_Main do
  begin

    with ADOQueryPrint do
    begin
      Close;
      SQL.Clear;
      sql.Add(' exec P_Print_RKMDGangNo2 ');
      SQL.Add(' @RKOrdID=''' + Trim(Order_Main.fieldbyname('RKOrdID').AsString) + '''');
      Open;
    end;
    try
      Moudle := LoadLibrary('MakeQRBarcode.dll');
      @Makebar := GetProcAddress(Moudle, 'Make');
      @Mixtext := GetProcAddress(Moudle, 'MixText');
      Txt := Trim(ADOQueryPrint.fieldbyname('RKOrdID').AsString);
      fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
      if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
        CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
      if FileExists(fImagePath) then
        DeleteFile(fImagePath);
      Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
    except
      application.MessageBox('条形码生成失败！', '提示信息', MB_ICONERROR);
      exit;
    end;
    fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\三联仓库码单.rmf';
    if FileExists(fPrintFile) then
    begin
      RMVariables['QRBARCODE'] := fImagePath;
      RM2.LoadFromFile(fPrintFile);
      Rm2.DefaultCopies := strtointdef(trim(ComboBox1.Text), 1);
//      RM2.PrintReport;
      RM2.ShowReport;
    end
    else
    begin
      Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0);
      Exit;
    end;

  end;

end;

procedure TfrmJYDayList.ToolButton3Click(Sender: TObject);
begin
  frmSysLogHelp := TfrmSysLogHelp.create(self);
  with frmSysLogHelp do
  begin
    fModel := self.caption;
  //  facction:='生产指示单删除';
    showmodal;
    free;
  end;
end;

procedure TfrmJYDayList.ToolButton4Click(Sender: TObject);
var
  strsql, FSPId: string;
begin
  if Order_Main.Locate('SSel', True, []) = False then
  begin
    Application.MessageBox('请选择数据！', '提示', 0);
    Exit;
  end;
  while Order_Main.Locate('SSel', True, []) do
  begin
    FSPId := Trim(Order_Main.fieldbyname('MJId').AsString);
    strsql := '卷号：' + Trim(Order_Main.fieldbyname('MJId').AsString) + ' 订单号:' + Trim(Order_Main.fieldbyname('conNO').AsString);
    if Application.MessageBox(PChar('请确定：' + strsql), '提示', 32 + 4) <> IDYES then
      Exit;

    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add(' update WFB_MJJY set ChuLiFlag=1,ChuLiTime=getdate(),ChuLiPerson='''+Trim(DName)+'''');
      sql.Add(' where MJID=' + quotedstr(Trim(Order_Main.fieldbyname('MJID').AsString)));

      sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
      sql.Add(' ' + quotedstr(trim(DName)));
      sql.Add(',getdate() ');
      sql.Add(',' + quotedstr(trim(self.Caption)));
      sql.Add(',' + quotedstr('偏差处理'));
      sql.Add(',' + quotedstr(trim(strsql)));
      sql.Add(',' + quotedstr(trim('成功')));
      sql.Add(')');
      execsql;
    end;
    Order_Main.Edit;
    Order_Main.FieldByName('SSel').Value:=False;
    Order_Main.FieldByName('ChuLiFlag').Value:=True;
    Order_Main.Post;
  end;

end;

procedure TfrmJYDayList.ToolButton5Click(Sender: TObject);
var
  strsql, FSPId: string;
begin
  if Order_Main.Locate('SSel', True, []) = False then
  begin
    Application.MessageBox('请选择数据！', '提示', 0);
    Exit;
  end;
  while Order_Main.Locate('SSel', True, []) do
  begin
    FSPId := Trim(Order_Main.fieldbyname('MJId').AsString);
    strsql := '卷号：' + Trim(Order_Main.fieldbyname('MJId').AsString) + '订单号:' + Trim(Order_Main.fieldbyname('conNO').AsString);
    if Application.MessageBox(PChar('请确定：' + strsql), '提示', 32 + 4) <> IDYES then
      Exit;

    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add(' update WFB_MJJY set ChuLiFlag=0,ChuLiTime=getdate(),ChuLiPerson='''+Trim(DName)+'''');
      sql.Add(' where MJID=' + quotedstr(Trim(Order_Main.fieldbyname('MJID').AsString)));

      sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
      sql.Add(' ' + quotedstr(trim(DName)));
      sql.Add(',getdate() ');
      sql.Add(',' + quotedstr(trim(self.Caption)));
      sql.Add(',' + quotedstr('偏差处理'));
      sql.Add(',' + quotedstr(trim(strsql)));
      sql.Add(',' + quotedstr(trim('撤销')));
      sql.Add(')');
      execsql;
    end;
    Order_Main.Edit;
    Order_Main.FieldByName('SSel').Value:=False;
    Order_Main.FieldByName('ChuLiFlag').Value:=False;
    Order_Main.Post;
  end;

end;

procedure TfrmJYDayList.Panel4Click(Sender: TObject);
begin
  InitGrid('已处理');
end;

procedure TfrmJYDayList.N1Click(Sender: TObject);
begin
  SelOKNoFilter(Tv1,True);
end;

procedure TfrmJYDayList.N2Click(Sender: TObject);
begin
  SelOKNoFilter(Tv1,False);
end;

end.

