⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unitcarhistory.pas

📁 绿色衡器称重系统(串口)
💻 PAS
字号:
unit unitCarHistory;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
//             该系统源码归青岛东亚电子衡器有限公司版权所有
//                                  Author:HaiBin
//      Email:qdseashore@163.com     DateTime:2005.06.22
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Buttons, DB, ADODB, Grids, DBGrids, DBCtrls;



type
  TfrmCarHistory = class(TForm)
    Panel1: TPanel;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    cbType: TComboBox;
    edtInfo: TEdit;
    Label2: TLabel;
    BitBtn1: TBitBtn;
    Panel2: TPanel;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    BitBtn5: TBitBtn;
    BitBtn6: TBitBtn;
    DBNavigator1: TDBNavigator;
    DBGrid1: TDBGrid;
    rbClassM: TRadioButton;
    rbClassJ: TRadioButton;
    dsCarHistory: TDataSource;
    qCarHistory: TADOQuery;
    adoConn: TADOConnection;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BitBtn1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure BitBtn5Click(Sender: TObject);
    procedure BitBtn6Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmCarHistory: TfrmCarHistory;

implementation

uses unitFun, unitJoin;

{$R *.dfm}

procedure TfrmCarHistory.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
try
 qCarHistory.Cancel;
 qCarHistory.Close;
 adoConn.Close;
  frmCarHistory:=nil;
  Action:=cafree;
except
end;
end;

procedure TfrmCarHistory.BitBtn1Click(Sender: TObject);
var
strSQL:String;
sInt:Double;
sCode:Integer;
begin
Try
if Trim(edtInfo.text)<>'' then  //文本有内容
begin
 val(Trim(edtInfo.Text),SInt,sCode);
  if rbClassM.Checked then      //选择是模糊
  begin
    if Trim(cbType.Text)='自动' then //选择的是自动
    begin
      if sCode=0 then   //输入的是数字
      begin
      strSQL:='Select * from uWeightTmp Where '+
     'ID like ' + floattostr(sInt) + ' or '+
     'ChePai like ' + quotedstr('%' + edtInfo.Text + '%') + ' or ' +
     'ChePaiN like ' + quotedstr('%' + edtInfo.Text + '%') + ' or ' +
     'ShouHuoDW like ' + quotedstr('%' + edtInfo.Text + '%') + ' or ' +
     'FaHuoDW like ' + quotedstr('%' + edtInfo.Text + '%') + ' or ' +
     'HuoPin like ' + quotedstr('%' + edtInfo.Text + '%') + ' or '+
     'MaoZhong like ' + floattostr(sInt) + ' or ' +
     'PiZhong like ' + floattostr(sInt) + ' or ' +
     'JingZhong like ' + floattostr(sInt) + ' or ' +
     'ShiJian like ' + floattostr(sInt) ;
      end
      else
      begin
      strSQL:='Select * from uWeightTmp Where '+
     'ChePai like ' + quotedstr('%' + edtInfo.Text + '%') + ' or ' +
     'ChePaiN like ' + quotedstr('%' + edtInfo.Text + '%') + ' or ' +
     'ShouHuoDW like ' + quotedstr('%' + edtInfo.Text + '%') + ' or ' +
     'FaHuoDW like ' + quotedstr('%' + edtInfo.Text + '%') + ' or ' +
     'HuoPin like ' + quotedstr('%' + edtInfo.Text + '%');
      end;
    end
    else
     if Trim(cbType.Text)='车号前缀' then
     begin
      strSQL:='Select * From uWeightTmp Where ChePai like ' + quotedstr('%'+ edtInfo.Text +'%');
     end
      else
       if Trim(cbType.Text)='车牌号' then
        begin
         strSQL:='Select * From uWeightTmp Where ChePaiN like ' + quotedstr('%'+ edtInfo.Text +'%');
        end
         else
           if (Trim(cbType.Text)='毛重') and (sCode=0) then
            begin
             strSQL:='Select * From uWeightTmp Where MaoZhong like ' + floattostr(sInt);
            end
              else
               if (Trim(cbType.Text)='皮重') and (sCode=0) then
                begin
                 strSQL:='Select * From uWeightTmp Where PiZhong like ' + floattostr(sInt);
                end
                 else
                   if (Trim(cbType.Text)='净重') and (sCode=0) then
                    begin
                     strSQL:='Select * From uWeightTmp Where JingZhong like ' + floattostr(sInt);
                    end
                      else
                       if Trim(cbType.Text)='发货单位' then
                        begin
                         strSQL:='Select * From uWeightTmp Where FaHuoDW like ' + quotedstr('%'+ edtInfo.Text +'%');
                        end
                          else
                           if Trim(cbType.Text)='收货单位' then
                            begin
                             strSQL:='Select * From uWeightTmp Where ShouHuoDW like ' + quotedstr('%'+ edtInfo.Text +'%');
                            end;
  end
  else
  if rbClassJ.Checked then      //选择是精确
  begin
   if Trim(cbType.Text)='自动' then //选择的是自动
    begin
      if sCode=0 then   //输入的是数字
      begin
      strSQL:='Select * from uWeightTmp Where '+
     'ID = ' + floattostr(sInt) + ' or '+
     'ChePai = ' + quotedstr( edtInfo.Text ) + ' or ' +
     'ChePaiN = ' + quotedstr( edtInfo.Text ) + ' or ' +
     'ShouHuoDW = ' + quotedstr(edtInfo.Text ) + ' or ' +
     'FaHuoDW = ' + quotedstr( edtInfo.Text ) + ' or ' +
     'HuoPin = ' + quotedstr( edtInfo.Text  ) + ' or '+
     'MaoZhong = ' + floattostr(sInt) + ' or ' +
     'PiZhong = ' + floattostr(sInt) + ' or ' +
     'JingZhong = ' + floattostr(sInt) + ' or ' +
     'ShiJian = ' + floattostr(sInt) ;
      end
      else
      begin
      strSQL:='Select * from uWeightTmp Where '+
     'ChePai = ' + quotedstr( edtInfo.Text  ) + ' or ' +
     'ChePaiN = ' + quotedstr(  edtInfo.Text  ) + ' or ' +
     'ShouHuoDW = ' + quotedstr( edtInfo.Text  ) + ' or ' +
     'FaHuoDW = ' + quotedstr( edtInfo.Text  ) + ' or ' +
     'HuoPin = ' + quotedstr(  edtInfo.Text );
      end;
    end
    else
     if Trim(cbType.Text)='车号前缀' then
     begin
      strSQL:='Select * From uWeightTmp Where ChePai = ' + quotedstr(edtInfo.Text );
     end
      else
       if Trim(cbType.Text)='车牌号' then
        begin
         strSQL:='Select * From uWeightTmp Where ChePaiN = ' + quotedstr(edtInfo.Text);
        end
         else
           if (Trim(cbType.Text)='毛重') and (sCode=0) then
            begin
             strSQL:='Select * From uWeightTmp Where MaoZhong = ' + floattostr(sInt);
            end
              else
               if (Trim(cbType.Text)='皮重') and (sCode=0) then
                begin
                 strSQL:='Select * From uWeightTmp Where PiZhong = ' + floattostr(sInt);
                end
                 else
                   if (Trim(cbType.Text)='净重') and (sCode=0) then
                    begin
                     strSQL:='Select * From uWeightTmp Where JingZhong = ' + floattostr(sInt);
                    end
                      else
                       if Trim(cbType.Text)='发货单位' then
                        begin
                         strSQL:='Select * From uWeightTmp Where FaHuoDW = ' + quotedstr( edtInfo.Text );
                        end
                          else
                           if Trim(cbType.Text)='收货单位' then
                            begin
                             strSQL:='Select * From uWeightTmp Where ShouHuoDW = ' + quotedstr(edtInfo.Text );
                            end;
  end;
end;
if strSQL='' then
begin
 strSQL:='Select * from uWeightTmp';
end;
qCarHistory.Close;
qCarHistory.SQL.Clear;
qCarHistory.SQL.Add(strSQL);
qCarHistory.open;
Except
//
end;
end;

procedure TfrmCarHistory.FormCreate(Sender: TObject);
var
strSQL:String;
Connstr:string;
begin
try
    if Not adoCOnn.Connected then
    begin
     Connstr:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ ExtractFilePath(Paramstr(0)) +'weight.mdb;Persist Security Info=False;Jet OLEDB:Database Password=qdseashore960501';
     adoConn.ConnectionString:=Connstr;
     adoCOnn.Open;
    end;
     strSQL:='Select * from uWeightTmp';
     qCarHistory.Close;
     qCarHistory.Connection:=adoConn;
     qCarHistory.SQL.Clear;
     qCarHistory.SQL.add(strSQL);
     qCarHistory.Open;
except
end;
end;

procedure TfrmCarHistory.BitBtn2Click(Sender: TObject);
begin
 try
  if qCarHistory.Active then
  begin
   qCarHistory.Insert;
  end;
 except
 end;
end;

procedure TfrmCarHistory.BitBtn3Click(Sender: TObject);
begin
try
 if qCarHistory.Active then
 begin
  if MessageBox(handle,'您确定要删除该记录吗?(无法恢复)',pChar(ClientUSN),MB_OKCancel+MB_ICONINFORMATION)=ID_OK then
  begin
   qCarHistory.Delete;
   qCarHistory.Refresh;
  end;
 end;
except
end;
end;

procedure TfrmCarHistory.BitBtn4Click(Sender: TObject);
begin
 try
  if qCarHistory.Active then
  begin
   qCarHistory.Edit;
  end;
 except
 end;
end;

procedure TfrmCarHistory.BitBtn5Click(Sender: TObject);
begin
 try
  if qCarHistory.Active then
  begin
   qCarHistory.Cancel;
   qCarHistory.Refresh;
  end;
 except
 end;
end;

procedure TfrmCarHistory.BitBtn6Click(Sender: TObject);
begin
 try
   if qCarHistory.Active then
   begin
    qCarHistory.Post;
    qCarHistory.Refresh;
   end;
 except
 end;
end;

procedure TfrmCarHistory.FormShow(Sender: TObject);
var
objFun:TFun;
bcanRead,bcanDelete,bcanModify:boolean;
begin
objFun:=TFun.Create;
if objFun.CheckUserLv(userID,Name,bcanRead,bcanDelete,bCanModify) then
begin
  if (bcanModify) and (bcanRead) and (bcanDelete)then
 begin
  BitBtn2.Enabled:= bcanModify;
  BitBtn3.Enabled:= bcanModify;
  BitBtn4.Enabled:= bcanModify;
  BitBtn5.Enabled:= bcanModify;
  BitBtn6.Enabled:= bcanModify;
  DBNavigator1.Enabled:=bcanModify;
  DBGrid1.ReadOnly:= Not bcanModify;
 end
 else
 if (bcanModify) and (bcanRead) then
 begin
  BitBtn2.Enabled:= bcanModify;
  BitBtn3.Enabled:=Not bcanModify;
  BitBtn4.Enabled:= bcanModify;
  BitBtn5.Enabled:= bcanModify;
  BitBtn6.Enabled:= bcanModify;
  DBNavigator1.Enabled:=bcanModify;
  DBGrid1.ReadOnly:= Not bcanModify;
 end
 else
 if bcanRead then
 begin
  BitBtn2.Enabled:=Not bcanModify;
  BitBtn3.Enabled:=Not bcanModify;
  BitBtn4.Enabled:=Not bcanModify;
  BitBtn5.Enabled:=Not bcanModify;
  BitBtn6.Enabled:=Not bcanModify;
  DBNavigator1.Enabled:=Not bcanModify;
  DBGrid1.ReadOnly:= bcanModify;
 end
 else
 begin
 MessageBox(handle,'对不起,你没有权限操作此功能!',pChar(ClientUSN),MB_OK+MB_ICONERROR);
 Close;
 end;
end
else
begin
MessageBox(handle,'对不起,你没有权限操作此功能!',pChar(ClientUSN),MB_OK+MB_ICONERROR);
Close;
end;
end;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -