unit U_ProductOrderLBNameSet;

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,StrUtils,
  Menus, cxTextEdit, cxDropDownEdit;

type
  TfrmProductOrderLBNameSet = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: 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;
    OrderNoM: TEdit;
    v1OrderNo: TcxGridDBColumn;
    v1OrdDate: TcxGridDBColumn;
    v1DeliveryDate: TcxGridDBColumn;
    v1ConNo: TcxGridDBColumn;
    v1MPRTSpec: TcxGridDBColumn;
    Order_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMDBMain: TRMDBDataSet;
    RMXLSExport1: TRMXLSExport;
    v1CustomerNoName: TcxGridDBColumn;
    Label4: TLabel;
    CustomerNoName: TEdit;
    v1MPRTCodeName: TcxGridDBColumn;
    v1MPRTMF: TcxGridDBColumn;
    PopupMenu1: TPopupMenu;
    N2: TMenuItem;
    ToolButton1: TToolButton;
    Label8: TLabel;
    MPRTCodeName: TEdit;
    Label9: TLabel;
    ConNo: TEdit;
    v1MPRTKZ: TcxGridDBColumn;
    v1OrdDefStr1: TcxGridDBColumn;
    Label10: TLabel;
    MPRTSpec: TEdit;
    Label11: TLabel;
    MPRTCode: TEdit;
    Label12: TLabel;
    MPRTKZ: TEdit;
    Label13: TLabel;
    MPRTMF: TEdit;
    ADOQueryPrint: TADOQuery;
    CDS_Print: TClientDataSet;
    v1Column4: TcxGridDBColumn;
    Panel4: TPanel;
    Label14: TLabel;
    Panel10: TPanel;
    Image2: TImage;
    Button1: TButton;
    RadioGroup1: TRadioGroup;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    PiZhong: TEdit;
    ToolButton4: TToolButton;
    v1Column3: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column6: 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 TBPrintClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure OrderNoMChange(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 Tv1StylesGetContentStyle(Sender: TcxCustomGridTableView;
      ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
      out AStyle: TcxStyle);
    procedure v1DeliveryDateCustomDrawCell(Sender: TcxCustomGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
      var ADone: Boolean);
    procedure ToolButton1Click(Sender: TObject);
    procedure OrderNoMKeyPress(Sender: TObject; var Key: Char);
    procedure ConNoKeyPress(Sender: TObject; var Key: Char);
    procedure Panel10MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Button1Click(Sender: TObject);
    procedure Image2Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure v1Column3PropertiesEditValueChanged(Sender: TObject);
    procedure v1Column5PropertiesEditValueChanged(Sender: TObject);
    procedure v1Column6PropertiesEditValueChanged(Sender: TObject);
  private
    DQdate:TDateTime;
    procedure InitGrid();
    procedure InitForm();

    { Private declarations }
  public
    FFInt,FCloth:Integer;

    { Public declarations }
  end;

var
  frmProductOrderLBNameSet: TfrmProductOrderLBNameSet;
  newh:hwnd;
implementation
uses
  U_DataLink,U_OrderInPut,U_Fun;

{$R *.dfm}

procedure TfrmProductOrderLBNameSet.FormDestroy(Sender: TObject);
begin
  frmProductOrderLBNameSet:=nil;
end;

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

procedure TfrmProductOrderLBNameSet.FormCreate(Sender: TObject);
begin
  cxgrid1.Align:=alClient;
  //BegDate.DateTime:=SGetServerDateTime(ADOQueryTemp)-7;
  //EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
  DQdate:=SGetServerDate(ADOQueryTemp);
end;

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

procedure TfrmProductOrderLBNameSet.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered:=False;
      Close;
      sql.Clear;
      sql.add('exec P_View_Order :begdate,:enddate,:WSql') ;
      Parameters.ParamByName('WSql').Value:='';
      Parameters.ParamByName('begdate').Value:=FormatDateTime('yyyy-MM-dd',BegDate.DateTime);
      Parameters.ParamByName('enddate').Value:=FormatDateTime('yyyy-MM-dd',enddate.DateTime+1);
      ExecSQL;
      Open;
    end;
    SCreateCDS20(ADOQueryMain,Order_Main);
    SInitCDSData20(ADOQueryMain,Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;


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

procedure TfrmProductOrderLBNameSet.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 TfrmProductOrderLBNameSet.TBPrintClick(Sender: TObject);
begin
  Button1.Click;
end;

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

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

procedure TfrmProductOrderLBNameSet.Tv1CellDblClick(
  Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  if ToolButton1.Visible=False then Exit;
  ToolButton1.Click;
end;

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

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

procedure TfrmProductOrderLBNameSet.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 TfrmProductOrderLBNameSet.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 TfrmProductOrderLBNameSet.ToolButton1Click(Sender: TObject);
begin
  if Order_Main.IsEmpty then Exit;
  try
    frmOrderInPut:=TfrmOrderInPut.Create(Application);
    with frmOrderInPut do
    begin
      PState:=1;
      FMainId:=Trim(Self.Order_Main.fieldbyname('MainId').AsString);
      ToolBar2.Visible:=False;
      TBSave.Visible:=False;
      ScrollBox1.Enabled:=False;
      Tv1.OptionsSelection.CellSelect:=False;
      if ShowModal=1 then
      begin

      end;
    end;
  finally
    frmOrderInPut.Free;
  end;
end;

procedure TfrmProductOrderLBNameSet.OrderNoMKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key=#13 then
  begin
    if Length(OrderNoM.Text)<3 then Exit;
    try
      ADOQueryMain.DisableControls;
      with ADOQueryMain do
      begin
        Filtered:=False;
        Close;
        sql.Clear;
        sql.add('exec P_View_Order :begdate,:enddate,:WSql') ;
        begin
          Parameters.ParamByName('WSql').Value:=' and orderno like '''+'%'+Trim(OrderNoM.Text)+'%'+'''';
        end;
        Parameters.ParamByName('begdate').Value:='1899-01-01';
        Parameters.ParamByName('enddate').Value:='2050-01-01';
        ExecSQL;
        Open;
      end;
      SCreateCDS20(ADOQueryMain,Order_Main);
      SInitCDSData20(ADOQueryMain,Order_Main);
    finally
      ADOQueryMain.EnableControls;
    end;
  end;
end;

procedure TfrmProductOrderLBNameSet.ConNoKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key=#13 then
  begin
    if Length(conno.Text)<3 then Exit;
    try
      ADOQueryMain.DisableControls;
      with ADOQueryMain do
      begin
        Filtered:=False;
        Close;
        sql.Clear;
        sql.add('exec P_View_Order :begdate,:enddate,:WSql') ;
        begin
          Parameters.ParamByName('WSql').Value:=' and conno like '''+'%'+Trim(conno.Text)+'%'+'''';
        end;
        Parameters.ParamByName('begdate').Value:='1899-01-01';
        Parameters.ParamByName('enddate').Value:='2050-01-01';
        ExecSQL;
        Open;
      end;
      SCreateCDS20(ADOQueryMain,Order_Main);
      SInitCDSData20(ADOQueryMain,Order_Main);
    finally
      ADOQueryMain.EnableControls;
    end;
  end;
end;

procedure TfrmProductOrderLBNameSet.Panel10MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture;
  TWinControl(Panel4).Perform(WM_SYSCOMMAND,$F012,0);
end;

procedure TfrmProductOrderLBNameSet.Button1Click(Sender: TObject);
var
   fPrintFile:string;
   Porderno,LBName,SYRName:string;
   i,j:Integer;
   OrderKg:Double;
begin
  if Order_Main.IsEmpty then Exit;
  LBName:=RadioGroup1.Items.Strings[RadioGroup1.ItemIndex];
  fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\'+Trim(LBName)+'.rmf' ;
  if Trim(Order_Main.fieldbyname('SYRName').AsString)='' then
  begin
    with ADOQueryTemp do
    begin
      Close;
      sql.Clear;
      sql.Add('select Top 1 B.ZdyName SYRName from JYOrderCon_Main A');
      sql.Add(' left join KH_Zdy B on A.SYRName=B.Note');
      sql.Add(' where A.ConNo='''+Trim(Order_Main.fieldbyname('ConNo').AsString)+'''');
      Open;
    end;
    SYRName:=Trim(ADOQueryTemp.fieldbyname('SYRName').AsString);
  end else
  begin
    SYRName:=Trim(Order_Main.fieldbyname('SYRName').AsString);
  end;

    with ADOQueryPrint do
    begin
      Close;
      sql.Clear;
      sql.Add('exec F_Get_Print_Order       ');
      sql.add('@mainID='+quotedstr(trim(Order_Main.fieldbyname('MainID').AsString)));
      Open;
    end;


  SCreateCDS20(ADOQueryPrint,CDS_Print);
  SInitCDSData20(ADOQueryPrint,CDS_Print);

  if FileExists(fPrintFile) then
  begin
    RM1.LoadFromFile(fPrintFile);
    RMVariables['SYRName']:=Trim(SYRName);
    RM1.ShowReport;
  end else
  begin
    Application.MessageBox(PChar('没有找'+ExtractFilePath(Application.ExeName)+'Report\'+Trim(LBName)+'.rmf'),'提示',0);
  end;
end;

procedure TfrmProductOrderLBNameSet.Image2Click(Sender: TObject);
begin
  Panel4.Visible:=False;
end;

procedure TfrmProductOrderLBNameSet.ToolButton2Click(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 JYOrder_Main Set LBName='''+Trim(labname)+'''');
              sql.Add(' where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
              ExecSQL;
            end;
            with Order_Main do
            begin
              Edit;
              FieldByName('LbName').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 TfrmProductOrderLBNameSet.ToolButton3Click(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 JYOrder_Main Set PiZhong='+Trim(PiZhong.Text));
    sql.Add(' where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
    ExecSQL;
  end;
  with Order_Main do
  begin
    Edit;
    FieldByName('PiZhong').Value:=PiZhong.Text;
    Post;
  end;
tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmProductOrderLBNameSet.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 JYOrder_Main Set NLBName='''+Trim(labname)+'''');
              sql.Add(' where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
              ExecSQL;
            end;
            with Order_Main do
            begin
              Edit;
              FieldByName('NLbName').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 TfrmProductOrderLBNameSet.v1Column3PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalues:string;
begin
  mvalues:=TCXTextEdit(Sender).Text;

  with Order_Main do
  begin
    edit;
    fieldbyname('NLBName').Value:=mvalues;
    post;
  end;
  tv1.Controller.EditingController.ShowEdit();
  IF trim(mvalues)='' then
  begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update JYOrder_Main Set NLBName='''' ');
          sql.Add('where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
          ExecSQL;
        end;
  end
end;

procedure TfrmProductOrderLBNameSet.v1Column5PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalues:string;
begin
  mvalues:=TCXTextEdit(Sender).Text;

  with Order_Main do
  begin
    edit;
    fieldbyname('Orddefstr15').Value:=mvalues;
    post;
  end;
  tv1.Controller.EditingController.ShowEdit();

  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('Update JYOrder_Main Set Orddefstr15='''+trim(mvalues)+''' ');
    sql.Add('where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
    ExecSQL;
  end;


end;

procedure TfrmProductOrderLBNameSet.v1Column6PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalues:string;
begin
  mvalues:=TCXTextEdit(Sender).Text;

  with Order_Main do
  begin
    edit;
    fieldbyname('Orddefstr14').Value:=mvalues;
    post;
  end;
  tv1.Controller.EditingController.ShowEdit();

  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('Update JYOrder_Main Set Orddefstr14='''+trim(mvalues)+''' ');
    sql.Add('where Mainid='''+Trim(Order_Main.fieldbyname('Mainid').AsString)+'''');
    ExecSQL;
  end;

end;

end.
