640 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			ObjectPascal
		
	
	
	
	
	
			
		
		
	
	
			640 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			ObjectPascal
		
	
	
	
	
	
unit U_KCRLLTZ_other;
 | 
						||
 | 
						||
interface
 | 
						||
 | 
						||
uses
 | 
						||
  Windows, Messages, strutils,SysUtils, Variants, Classes, Graphics, Controls, Forms,
 | 
						||
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
 | 
						||
  cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView,
 | 
						||
  cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
 | 
						||
  cxGridCustomView, cxGrid, StdCtrls, cxContainer, cxTextEdit,
 | 
						||
  cxCurrencyEdit, BtnEdit, ExtCtrls, ComCtrls, ToolWin, DBClient, ADODB,
 | 
						||
  MovePanel, RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport;
 | 
						||
  function CommOpen(fhandle:hwnd;sCommName:PAnsiChar;
 | 
						||
                    IntTime:integer;IsMessage:integer):integer;stdcall;external 'JCYData.DLL';
 | 
						||
  function CommClose(sCommName:PAnsiChar):integer;stdcall;external 'JCYData.DLL';
 | 
						||
 | 
						||
type
 | 
						||
  TfrmKCRLLTZ_other = class(TForm)
 | 
						||
    ToolBar1: TToolBar;
 | 
						||
    TBSave: TToolButton;
 | 
						||
    TBClose: TToolButton;
 | 
						||
    Panel1: TPanel;
 | 
						||
    Label1: TLabel;
 | 
						||
    cxGrid1: TcxGrid;
 | 
						||
    Tv1: TcxGridDBTableView;
 | 
						||
    v1MJID: TcxGridDBColumn;
 | 
						||
    v1P_Code: TcxGridDBColumn;
 | 
						||
    v1P_Color: TcxGridDBColumn;
 | 
						||
    v1RollNum: TcxGridDBColumn;
 | 
						||
    v1Qty: TcxGridDBColumn;
 | 
						||
    cxGrid1Level1: TcxGridLevel;
 | 
						||
    Panel2: TPanel;
 | 
						||
    cxGrid2: TcxGrid;
 | 
						||
    TV2: TcxGridDBTableView;
 | 
						||
    cxGridDBColumn2: TcxGridDBColumn;
 | 
						||
    cxGridDBColumn3: TcxGridDBColumn;
 | 
						||
    cxGridDBColumn4: TcxGridDBColumn;
 | 
						||
    cxGridDBColumn5: TcxGridDBColumn;
 | 
						||
    cxGridDBColumn6: TcxGridDBColumn;
 | 
						||
    cxGridDBColumn7: TcxGridDBColumn;
 | 
						||
    cxGridLevel1: TcxGridLevel;
 | 
						||
    ADOQueryMain: TADOQuery;
 | 
						||
    ADOQueryCmd: TADOQuery;
 | 
						||
    CDSOrder: TClientDataSet;
 | 
						||
    CDSMJID: TClientDataSet;
 | 
						||
    DataSource1: TDataSource;
 | 
						||
    DataSource2: TDataSource;
 | 
						||
    SmNO: TEdit;
 | 
						||
    ADOQueryTmp: TADOQuery;
 | 
						||
    MovePanel1: TMovePanel;
 | 
						||
    Label2: TLabel;
 | 
						||
    Edit2: TEdit;
 | 
						||
    Button4: TButton;
 | 
						||
    V2Column1: TcxGridDBColumn;
 | 
						||
    cxStyleRepository1: TcxStyleRepository;
 | 
						||
    cxStyle1: TcxStyle;
 | 
						||
    cxStyle2: TcxStyle;
 | 
						||
    cxStyle_gridRow: TcxStyle;
 | 
						||
    cxStyle_gridFoot: TcxStyle;
 | 
						||
    cxStyle_gridHead: TcxStyle;
 | 
						||
    cxStyle_gridGroupBox: TcxStyle;
 | 
						||
    cxStyle_yellow: TcxStyle;
 | 
						||
    cxStyle_Red: TcxStyle;
 | 
						||
    cxStyle_fontBlack: TcxStyle;
 | 
						||
    cxStyle_fontclFuchsia: TcxStyle;
 | 
						||
    cxStyle_fontclPurple: TcxStyle;
 | 
						||
    cxStyle_fontclGreen: TcxStyle;
 | 
						||
    cxStyle_fontclBlue: TcxStyle;
 | 
						||
    cxStyle_fontclTeal: TcxStyle;
 | 
						||
    cxStyle_fontclOlive: TcxStyle;
 | 
						||
    CheckBox3: TCheckBox;
 | 
						||
    Panel3: TPanel;
 | 
						||
    MJLen: TEdit;
 | 
						||
    Label5: TLabel;
 | 
						||
    Label9: TLabel;
 | 
						||
    Edit7: TEdit;
 | 
						||
    Label32: TLabel;
 | 
						||
    Label33: TLabel;
 | 
						||
    Edit8: TEdit;
 | 
						||
    Edit6: TEdit;
 | 
						||
    Label26: TLabel;
 | 
						||
    BTPrint: TButton;
 | 
						||
    Button5: TButton;
 | 
						||
    ADOQueryPrint: TADOQuery;
 | 
						||
    RM2: TRMGridReport;
 | 
						||
    RMDB_Main: TRMDBDataSet;
 | 
						||
    procedure FormDestroy(Sender: TObject);
 | 
						||
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
 | 
						||
    procedure TBCloseClick(Sender: TObject);
 | 
						||
 | 
						||
    procedure FormCreate(Sender: TObject);
 | 
						||
    procedure SmNOKeyPress(Sender: TObject; var Key: Char);
 | 
						||
    procedure FormShow(Sender: TObject);
 | 
						||
    procedure Button4Click(Sender: TObject);
 | 
						||
    procedure Edit7Click(Sender: TObject);
 | 
						||
    procedure Edit8Click(Sender: TObject);
 | 
						||
    procedure Edit6Click(Sender: TObject);
 | 
						||
    procedure BTPrintClick(Sender: TObject);
 | 
						||
    procedure Tv1DblClick(Sender: TObject);
 | 
						||
    procedure Button5Click(Sender: TObject);
 | 
						||
  private
 | 
						||
    procedure InitGrid();
 | 
						||
    procedure InitMJID();
 | 
						||
    function  Savedata1():boolean;
 | 
						||
    function  Savedata2():boolean;
 | 
						||
    procedure Printdata(fCRID:string);
 | 
						||
    procedure On1201(Var Message:Tmessage);
 | 
						||
    { Private declarations }
 | 
						||
  public
 | 
						||
      iscom:boolean;
 | 
						||
    { Public declarations }
 | 
						||
  end;
 | 
						||
 | 
						||
var
 | 
						||
  frmKCRLLTZ_other: TfrmKCRLLTZ_other;
 | 
						||
 | 
						||
implementation
 | 
						||
uses
 | 
						||
  U_DataLink,U_Fun, U_UserHelp, U_ZDYHelp;
 | 
						||
{$R *.dfm}
 | 
						||
procedure TfrmKCRLLTZ_other.On1201(Var Message:Tmessage);
 | 
						||
var
 | 
						||
  i1,i2:integer;
 | 
						||
  unitname:string;
 | 
						||
  fdata:double;
 | 
						||
begin
 | 
						||
  i1:=message.WParam;
 | 
						||
  i2:=message.LParam;
 | 
						||
 | 
						||
  IF not CheckBox3.Checked then exit;
 | 
						||
 | 
						||
  IF trim(DParameters10)='<27><>С<EFBFBD><D0A1>'then
 | 
						||
  MJLen.Text:= format('%.2f',[i1/100000])
 | 
						||
  else
 | 
						||
  MJLen.Text:= format('%.0f',[i1/100000]);
 | 
						||
  IF i2=0 then Label9.Caption:='M' else  Label9.Caption:='Y';
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.Printdata(fCRID:string);
 | 
						||
var
 | 
						||
  fPrintFile:String;
 | 
						||
  mvalue:Double;
 | 
						||
  Txt,fImagePath:string;
 | 
						||
  Moudle: THandle;
 | 
						||
  Makebar:TMakebar;
 | 
						||
  Mixtext:TMixtext;
 | 
						||
begin
 | 
						||
    with ADOQueryPrint do
 | 
						||
    begin
 | 
						||
      Close;
 | 
						||
      SQL.Clear;
 | 
						||
      sql.Add('select A.*,kcQty as mjlen,kcQtyUnit as MJTypeother ');
 | 
						||
      sql.Add(' from CK_BanCP_KC1 A') ;
 | 
						||
      //SQL.Add(' where A.MJID='''+Trim(CDS_Main.fieldbyname('MJID').AsString)+'''');
 | 
						||
      SQL.Add(' where A.CRID='+quotedstr(trim(fCRID)));
 | 
						||
      Open;
 | 
						||
    end;
 | 
						||
    try
 | 
						||
      Moudle:=LoadLibrary('MakeQRBarcode.dll');
 | 
						||
      @Makebar:=GetProcAddress(Moudle,'Make');
 | 
						||
      @Mixtext:=GetProcAddress(Moudle,'MixText');
 | 
						||
      Txt:=Trim(ADOQueryPrint.fieldbyname('MJID').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('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
 | 
						||
      exit;
 | 
						||
    end;
 | 
						||
 | 
						||
 | 
						||
    fPrintFile:=ExtractFilePath(Application.ExeName)+'Report\ͨ<>ñ<EFBFBD>ǩ.rmf' ;
 | 
						||
    if FileExists(fPrintFile) then
 | 
						||
    begin
 | 
						||
      RMVariables['QRBARCODE']:=fImagePath;
 | 
						||
      RM2.LoadFromFile(fPrintFile);
 | 
						||
   //   RM2.ShowReport;
 | 
						||
      RM2.PrintReport;
 | 
						||
     // MJLen.SetFocus;
 | 
						||
    end else
 | 
						||
    begin
 | 
						||
      Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\<5C><><EFBFBD><EFBFBD>ǩ.rmf'),'<27><>ʾ',0);
 | 
						||
    end;
 | 
						||
 | 
						||
end;
 | 
						||
function  TfrmKCRLLTZ_other.Savedata2():boolean;
 | 
						||
var
 | 
						||
  i,FCRID:integer;
 | 
						||
  fconNo,FC_CodeName,FC_Color:string;
 | 
						||
  fRollNum,FQty:double;
 | 
						||
begin
 | 
						||
  result:=false;
 | 
						||
  IF CDSOrder.RecordCount<=1 then
 | 
						||
  begin
 | 
						||
    application.MessageBox('<27><><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ڻ<EFBFBD><DABB>ߵ<EFBFBD><DFB5><EFBFBD>һƥ<D2BB><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɨ<EFBFBD>赽<EFBFBD><E8B5BD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
 | 
						||
    exit;
 | 
						||
  end;
 | 
						||
 | 
						||
  i:=0;
 | 
						||
  with  CDSOrder do
 | 
						||
  begin
 | 
						||
    DisableControls;
 | 
						||
    First;
 | 
						||
    while not eof do
 | 
						||
    begin
 | 
						||
        if i=0 then
 | 
						||
        begin
 | 
						||
//          fconNo:= trim(Fieldbyname('ConNo').AsString);
 | 
						||
          FC_CodeName:= trim(Fieldbyname('C_CodeName').AsString);
 | 
						||
          FC_Color:= trim(Fieldbyname('C_Color').AsString);
 | 
						||
        end
 | 
						||
        else
 | 
						||
        begin
 | 
						||
         { if trim(fconNo)<>trim(Fieldbyname('ConNo').AsString) then
 | 
						||
          begin
 | 
						||
            EnableControls;
 | 
						||
            application.MessageBox('<27><><EFBFBD>Ų<F1B5A5BA>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ܺϲ<DCBA><CFB2><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
 | 
						||
            exit;
 | 
						||
          end;  }
 | 
						||
          if trim(FC_CodeName)<>trim(Fieldbyname('C_CodeName').AsString) then
 | 
						||
          begin
 | 
						||
            EnableControls;
 | 
						||
            application.MessageBox('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>Ʋ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ܺϲ<DCBA><CFB2><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
 | 
						||
            exit;
 | 
						||
          end;
 | 
						||
          if trim(FC_Color)<>trim(Fieldbyname('C_Color').AsString) then
 | 
						||
          begin
 | 
						||
            EnableControls;
 | 
						||
            application.MessageBox('<27><>ɫ<EFBFBD><C9AB>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ܺϲ<DCBA><CFB2><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
 | 
						||
            exit;
 | 
						||
          end;
 | 
						||
        end;
 | 
						||
        i:=i+1;
 | 
						||
      next;
 | 
						||
    end;
 | 
						||
    EnableControls;
 | 
						||
    First;
 | 
						||
  end;
 | 
						||
 | 
						||
  if i<2 then exit;
 | 
						||
 | 
						||
  ADOQueryCmd.Connection.BeginTrans;
 | 
						||
  try
 | 
						||
 | 
						||
    fRollNum:=0;
 | 
						||
    FQty:=0;
 | 
						||
    i:=0;
 | 
						||
    with  CDSOrder do
 | 
						||
    begin
 | 
						||
      DisableControls;
 | 
						||
      First;
 | 
						||
      while not eof do
 | 
						||
      begin
 | 
						||
      //  if  Fieldbyname('Ssel').AsBoolean then
 | 
						||
      //  begin
 | 
						||
          IF i=0 then
 | 
						||
          fCRID:=Fieldbyname('CRID').AsInteger;
 | 
						||
 | 
						||
          fRollNum:=1;
 | 
						||
          FQty:=strtofloatdef(trim(MJLen.Text),0);
 | 
						||
 | 
						||
          with adoqueryCmd do
 | 
						||
          begin
 | 
						||
            close;
 | 
						||
            sql.Clear;
 | 
						||
            sql.Add('select * from CK_BanCP_KC1 ');
 | 
						||
            sql.Add('where CRID='+quotedstr(trim(CDSOrder.Fieldbyname('CRID').AsString)));
 | 
						||
            open;
 | 
						||
            edit;
 | 
						||
            fieldbyname('ZDYstr1').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD>';
 | 
						||
            fieldbyname('ZDYFlote1').Value:=fieldbyname('kcQty').AsFloat;
 | 
						||
            FieldByName('oldCRID').Value:=fCRID;
 | 
						||
            fieldbyname('KCROllNum').Value:=0;
 | 
						||
            fieldbyname('kcQty').Value:=0;
 | 
						||
            post;
 | 
						||
          end;
 | 
						||
          i:=i+1;
 | 
						||
        //end;
 | 
						||
        next;
 | 
						||
      end;
 | 
						||
      EnableControls;
 | 
						||
      First;
 | 
						||
    end;
 | 
						||
 | 
						||
    with adoqueryCmd do
 | 
						||
    begin
 | 
						||
      close;
 | 
						||
      sql.Clear;
 | 
						||
      sql.Add('select * from CK_BanCP_KC1 ');
 | 
						||
      sql.Add('where CRID='+quotedstr(inttostr(fCRID)));
 | 
						||
      open;
 | 
						||
      edit;
 | 
						||
      fieldbyname('KCROllNum').Value:=1;
 | 
						||
      fieldbyname('kcQty').Value:=FQty;
 | 
						||
      post;
 | 
						||
    end;
 | 
						||
    with adoqueryCmd do
 | 
						||
    begin
 | 
						||
      close;
 | 
						||
      sql.Clear;
 | 
						||
      sql.Add('select * from CK_BanCP_KC1 ');
 | 
						||
      sql.Add('where CRID='+quotedstr(inttostr(fCRID)));
 | 
						||
      open;
 | 
						||
      SInitCDSData20(adoqueryCmd,CDSMJID);
 | 
						||
    end;
 | 
						||
 | 
						||
    ADOQueryCmd.Connection.CommitTrans;
 | 
						||
    CDSOrder.EmptyDataSet;
 | 
						||
    if Trim(Edit6.Text)='<27><>' then
 | 
						||
    begin
 | 
						||
 | 
						||
      printdata(inttostr(fCRID));
 | 
						||
    end;
 | 
						||
    
 | 
						||
    ModalResult:=1;
 | 
						||
  //  application.MessageBox('<27><><EFBFBD>ݺϲ<DDBA><CFB2>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
 | 
						||
 //   TBRafresh.Click;
 | 
						||
  except
 | 
						||
    ADOQueryCmd.Connection.RollbackTrans;
 | 
						||
  //  application.MessageBox('<27><><EFBFBD>ݺϲ<DDBA>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
 | 
						||
  end;
 | 
						||
 | 
						||
 | 
						||
 | 
						||
end;
 | 
						||
 | 
						||
function  TfrmKCRLLTZ_other.Savedata1():boolean;
 | 
						||
var
 | 
						||
  fbcID,FCRID,fAPTM:string;
 | 
						||
  CRID:integer;
 | 
						||
  i:integer;
 | 
						||
begin
 | 
						||
  result:=false;
 | 
						||
 | 
						||
  IF CDSOrder.RecordCount>1 then
 | 
						||
  begin
 | 
						||
    application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD>һƥ<D2BB><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɨ<EFBFBD>赽<EFBFBD><E8B5BD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
 | 
						||
    exit;
 | 
						||
  end;
 | 
						||
  IF strtofloatdef(trim(mjlen.Text),0)>CDSOrder.FieldByName('KCqty').AsFloat then
 | 
						||
  begin
 | 
						||
    application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
 | 
						||
    exit;
 | 
						||
  end;
 | 
						||
 | 
						||
  if GetLSNo(ADOQueryCmd,fAPTM,'C','APTM',4,1)=False then
 | 
						||
  begin
 | 
						||
    Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
 | 
						||
    Exit;
 | 
						||
  end;
 | 
						||
 | 
						||
  fbcID:=CDSOrder.fieldbyname('BCID').AsString;
 | 
						||
  fcrID:=CDSOrder.fieldbyname('CRID').AsString;
 | 
						||
  ADOQueryCmd.Connection.BeginTrans;
 | 
						||
  try
 | 
						||
    with ADOQueryTmp do
 | 
						||
    begin
 | 
						||
      close;
 | 
						||
      sql.Clear;
 | 
						||
      sql.Add('select * from CK_BanCP_KC1 A');
 | 
						||
      sql.Add('where BCID='+quotedstr(trim(fBCID)));
 | 
						||
      sql.Add('and CRID='+quotedstr(trim(fCRID)));
 | 
						||
      open;
 | 
						||
    end;
 | 
						||
    with ADOQueryCmd  do
 | 
						||
    begin
 | 
						||
      Close;
 | 
						||
      sql.Clear;
 | 
						||
      SQL.add('Update CK_BanCP_CRID1 Set CRID=CRID+1');
 | 
						||
      sql.Add('select * from CK_BanCP_CRID1');
 | 
						||
      Open;
 | 
						||
    end;
 | 
						||
    CRID:=ADOQueryCmd.fieldbyname('CRID').AsInteger;
 | 
						||
    with ADOQueryCmd do
 | 
						||
    begin
 | 
						||
      close;
 | 
						||
      sql.Clear;
 | 
						||
      sql.Add('select * from CK_BanCP_KC1 A');
 | 
						||
      sql.Add('where 1=2 ');
 | 
						||
      open;
 | 
						||
    end;
 | 
						||
    ADOQueryCmd.Append;
 | 
						||
    for i:=0 to ADOQueryCmd.FieldCount-1 do
 | 
						||
    begin
 | 
						||
      ADOQueryCmd.fields[i].value:=ADOQueryTmp.Fields[i].Value ;
 | 
						||
    end;
 | 
						||
    ADOQueryCmd.FieldByName('CRID').Value:=CRID;
 | 
						||
    ADOQueryCmd.FieldByName('KCROllNum').Value:=1;
 | 
						||
    ADOQueryCmd.FieldByName('KCQty').Value:=strtofloatdef(MJLen.Text,0);
 | 
						||
    ADOQueryCmd.FieldByName('oldCRID').Value:=fcrID;
 | 
						||
    ADOQueryCmd.FieldByName('KCStatus').Value:=NULL;
 | 
						||
    ADOQueryCmd.FieldByName('MJID').Value:=trim(fAPTM);
 | 
						||
    ADOQueryCmd.fieldbyname('ZDYstr1').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
 | 
						||
    ADOQueryCmd.fieldbyname('ZDYFlote1').Value:= 0;
 | 
						||
    ADOQueryCmd.Post;
 | 
						||
 | 
						||
 | 
						||
    with ADOQueryCmd do
 | 
						||
    begin
 | 
						||
      close;
 | 
						||
      sql.Clear;
 | 
						||
      sql.Add('select * from CK_BanCP_KC1 A');
 | 
						||
      sql.Add('where CRID='''+trim(fCRID)+'''');
 | 
						||
      open;
 | 
						||
    end;
 | 
						||
    ADOQueryCmd.Edit;
 | 
						||
    ADOQueryCmd.FieldByName('KCROllNum').Value:=ADOQueryCmd.FieldByName('KCROllNum').AsFloat - 1;
 | 
						||
    ADOQueryCmd.FieldByName('KCQty').Value:=ADOQueryCmd.FieldByName('KCQty').AsFloat - strtofloatdef(MJLen.Text,0);
 | 
						||
    ADOQueryCmd.fieldbyname('ZDYstr1').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
 | 
						||
    ADOQueryCmd.fieldbyname('ZDYFlote1').Value:= ADOQueryCmd.FieldByName('KCQty').AsFloat;
 | 
						||
    ADOQueryCmd.Post;
 | 
						||
 | 
						||
    with ADOQueryCmd do
 | 
						||
    begin
 | 
						||
      Close;
 | 
						||
      sql.Clear;
 | 
						||
      sql.Add('UPDATE CK_BanCp_KC1 SET KCRollNum =1 ');
 | 
						||
      sql.Add('WHERE (KCQty<>0 or KCKgQty<>0)and KcRollNum=0  ');
 | 
						||
      ExecSQL;
 | 
						||
    end;
 | 
						||
 | 
						||
    with adoqueryCmd do
 | 
						||
    begin
 | 
						||
      close;
 | 
						||
      sql.Clear;
 | 
						||
      sql.Add('select * from CK_BanCP_KC1 ');
 | 
						||
      sql.Add('where CRID='+quotedstr(inttostr(CRID)));
 | 
						||
      open;
 | 
						||
      SInitCDSData20(adoqueryCmd,CDSMJID);
 | 
						||
    end;
 | 
						||
 | 
						||
    with adoqueryCmd do
 | 
						||
    begin
 | 
						||
      close;
 | 
						||
      sql.Clear;
 | 
						||
      sql.Add('select * from CK_BanCP_KC1 ');
 | 
						||
      sql.Add('where CRID='+quotedstr(fCRID));
 | 
						||
      open;
 | 
						||
      SInitCDSData20(adoqueryCmd,CDSMJID);
 | 
						||
    end;
 | 
						||
    ADOQueryCmd.Connection.CommitTrans;
 | 
						||
  //  application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ');
 | 
						||
    CDSOrder.EmptyDataSet;
 | 
						||
 | 
						||
    if Trim(Edit6.Text)='<27><>' then
 | 
						||
    begin
 | 
						||
      printdata(inttostr(CRID));
 | 
						||
      printdata(fCRID);
 | 
						||
    end;
 | 
						||
    ModalResult:=1;
 | 
						||
  except
 | 
						||
    ADOQueryCmd.Connection.RollbackTrans;
 | 
						||
    application.MessageBox('<27><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
 | 
						||
  end;
 | 
						||
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.InitGrid();
 | 
						||
begin
 | 
						||
  with ADOQueryMain do
 | 
						||
  begin
 | 
						||
    Close;
 | 
						||
    sql.Clear;
 | 
						||
    SQL.Add('select * from CK_BanCP_KC1 A');
 | 
						||
    SQL.Add('where 1=2 ');
 | 
						||
    Open;
 | 
						||
  end;
 | 
						||
  SCreateCDS20(ADOQueryMain,CDSOrder);
 | 
						||
  SInitCDSData20(ADOQueryMain,CDSOrder);
 | 
						||
  SCreateCDS20(ADOQueryMain,CDSMJID);
 | 
						||
  SInitCDSData20(ADOQueryMain,CDSMJID);
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.InitMJID();
 | 
						||
var
 | 
						||
  fP_No:string;
 | 
						||
begin
 | 
						||
  MovePanel1.Visible:=false;
 | 
						||
  with ADOQueryMain do
 | 
						||
  begin
 | 
						||
    Close;
 | 
						||
    sql.Clear;
 | 
						||
    SQL.Add('select A.* from CK_BanCP_KC1 A');
 | 
						||
   // sql.add('left join  CK_BanCP_CR B on B.BCID=A.BCID and B.CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
 | 
						||
    SQL.Add('where A.MJID='+quotedstr(trim(SmNO.text)));
 | 
						||
    sql.Add('and isnull(A.KCStatus,''0'')=''0''  ');
 | 
						||
    sql.Add('and KCQty>0  ');
 | 
						||
    Open;
 | 
						||
    if not IsEmpty  then
 | 
						||
    begin
 | 
						||
      IF Fieldbyname('KCQty').AsFloat<=0 then
 | 
						||
      begin
 | 
						||
        MovePanel1.Visible:=true;
 | 
						||
        Edit2.Text:=SmNO.Text;
 | 
						||
        Label2.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѳ<EFBFBD><D1B3><EFBFBD>';
 | 
						||
      end
 | 
						||
      else
 | 
						||
      begin
 | 
						||
         SInitCDSData20(ADOQueryMain,CDSOrder);
 | 
						||
      end;
 | 
						||
    end
 | 
						||
    else
 | 
						||
    begin
 | 
						||
        MovePanel1.Visible:=true;
 | 
						||
        Edit2.Text:=SmNO.Text;
 | 
						||
        Label2.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD>벻<EFBFBD><EBB2BB><EFBFBD><EFBFBD>';
 | 
						||
    end;
 | 
						||
  end;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.FormDestroy(Sender: TObject);
 | 
						||
begin
 | 
						||
  wRITECxGrid(self.Caption+tV1.Name,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
 | 
						||
  wRITECxGrid(self.Caption+TV2.Name,Tv2,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
 | 
						||
  frmKCRLLTZ_other:=nil;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.FormClose(Sender: TObject;
 | 
						||
  var Action: TCloseAction);
 | 
						||
begin
 | 
						||
  if iscom then
 | 
						||
  CommClose(pchar('com2'));
 | 
						||
  Action:=caFree;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.TBCloseClick(Sender: TObject);
 | 
						||
begin
 | 
						||
  close;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.FormCreate(Sender: TObject);
 | 
						||
begin
 | 
						||
  Panel2.Align:=alClient;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.SmNOKeyPress(Sender: TObject; var Key: Char);
 | 
						||
begin
 | 
						||
  IF key=#13 then
 | 
						||
  begin
 | 
						||
    MovePanel1.Visible:=false;
 | 
						||
    if not CDSOrder.Locate('MJID',trim(smNo.Text),[]) then
 | 
						||
    initMjid();
 | 
						||
    smno.Text:='';
 | 
						||
    smno.SetFocus;
 | 
						||
  end;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.FormShow(Sender: TObject);
 | 
						||
begin
 | 
						||
  ReadCxGrid(self.Caption+tV1.Name,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
 | 
						||
  ReadCxGrid(self.Caption+TV2.Name,Tv2,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
 | 
						||
  MovePanel1.Left:=(Width-MovePanel1.Width) div 2;
 | 
						||
  MovePanel1.top:=(Height-MovePanel1.Height-200) div 2;
 | 
						||
  InitGrid();
 | 
						||
  if iscom then
 | 
						||
  begin
 | 
						||
    if CommOpen(frmKCRLLTZ_other.Handle,'',500,1)<1 then
 | 
						||
    begin
 | 
						||
      showmessage('<27><EFBFBD><F2BFAAB4>ڴ<EFBFBD><DAB4><EFBFBD>');
 | 
						||
    end;
 | 
						||
  end;
 | 
						||
  SmNO.SetFocus;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.Button4Click(Sender: TObject);
 | 
						||
begin
 | 
						||
  MovePanel1.Visible:=false;  
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.Edit7Click(Sender: TObject);
 | 
						||
begin
 | 
						||
  if Trim(Edit7.Text)='' then
 | 
						||
  begin
 | 
						||
    Edit7.Text:='<27><>';
 | 
						||
    Edit8.Text:='';
 | 
						||
   // Edit9.Text:='';
 | 
						||
  end else
 | 
						||
  begin
 | 
						||
    Edit7.Text:='';
 | 
						||
    Edit8.Text:='';
 | 
						||
   // Edit9.Text:='';
 | 
						||
  end;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.Edit8Click(Sender: TObject);
 | 
						||
begin
 | 
						||
  if Trim(Edit8.Text)='' then
 | 
						||
  begin
 | 
						||
    Edit7.Text:='';
 | 
						||
    Edit8.Text:='<27><>';
 | 
						||
  //  Edit9.Text:='';
 | 
						||
  end else
 | 
						||
  begin
 | 
						||
    Edit7.Text:='';
 | 
						||
    Edit8.Text:='';
 | 
						||
 //   Edit9.Text:='';
 | 
						||
  end;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.Edit6Click(Sender: TObject);
 | 
						||
begin
 | 
						||
  if Trim(Edit6.Text)='' then
 | 
						||
  begin
 | 
						||
    Edit6.Text:='<27><>';
 | 
						||
  end else
 | 
						||
  begin
 | 
						||
    Edit6.Text:='';
 | 
						||
  end;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.BTPrintClick(Sender: TObject);
 | 
						||
begin
 | 
						||
  if Trim(Edit7.Text)='<27><>' then
 | 
						||
  begin
 | 
						||
    savedata1();
 | 
						||
  end;
 | 
						||
  if Trim(Edit8.Text)='<27><>' then
 | 
						||
  begin
 | 
						||
    savedata2();
 | 
						||
  end;
 | 
						||
  SmNO.SetFocus;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.Tv1DblClick(Sender: TObject);
 | 
						||
begin
 | 
						||
  IF CDSOrder.IsEmpty then exit;
 | 
						||
  CDSOrder.Delete;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmKCRLLTZ_other.Button5Click(Sender: TObject);
 | 
						||
begin
 | 
						||
  If CDSMJID.IsEmpty then exit;
 | 
						||
  printdata(CDSMJID.fieldbyname('CRID').AsString);
 | 
						||
  SmNO.SetFocus;
 | 
						||
end;
 | 
						||
 | 
						||
end.
 |