unit U_ProductOrderNewList_BQNew;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
  cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView,
  cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxMemo,
  cxRichEdit, ComCtrls, cxContainer, cxTextEdit, cxMaskEdit, cxButtonEdit,
  StdCtrls, ToolWin, DBClient, ADODB, ExtCtrls, BtnEdit, cxCalendar, StrUtils,
  cxCurrencyEdit, cxImage, cxDBEdit, Menus, RM_Common, RM_Class, RM_e_Xls,
  RM_Dataset, RM_System, RM_GridReport, cxGridCustomPopupMenu, cxGridPopupMenu,
  cxPC, cxSplitter, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdFTP, ShellAPI, cxCheckBox, cxLookAndFeels, cxLookAndFeelPainters,
  cxNavigator, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint,
  dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
  dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
  dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
  dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
  dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
  dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
  dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
  dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
  dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinPumpkin,
  dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
  dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
  dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine,
  dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue, dxSkinscxPCPainter;

type
  TfrmProductOrderNewList_BQNew = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: 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;
    MLOrderNo: TEdit;
    v1MLOrderNo: TcxGridDBColumn;
    v1OrdDate: TcxGridDBColumn;
    v1MLConNo: TcxGridDBColumn;
    Order_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMDBMain: TRMDBDataSet;
    RMXLSExport1: TRMXLSExport;
    v1KHName: TcxGridDBColumn;
    Label4: TLabel;
    KHName: TEdit;
    PopupMenu1: TPopupMenu;
    N2: TMenuItem;
    ToolButton1: TToolButton;
    Label9: TLabel;
    MLConNo: TEdit;
    Label12: TLabel;
    MPRTKZ: TEdit;
    ADOQueryPrint: TADOQuery;
    CDS_Print: TClientDataSet;
    v1ZQty: TcxGridDBColumn;
    cxSplitter1: TcxSplitter;
    ADOQuerySub: TADOQuery;
    DataSource2: TDataSource;
    ADOQueryImage: TADOQuery;
    DSImage: TDataSource;
    IdFTP1: TIdFTP;
    MLCodeName: TEdit;
    Label5: TLabel;
    N1: TMenuItem;
    v1Ssel: TcxGridDBColumn;
    DataSource3: TDataSource;
    Panel2: TPanel;
    Order_Print: TClientDataSet;
    Label7: TLabel;
    status: TComboBox;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    v1XHNo: TcxGridDBColumn;
    v1MLColor: TcxGridDBColumn;
    v1MLColorNo: TcxGridDBColumn;
    v1MLHX: TcxGridDBColumn;
    v1Qty: TcxGridDBColumn;
    v1QtyUnit: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    v1MLCodeName: TcxGridDBColumn;
    ADOQuery1: TADOQuery;
    DataSource4: TDataSource;
    Ord_GX: TClientDataSet;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    Button2: TButton;
    v1CPBQName: TcxGridDBColumn;
    v1CPBaoBQName: TcxGridDBColumn;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    Button1: TButton;
    Button3: TButton;
    v1PiZhong: TcxGridDBColumn;
    v1XS: TcxGridDBColumn;
    PiZhong: TEdit;
    XS: TEdit;
    ToolButton6: TToolButton;
    Tv1MaXS: TcxGridDBColumn;
    Button4: TButton;
    MaXS: TEdit;
    Tv1Filler: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure MLOrderNoChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure Tv1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure Button2Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure ToolButton5Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure ToolButton6Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    DQdate: TDateTime;
    procedure InitGrid();
    procedure InitForm();
    function DelData(): Boolean;
    procedure InitSub();
    procedure SetStatus();
    { Private declarations }
  public
    FFInt, FCloth: Integer;
    canshu1, canshu2, canshu3: string;
    fFlileFlag: string;
    { Public declarations }
  end;

var
  frmProductOrderNewList_BQNew: TfrmProductOrderNewList_BQNew;

implementation

uses
  U_DataLink, U_Fun, U_FjList_RZ, U_OrderInPut_New, U_KHList_CX, U_LabelList;
{$R *.dfm}

procedure TfrmProductOrderNewList_BQNew.SetStatus();
begin
  v1Ssel.Visible := true;
end;

procedure TfrmProductOrderNewList_BQNew.InitSub();
begin
  if Order_Main.IsEmpty then
    exit;
  with ADOQuerySub do
  begin
    close;
    sql.Clear;
    sql.Add('select * from ML_OrderSubidNew ');
    sql.Add('where NewMLID =' + quotedstr((Order_Main.fieldbyname('NewMLID').AsString)));
    open;
  end;
  with ADOQuery1 do
  begin
    close;
    sql.Clear;
    sql.Add('select * from ML_GX ');
    sql.Add('where NewMLID =' + quotedstr((Order_Main.fieldbyname('NewMLID').AsString)));
    open;
  end;
  SCreateCDS20(ADOQuery1, Ord_GX);
  SInitCDSData20(ADOQuery1, Ord_GX);
end;

procedure TfrmProductOrderNewList_BQNew.FormDestroy(Sender: TObject);
begin
  frmProductOrderNewList_BQNew := nil;
end;

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

procedure TfrmProductOrderNewList_BQNew.FormCreate(Sender: TObject);
begin
  cxgrid1.Align := alClient;
  DQdate := SGetServerDate(ADOQueryTemp);
  canshu1 := trim(DParameters1);
  canshu2 := trim(DdataBase);
end;

procedure TfrmProductOrderNewList_BQNew.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid('生产指示单标签', Tv1, '生产指示单管理');
end;

procedure TfrmProductOrderNewList_BQNew.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.add('select A.* ');
      SQL.Add(',ZQty=(select Sum(B.Qty) from ML_OrderSubidNew B where B.NewMLID=A.NewMLID) ');
      sql.Add('from ML_OrderMainNew A ');
      sql.Add('where A.OrdDate>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.DateTime)) + ''' ');
      sql.Add('and A.OrdDate<''' + Trim(FormatDateTime('yyyy-MM-dd', endDate.DateTime + 1)) + ''' ');
      if canshu1 <> '高权限' then
      begin
        SQL.Add(' and filler=''' + trim(DName) + '''');
      end;
      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_Main);
    SInitCDSData20(ADOQueryMain, Order_Main);
  finally
    ADOQueryMain.EnableControls;
    TBFind.Click;
  end;
end;

procedure TfrmProductOrderNewList_BQNew.InitForm();
begin
  ReadCxGrid('生产指示单标签', Tv1, '生产指示单管理');
  BegDate.DateTime := SGetServerDate10(ADOQueryTemp) - 15;
  EndDate.DateTime := SGetServerDate10(ADOQueryTemp);
  InitGrid();
end;

procedure TfrmProductOrderNewList_BQNew.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 TfrmProductOrderNewList_BQNew.DelData(): Boolean;
begin

end;

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

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

procedure TfrmProductOrderNewList_BQNew.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  ToolButton1.Click;
end;

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

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

procedure TfrmProductOrderNewList_BQNew.N1Click(Sender: TObject);
begin
  SelOKNo(Order_Main, false);
end;

procedure TfrmProductOrderNewList_BQNew.N2Click(Sender: TObject);
begin
  SelOKNo(Order_Main, True);
end;

procedure TfrmProductOrderNewList_BQNew.ToolButton1Click(Sender: TObject);
begin
  if Order_Main.IsEmpty then
    Exit;
  try
    frmOrderInPut_New := TfrmOrderInPut_New.Create(Application);
    with frmOrderInPut_New do
    begin
      PState := 1;
      FMainId := Trim(Self.Order_Main.fieldbyname('NewMLID').AsString);
      TBSave.Visible := False;
      ScrollBox1.Enabled := False;
      Tv1.OptionsSelection.CellSelect := False;
      canshu1 := self.canshu1;
      canshu2 := self.canshu2;
      if ShowModal = 1 then
      begin

      end;
    end;
  finally
    frmOrderInPut_New.Free;
  end;
end;

procedure TfrmProductOrderNewList_BQNew.Tv1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  InitSub();
end;

procedure TfrmProductOrderNewList_BQNew.Button2Click(Sender: TObject);
begin
  try
    frmKHList_CX := TfrmKHList_CX.Create(Application);
    with frmKHList_CX do
    begin
      if self.canshu1 <> '高权限' then
        canshu1 := '业务员';
      if ShowModal = 1 then
      begin
        Self.KHName.Text := Trim(CDS_HZ.fieldbyname('KHName').AsString);
        TBFind.Click;
      end;
    end;
  finally
    frmKHList_CX.Free;
  end;
end;

procedure TfrmProductOrderNewList_BQNew.ToolButton3Click(Sender: TObject);
var
  fPrintFile: string;
  Txt, fImagePath: string;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  if Order_Main.IsEmpty then
    exit;
  if trim(Order_Main.fieldbyname('CPBQName').AsString) = '' then
    exit;
  with ADOQueryPrint do
  begin
    Close;
    SQL.Clear;
    sql.Add('exec P_Print_New_Roll ');
    sql.Add('@mainID=''' + trim(Order_Main.fieldbyname('NewMLID').AsString) + ''' ');
    Open;
  end;
  try
    Moudle := LoadLibrary('MakeQRBarcode.dll');
    @Makebar := GetProcAddress(Moudle, 'Make');
    @Mixtext := GetProcAddress(Moudle, 'MixText');
    Txt := Trim(ADOQueryPrint.fieldbyname('JYID').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\' + Trim(Order_Main.fieldbyname('CPBQName').AsString) + '.rmf';
  if FileExists(fPrintFile) then
  begin
    RMVariables['QRBARCODE'] := fImagePath;
    RM1.LoadFromFile(fPrintFile);
    RM1.ShowReport;
  end
  else
  begin
    Application.MessageBox(PChar('没有找到' + trim(fPrintFile)), '提示信息', 0);
  end;
end;

procedure TfrmProductOrderNewList_BQNew.ToolButton4Click(Sender: TObject);
type
  TMyFunc = function(App: Tapplication; FormH: hwnd; FormID: integer; Language: integer; WinStyle: integer; GCode: Pchar; GName: Pchar; DataBase: Pchar; Title: PChar; Parameters1: PChar; Parameters2: PChar; Parameters3: PChar; Parameters4: PChar; Parameters5: PChar; Parameters6: PChar; Parameters7: PChar; Parameters8: PChar; Parameters9: PChar; Parameters10: PChar; DataBaseStr: PChar): hwnd; stdcall;
var
  Tf: TMyFunc;
  Tp: TFarProc;
  Th: Thandle;
  LabInt, labname: string;
begin
  //if PPInt=2 then Exit;
  Ddatabase := StringOfChar(' ', 32);
  Th := LoadLibrary('LabelSet.dll');
  if Th > 0 then
  begin
    try
      Tp := GetProcAddress(Th, 'GetDllForm');
      if Tp <> nil then
      begin
        Tf := TMyFunc(Tp);
        newh := Tf(Application, 0, 2, 0, 0, PChar(DCode), PChar(DName), PChar(Ddatabase), PChar('标签模版设置'), PChar(''), PChar(''), '', '', '', '', '', '', '', '', PChar(DConString));
        if Trim(PChar(Ddatabase)) <> '' then
        begin
          Ddatabase := Trim(PChar(Ddatabase));
          LabInt := Trim(LeftBStr(Ddatabase, Pos('|', Ddatabase) - 1));
          labname := Trim(RightBStr(Ddatabase, Length(Ddatabase) - Pos('|', Ddatabase)));
          with ADOQueryCmd do
          begin
            Close;
            sql.Clear;
            sql.Add('Update ML_OrderMainNew Set CPBaoBQName=''' + Trim(labname) + '''');
            sql.Add(' where NewMLID=''' + Trim(Order_Main.fieldbyname('NewMLID').AsString) + '''');
            ExecSQL;
          end;
          with Order_Main do
          begin
            Edit;
            FieldByName('CPBaoBQName').Value := labname;
            Post;
          end;
        end;
      end
      else
      begin
        ShowMessage('打印执行错误');
      end;
    finally
    // FreeLibrary();
    end;
  end
  else
  begin
    ShowMessage('找不到' + Trim('LabelSet.dll'));
  end;
  tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmProductOrderNewList_BQNew.ToolButton5Click(Sender: TObject);
var
  fPrintFile: string;
  Txt, fImagePath: string;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  if Order_Main.IsEmpty then
    exit;
  if trim(Order_Main.fieldbyname('CPBaoBQName').AsString) = '' then
    exit;
  with ADOQueryPrint do
  begin
    Close;
    SQL.Clear;
    sql.Add('exec P_Print_New_Bao ');
    sql.Add('@mainID=''' + trim(Order_Main.fieldbyname('NewMLID').AsString) + ''' ');
    Open;
  end;
  try
    Moudle := LoadLibrary('MakeQRBarcode.dll');
    @Makebar := GetProcAddress(Moudle, 'Make');
    @Mixtext := GetProcAddress(Moudle, 'MixText');
    Txt := Trim(ADOQueryPrint.fieldbyname('JYID').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\' + Trim(Order_Main.fieldbyname('CPBaoBQName').AsString) + '.rmf';
  if FileExists(fPrintFile) then
  begin
    RMVariables['QRBARCODE'] := fImagePath;
    RM1.LoadFromFile(fPrintFile);
    RM1.ShowReport;
  end
  else
  begin
    Application.MessageBox(PChar('没有找到' + trim(fPrintFile)), '提示信息', 0);
  end;
end;

procedure TfrmProductOrderNewList_BQNew.Button1Click(Sender: TObject);
var
  FPiZhong: string;
  FReal: Double;
begin
  if Trim(PiZhong.Text) = '' then
  begin
    Application.MessageBox('皮重不能为空!', '提示', 0);
    Exit;
  end;
  if TryStrToFloat(PiZhong.Text, FReal) = False then
  begin
    Application.MessageBox('皮重非法数字!', '提示', 0);
    Exit;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('Update ML_OrderMainNew Set PiZhong=' + (PiZhong.Text));
    sql.Add(' where NewMLID=''' + Trim(Order_Main.fieldbyname('NewMLID').AsString) + '''');
    ExecSQL;
  end;
  with Order_Main do
  begin
    Edit;
    FieldByName('PiZhong').Value := PiZhong.Text;
    Post;
  end;
  tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmProductOrderNewList_BQNew.Button3Click(Sender: TObject);
var
  FPiZhong: string;
  FReal: Double;
begin
  if Trim(XS.Text) = '' then
  begin
    Application.MessageBox('系数不能为空!', '提示', 0);
    Exit;
  end;
  if TryStrToFloat(XS.Text, FReal) = False then
  begin
    Application.MessageBox('系数非法数字!', '提示', 0);
    Exit;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('Update ML_OrderMainNew Set XS=' + (XS.Text));
    sql.Add(' where NewMLID=''' + Trim(Order_Main.fieldbyname('NewMLID').AsString) + '''');
    ExecSQL;
  end;
  with Order_Main do
  begin
    Edit;
    FieldByName('XS').Value := XS.Text;
    Post;
  end;
  tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmProductOrderNewList_BQNew.ToolButton6Click(Sender: TObject);
var
  labname: string;
begin
  try
    frmLabelList := TfrmLabelList.Create(Application);
    with frmLabelList do
    begin
      if ShowModal = 1 then
      begin
        labname := Trim(ADOQueryLabel.fieldbyname('labelCaption').AsString);
//
//        Ddatabase := Trim(PChar(Ddatabase));
//          LabInt := Trim(LeftBStr(Ddatabase, Pos('|', Ddatabase) - 1));
//          labname := Trim(RightBStr(Ddatabase, Length(Ddatabase) - Pos('|', Ddatabase)));
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update ML_OrderMainNew Set CPBQName=''' + Trim(labname) + '''');
          sql.Add(' where NewMLID=''' + Trim(Order_Main.fieldbyname('NewMLID').AsString) + '''');
          ExecSQL;
        end;
        with Order_Main do
        begin
          Edit;
          FieldByName('CPBQName').Value := labname;
          Post;
        end;
      end;
    end;
  finally
    frmLabelList.Free;
  end;
end;

procedure TfrmProductOrderNewList_BQNew.Button4Click(Sender: TObject);
var
  FReal: Double;
begin
  if Trim(MaXS.Text) = '' then
  begin
    Application.MessageBox('码数不能为空!', '提示', 0);
    Exit;
  end;
  if TryStrToFloat(MaXS.Text, FReal) = False then
  begin
    Application.MessageBox('码数非法数字!', '提示', 0);
    Exit;
  end;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('Update ML_OrderMainNew Set MaXS=' + (MaXS.Text));
    sql.Add(' where NewMLID=''' + Trim(Order_Main.fieldbyname('NewMLID').AsString) + '''');
    ExecSQL;
  end;
  with Order_Main do
  begin
    Edit;
    FieldByName('MaXS').Value := MaXS.Text;
    Post;
  end;
  tv1.Controller.EditingController.ShowEdit();
end;

end.

