unit U_ProductOrderNewList_CY;

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, cxButtonEdit, cxTextEdit, cxPC;

type
  TfrmProductOrderNewList_CY = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBAdd: TToolButton;
    TBEdit: TToolButton;
    TBDel: TToolButton;
    TBPrint: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    Label1: TLabel;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    Label3: TLabel;
    OrderNo: TEdit;
    v1OrderNo: TcxGridDBColumn;
    Order_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMDBMain: TRMDBDataSet;
    RMXLSExport1: TRMXLSExport;
    v1CustomerNoName: TcxGridDBColumn;
    Label4: TLabel;
    CustomerNoName: TEdit;
    PopupMenu1: TPopupMenu;
    N2: TMenuItem;
    ToolButton1: TToolButton;
    Label8: TLabel;
    MPRTCodeName: TEdit;
    Label10: TLabel;
    MPRTSpec: TEdit;
    Label11: TLabel;
    MPRTCode: TEdit;
    Label12: TLabel;
    MPRTKZ: TEdit;
    Label13: TLabel;
    MPRTMF: TEdit;
    ADOQueryPrint: TADOQuery;
    cxSplitter1: TcxSplitter;
    ADOQuerySub: TADOQuery;
    DataSource2: TDataSource;
    v1Column8: TcxGridDBColumn;
    Label2: TLabel;
    cxTabControl1: TcxTabControl;
    TChk: TToolButton;
    TNOChk: TToolButton;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    v1Column5: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1PRTColor: TcxGridDBColumn;
    cxGridDBColumn3: TcxGridDBColumn;
    v1OrderUnit: TcxGridDBColumn;
    cxGridDBColumn4: TcxGridDBColumn;
    v1Column13: TcxGridDBColumn;
    cxGridDBColumn6: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    v1Column14: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v2Column1: TcxGridDBColumn;
    v2Column2: TcxGridDBColumn;
    v1Column16: TcxGridDBColumn;
    TSChk: TToolButton;
    TSNoChk: TToolButton;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure TBEditClick(Sender: TObject);
    procedure TBDelClick(Sender: TObject);
    procedure TBPrintClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure TBAddClick(Sender: TObject);
    procedure OrderNoChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBTPClick(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure Tv1StylesGetContentStyle(Sender: TcxCustomGridTableView;
      ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
      out AStyle: TcxStyle);
    procedure v1DeliveryDateCustomDrawCell(Sender: TcxCustomGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
      var ADone: Boolean);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView;
      APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
      ANewItemRecordFocusingChanged: Boolean);
    procedure TChkClick(Sender: TObject);
    procedure TNOChkClick(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
    procedure TSChkClick(Sender: TObject);
    procedure TSNoChkClick(Sender: TObject);
  private
    DQdate:TDateTime;
    procedure InitGrid();
    function  DelData():Boolean;

    procedure InitSub();
    procedure SetStatus();
    { Private declarations }
  public
    FFInt,FCloth:Integer;
    canshu1:string;
    { Public declarations }
  end;

//var
//  frmProductOrderNewList_CY: TfrmProductOrderNewList_CY;

implementation
uses
  U_DataLink,U_OrderInPut,U_Fun,  U_OrderInPut_CY;

{$R *.dfm}
procedure TfrmProductOrderNewList_CY.SetStatus();
begin

  tbedit.Visible:=false;
  tbdel.Visible:=false;
  TBAdd.Visible:=false;
  TBPrint.Visible:=false;
  
  tchk.Visible:=false;
  tnochk.Visible:=false;

  TSChk.Visible:=false;
  TSNoChk.Visible:=false;

  if Trim(self.Caption)='发货申请录入'  then
  begin
    case cxTabControl1.TabIndex of
    0:begin
        tbedit.Visible:=true;
        tbdel.Visible:=true;
        TBAdd.Visible:=true;
      end;
    end;
  end;
  if Trim(self.Caption)='发货申请财务审核'   then
  begin
    case cxTabControl1.TabIndex of
    0:begin
        tchk.Visible:=true;
      end;
    1:begin
        tnochk.Visible:=true;
      end;

    end;
  end;
  if Trim(self.Caption)='发货申请仓库审核'  then
  begin
    case cxTabControl1.TabIndex of
    1:begin
        TSChk.Visible:=true;
      end;
    2:begin
        TBPrint.Visible:=true;
      end;
    end;
  end
end;
procedure TfrmProductOrderNewList_CY.InitSub();
begin
  ADOQuerySub.Close;
  IF Order_Main.IsEmpty then exit;
  with ADOQuerySub do
  begin
    close;
    sql.Clear;
    sql.Add('select * from JYOrderCY_sub ');
    sql.Add('where mainID ='+quotedstr((Order_Main.fieldbyname('mainID').AsString)));
    open;
  end;
end;

procedure TfrmProductOrderNewList_CY.FormDestroy(Sender: TObject);
begin
//  frmProductOrderNewList_CY:=nil;
end;

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

procedure TfrmProductOrderNewList_CY.FormCreate(Sender: TObject);
begin
  canshu1:=trim(DParameters1);
  DQdate:=SGetServerDate(ADOQueryTemp);
  cxTabControl1.TabIndex:=0;
 
end;

procedure TfrmProductOrderNewList_CY.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid(self.Caption+tv1.Name,Tv1,'生产指示单管理');
  WriteCxGrid(self.Caption+tv2.Name,Tv2,'生产指示单管理');
end;

procedure TfrmProductOrderNewList_CY.InitGrid();
begin

  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.add('select * from JYOrderCy_Main') ;
      sql.add(' where isnull(status,''0'')='+quotedstr(trim(inttostr(cxTabControl1.TabIndex)))) ;
      if Trim(self.Caption)='发货申请录入'  then
       sql.add(' and Filler='+quotedstr(trim(DName))) ;
      Open;
    end;

    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;


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

procedure TfrmProductOrderNewList_CY.TBEditClick(Sender: TObject);
begin
  if Order_Main.IsEmpty then Exit;
 { if Trim(Order_Main.fieldbyname('Filler').AsString)<>Trim(DName) then
  begin
    Application.MessageBox('不能操作他人的数据!','提示',0);
    Exit;
  end;  }
  try
    frmOrderInPut_CY:=TfrmOrderInPut_CY.Create(Application);
    with frmOrderInPut_CY do
    begin
      PState:=1;
      FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
      if ShowModal=1 then
      begin

      end;
    end;
  finally
    frmOrderInPut_CY.Free;
  end;
end;

procedure TfrmProductOrderNewList_CY.TBDelClick(Sender: TObject);
begin
  if Order_Main.IsEmpty then Exit;

  if Application.MessageBox('确定要删除数据吗？','提示',32+4)<>IDYES then Exit;
  if DelData() then
  begin
    Order_Main.Delete;
  end;
end;

function TfrmProductOrderNewList_CY.DelData():Boolean;
begin
  try
    Result:=false;
    ADOQueryCmd.Connection.BeginTrans;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('delete JYOrderCY_Main where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
      sql.Add('delete JYOrderCY_Sub where MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
      sql.Add('delete JY_CY_money where MainId='''+Trim(Order_Main.fieldbyname('MainId').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(trim('出运单删除')));
      sql.Add(','+quotedstr(trim('指出运单：'+trim(Order_Main.FieldByName('OrderNO').AsString))));
      sql.Add(','+quotedstr(trim('成功')));
      sql.Add(')');
      ExecSQL;
    end;

    ADOQueryCmd.Connection.CommitTrans;
    Result:=True;
  except
    ADOQueryCmd.Connection.RollbackTrans;
    Result:=False;
    Application.MessageBox('数据删除异常！','提示',0);
  end;
end;

procedure TfrmProductOrderNewList_CY.TBPrintClick(Sender: TObject);
var
   fPrintFile:string;
   Porderno:string;
   i,j:Integer;
begin
  if Order_Main.IsEmpty then Exit;
  fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\出运通知单.rmf' ;
  with ADOQueryPrint do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*,B.*   ');
    sql.Add('from JYOrderCY_Main A inner join JYOrderCY_Sub B on A.MainId=B.MainId ');
    sql.Add('and A.MainId='''+Trim(Order_Main.fieldbyname('MainId').AsString)+'''');
    Open;
  end;


  if FileExists(fPrintFile) then
  begin
    RM1.LoadFromFile(fPrintFile);
    RM1.ShowReport;
  end
  else
  begin
    Application.MessageBox(PChar('没有找'+ExtractFilePath(Application.ExeName)+'Report\出运通知单.rmf'),'提示',0);
  end;
end;

procedure TfrmProductOrderNewList_CY.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmProductOrderNewList_CY.TBAddClick(Sender: TObject);
begin
  try
    frmOrderInPut_CY:=TfrmOrderInPut_CY.Create(Application);
    with frmOrderInPut_CY do
    begin
      PState:=0;
      FMainId:='';
      if ShowModal=1 then
      begin
        InitGrid();
      end;
    end;
  finally
    frmOrderInPut_CY.Free;
  end;
end;

procedure TfrmProductOrderNewList_CY.OrderNoChange(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 TfrmProductOrderNewList_CY.FormShow(Sender: TObject);
begin
  ReadCxGrid(self.Caption+tv1.Name,Tv1,'生产指示单管理');
  readCxGrid(self.Caption+tv2.Name,Tv2,'生产指示单管理');
  BegDate.DateTime:=SGetServerDate10(ADOQueryTemp)-7;
  EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
  InitGrid();
   SetStatus();
end;

procedure TfrmProductOrderNewList_CY.TBTPClick(Sender: TObject);
 var
   FQty,FQty1,FMxQty,FPQty,FMxQtyS,FPQtyS:String;
begin
end;

procedure TfrmProductOrderNewList_CY.CheckBox1Click(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmProductOrderNewList_CY.CheckBox2Click(Sender: TObject);
begin
  TBRafresh.Click;
end;

procedure TfrmProductOrderNewList_CY.Tv1StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
  id,id10:Integer;
begin
  {try
    if Tv1.GroupedItemCount=0 then
    begin
      Id:=Tv1.GetColumnByFieldName('DeliveryDate').Index-tv1.GroupedItemCount;
      Id10:=Tv1.GetColumnByFieldName('SubStatus').Index-tv1.GroupedItemCount;
      if Trim(VarToStr(ARecord.Values[id]))='' then Exit;
      if Id<0 then Exit;
      if ARecord.Values[id10]='完成' then exit;
      if (ARecord.Values[id]-DQdate)>=4 then Exit;
      if ((ARecord.Values[id]-DQdate)>=0) and ((ARecord.Values[id]-DQdate)<4) then
        AStyle:=DataLink_.QHuangSe
      else
      if ARecord.Values[id]-DQdate<0 then
      begin
        AStyle:=DataLink_OrderManage.FenHongS;
      end;
    end else
    begin

    end;
  except
  end; }
end;

procedure TfrmProductOrderNewList_CY.v1DeliveryDateCustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
 { Id:=TV1.GetColumnByFieldName('DeliveryDate').Index;//;-TV1.GroupedItemCount;
  Id10:=TV1.GetColumnByFieldName('SubStatus').Index;
  if Id<0 then Exit;
  if AViewInfo.GridRecord.Values[Id10]='完成' then Exit;
  if AViewInfo.GridRecord.Values[Id]-SGetServerDate(ADOQueryTemp)>=4 then Exit;
  if ((AViewInfo.GridRecord.Values[id]-SGetServerDate10(ADOQueryTemp))>=0) and ((AViewInfo.GridRecord.Values[id]-SGetServerDate(ADOQueryTemp))<4) then
    ACanvas.Brush.Color:=clYellow
  else
  if (AViewInfo.GridRecord.Values[id])-(SGetServerDate10(ADOQueryTemp)<0) then
  begin
    ACanvas.Brush.Color:=clRed;
  end;
  begin
    ACanvas.Brush.Color:=clRed;
  end else
  if AViewInfo.GridRecord.Values[Id]='Purple' then
  begin
    ACanvas.Brush.Color:=clPurple;
  end else
  if AViewInfo.GridRecord.Values[Id]='Olive' then
  begin
    ACanvas.Brush.Color:=clOlive;
  end else
  if AViewInfo.GridRecord.Values[Id]='Teal' then
  begin
    ACanvas.Brush.Color:=clTeal;
  end else
  if AViewInfo.GridRecord.Values[Id]='Background' then
  begin
    ACanvas.Brush.Color:=clBackground;
  end;   }
end;

procedure TfrmProductOrderNewList_CY.N1Click(Sender: TObject);
var
   fPrintFile:string;
   Porderno:string;
begin
  if Order_Main.IsEmpty then Exit;
  fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\生产指示单10.rmf' ;
  SDofilter(ADOQueryMain,' OrderNoM='''+Trim(Order_Main.fieldbyname('OrderNoM').AsString)+'''');
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
  Porderno:=Trim(Order_Main.fieldbyname('OrderNoM').AsString);
  if FileExists(fPrintFile) then
  begin
    //RMVariables['begindate']:=begindate.DateTime;
    //RMVariables['enddate']:=enddate.DateTime;
    //RMVariables['printtime']:=Now;
    //RMVariables['printer']:=Trim(gUserName);
    RM1.LoadFromFile(fPrintFile);
    RM1.ShowReport;
  end else
  begin
    Application.MessageBox(PChar('没有找'+ExtractFilePath(Application.ExeName)+'Report\生产指示单10.rmf'),'提示',0);
  end;
  SDofilter(ADOQueryMain,'');
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
  Order_Main.Locate('ordernoM',Porderno,[]);
end;

procedure TfrmProductOrderNewList_CY.N2Click(Sender: TObject);
var
   fPrintFile:string;
   Porderno:string;
begin
  if Order_Main.IsEmpty then Exit;
  fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\生产指示单.rmf' ;
  SDofilter(ADOQueryMain,' OrderNoM='''+Trim(Order_Main.fieldbyname('OrderNoM').AsString)+'''');
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
  Porderno:=Trim(Order_Main.fieldbyname('OrderNoM').AsString);
  if FileExists(fPrintFile) then
  begin
    //RMVariables['begindate']:=begindate.DateTime;
    //RMVariables['enddate']:=enddate.DateTime;
    //RMVariables['printtime']:=Now;
    //RMVariables['printer']:=Trim(gUserName);
    RM1.LoadFromFile(fPrintFile);
    RM1.ShowReport;
  end else
  begin
    Application.MessageBox(PChar('没有找'+ExtractFilePath(Application.ExeName)+'Report\生产指示单.rmf'),'提示',0);
  end;
  SDofilter(ADOQueryMain,'');
  SCreateCDS20(ADOQueryMain,Order_Main);
  SInitCDSData20(ADOQueryMain,Order_Main);
  Order_Main.Locate('ordernoM',Porderno,[]);
end;

procedure TfrmProductOrderNewList_CY.ToolButton1Click(Sender: TObject);
begin
  if Order_Main.IsEmpty then Exit;
  try
    frmOrderInPut_CY:=TfrmOrderInPut_CY.Create(Application);
    with frmOrderInPut_CY do
    begin
      PState:=1;
      FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
      ToolBar2.Visible:=False;
      TBSave.Visible:=False;
      Panel1.Enabled:=False;
      Tv1.OptionsSelection.CellSelect:=False;
      if ShowModal=1 then
      begin

      end;
    end;
  finally
    frmOrderInPut_CY.Free;
  end;
end;

procedure TfrmProductOrderNewList_CY.Tv1FocusedRecordChanged(
  Sender: TcxCustomGridTableView; APrevFocusedRecord,
  AFocusedRecord: TcxCustomGridRecord;
  ANewItemRecordFocusingChanged: Boolean);
begin
  InitSub();
end;

procedure TfrmProductOrderNewList_CY.TChkClick(Sender: TObject);
begin
 if Order_Main.IsEmpty then exit;
 ADOQueryCmd.Connection.BeginTrans;
  try
    with ADOQueryCmd do
    begin
      close;
      sql.Clear;
      sql.Add('update JYOrderCY_Main SET status=''1'' ');
      sql.Add('where mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').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(trim('出运单审核')));
      sql.Add(','+quotedstr(trim('出运单号：'+trim(Order_Main.FieldByName('CYNO').AsString))));
      sql.Add(','+quotedstr(trim('成功')));
      sql.Add(')');
      execsql;
    end;
    ADOQueryCmd.Connection.CommitTrans;
    application.MessageBox('审核成功！','提示信息');
    TBRafresh.Click;
  except
   ADOQueryCmd.Connection.RollbackTrans;
   application.MessageBox('审核失败！','提示信息',0);
  end;
end;

procedure TfrmProductOrderNewList_CY.TNOChkClick(Sender: TObject);
begin
  if Order_Main.IsEmpty then exit;
  ADOQueryCmd.Connection.BeginTrans;
  try
    with ADOQueryCmd do
    begin
      close;
      sql.Clear;
      sql.Add('update  JYOrderCY_Main SET status=''0'' ');
      sql.Add('where mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').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(trim('出运单撤销审核')));
      sql.Add(','+quotedstr(trim('出运单号：'+trim(Order_Main.FieldByName('CYNO').AsString))));
      sql.Add(','+quotedstr(trim('成功')));
      sql.Add(')');
      execsql;
    end;
     ADOQueryCmd.Connection.CommitTrans;
    application.MessageBox('撤销审核成功！','提示信息');
    TBRafresh.Click;
  except
     ADOQueryCmd.Connection.RollbackTrans;
   application.MessageBox('撤销审核失败！','提示信息',0);
  end;
end;

procedure TfrmProductOrderNewList_CY.cxTabControl1Change(Sender: TObject);
begin
  SetStatus();
  TBRafresh.Click;

end;

procedure TfrmProductOrderNewList_CY.TSChkClick(Sender: TObject);
begin
 if Order_Main.IsEmpty then exit;
 ADOQueryCmd.Connection.BeginTrans;
  try
    with ADOQueryCmd do
    begin
      close;
      sql.Clear;
      sql.Add('update JYOrderCY_Main SET status=''2'' ');
      sql.Add('where mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').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(trim('出运单仓库审核')));
      sql.Add(','+quotedstr(trim('出运单号：'+trim(Order_Main.FieldByName('CYNO').AsString))));
      sql.Add(','+quotedstr(trim('成功')));
      sql.Add(')');
      execsql;
    end;
    ADOQueryCmd.Connection.CommitTrans;
    application.MessageBox('审核成功！','提示信息');
    TBRafresh.Click;
  except
   ADOQueryCmd.Connection.RollbackTrans;
   application.MessageBox('审核失败！','提示信息',0);
  end;
end;

procedure TfrmProductOrderNewList_CY.TSNoChkClick(Sender: TObject);
begin
  if Order_Main.IsEmpty then exit;
  ADOQueryCmd.Connection.BeginTrans;
  try
    with ADOQueryCmd do
    begin
      close;
      sql.Clear;
      sql.Add('update  JYOrderCY_Main SET status=''1'' ');
      sql.Add('where mainID='+quotedstr(trim(Order_Main.fieldbyname('mainID').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(trim('出运单撤销审核')));
      sql.Add(','+quotedstr(trim('出运单号：'+trim(Order_Main.FieldByName('CYNO').AsString))));
      sql.Add(','+quotedstr(trim('成功')));
      sql.Add(')');
      execsql;
    end;
     ADOQueryCmd.Connection.CommitTrans;
    application.MessageBox('撤销审核成功！','提示信息');
    TBRafresh.Click;
  except
     ADOQueryCmd.Connection.RollbackTrans;
   application.MessageBox('撤销审核失败！','提示信息',0);
  end;
end;

end.
