www.pudn.com > dianlijiankong.rar > UHWSQXX.pas, change:2006-03-06,size:28113b


unit UHWSQXX; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, ExtCtrls, Buttons, ToolWin, ComCtrls, StdCtrls, Grids, DBGrids; 
 
type 
  TFRM_HWSQXX = class(TForm) 
    ToolBar1: TToolBar; 
    SpeedButton1: TSpeedButton; 
    SpeedButton2: TSpeedButton; 
    SpeedButton3: TSpeedButton; 
    SpeedButton4: TSpeedButton; 
    SpeedButton5: TSpeedButton; 
    SpeedButton6: TSpeedButton; 
    Panel1: TPanel; 
    Panel2: TPanel; 
    Label1: TLabel; 
    Label2: TLabel; 
    Label3: TLabel; 
    Label4: TLabel; 
    Label5: TLabel; 
    Label6: TLabel; 
    Label7: TLabel; 
    Label8: TLabel; 
    Label9: TLabel; 
    Label10: TLabel; 
    Label11: TLabel; 
    Label12: TLabel; 
    Label13: TLabel; 
    Label14: TLabel; 
    Label15: TLabel; 
    Label16: TLabel; 
    Label17: TLabel; 
    Label18: TLabel; 
    Label19: TLabel; 
    Label20: TLabel; 
    Label21: TLabel; 
    Label22: TLabel; 
    Label23: TLabel; 
    Label24: TLabel; 
    Edit1: TEdit; 
    ComboBox1: TComboBox; 
    Edit2: TEdit; 
    Edit3: TEdit; 
    Edit4: TEdit; 
    Edit5: TEdit; 
    DateTimePicker1: TDateTimePicker; 
    ComboBox2: TComboBox; 
    Edit6: TEdit; 
    Edit7: TEdit; 
    Edit8: TEdit; 
    DateTimePicker2: TDateTimePicker; 
    Edit9: TEdit; 
    Edit10: TEdit; 
    Edit11: TEdit; 
    Edit12: TEdit; 
    Edit13: TEdit; 
    Edit14: TEdit; 
    Edit15: TEdit; 
    Edit16: TEdit; 
    Edit17: TEdit; 
    Edit18: TEdit; 
    ComboBox3: TComboBox; 
    DBGrid1: TDBGrid; 
    Edit19: TEdit; 
    Label25: TLabel; 
    Edit20: TEdit; 
    Edit21: TEdit; 
    procedure SpeedButton6Click(Sender: TObject); 
    procedure FormCreate(Sender: TObject); 
    procedure FormShow(Sender: TObject); 
    procedure SpeedButton1Click(Sender: TObject); 
    procedure SpeedButton2Click(Sender: TObject); 
    procedure SpeedButton3Click(Sender: TObject); 
    procedure SpeedButton4Click(Sender: TObject); 
    procedure SpeedButton5Click(Sender: TObject); 
    procedure ComboBox1DropDown(Sender: TObject); 
    procedure ComboBox2DropDown(Sender: TObject); 
    procedure ComboBox3DropDown(Sender: TObject); 
    procedure ComboBox1Change(Sender: TObject); 
    procedure ComboBox2Change(Sender: TObject); 
    procedure Edit2KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit6KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit1KeyPress(Sender: TObject; var Key: Char); 
    procedure ComboBox1KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit3KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit4KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit5KeyPress(Sender: TObject; var Key: Char); 
    procedure DateTimePicker1KeyPress(Sender: TObject; var Key: Char); 
    procedure ComboBox2KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit7KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit8KeyPress(Sender: TObject; var Key: Char); 
    procedure DateTimePicker2KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit9KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit10KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit11KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit12KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit13KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit14KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit15KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit16KeyPress(Sender: TObject; var Key: Char); 
    procedure Edit17KeyPress(Sender: TObject; var Key: Char); 
    procedure ComboBox3KeyPress(Sender: TObject; var Key: Char); 
    procedure DBGrid1CellClick(Column: TColumn); 
    procedure Edit7Change(Sender: TObject); 
    procedure Edit8Change(Sender: TObject); 
    procedure Edit9Change(Sender: TObject); 
    procedure Edit10Change(Sender: TObject); 
    procedure Edit11Change(Sender: TObject); 
    procedure Edit12Change(Sender: TObject); 
    procedure Edit13Change(Sender: TObject); 
    procedure Edit14Change(Sender: TObject); 
    procedure Edit15Change(Sender: TObject); 
    procedure Edit16Change(Sender: TObject); 
    procedure Edit17Change(Sender: TObject); 
    procedure Edit19Change(Sender: TObject); 
    procedure Edit16Exit(Sender: TObject); 
    procedure Edit17Exit(Sender: TObject); 
    procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; 
      DataCol: Integer; Column: TColumn; State: TGridDrawState); 
  private 
    { Private declarations } 
  public 
    procedure tr;       //去除空字符 
    procedure bh;        //自动编号 
    procedure bh1; 
    procedure bh2; 
    procedure bh3; 
    Procedure GetAll;    //获得所有数据 
    Procedure Posting;   //提交数据 
    Procedure CLS;       //清除控件中内容 
    Procedure DIS;       //控件不可用 
    Procedure ENA;       //控件可用 
    Function CanSave:Boolean;   //判断是否保存 
    { Public declarations } 
  end; 
 
var 
  FRM_HWSQXX: TFRM_HWSQXX; 
 
implementation 
 
uses UMAIN, UDM; 
 
{$R *.dfm} 
procedure TFRM_HWSQXX.tr; 
var 
i:integer; 
begin 
  for i:=ComponentCount - 1 downto 0 do 
    if(Components[i] is TEdit) then 
    TEdit(Components[i]).Text:=trim(TEdit(Components[i]).Text); 
end; 
Function TFRM_HWSQXX.CanSave: Boolean; 
begin 
  if (Edit1.Text='') then 
  begin 
   Result:=False; 
   Application.MessageBox('申请编号不能为空!','提示信息',0+MB_ICONINFORMATION); 
   exit; 
  end; 
  if (ComboBox1.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('客户编号不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit2.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('客户名称不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit3.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('订单编号不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit20.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('客户电话不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit4.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('合同编号不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit5.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('发票号码不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (ComboBox2.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('车辆编号不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit6.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('车牌号码不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit7.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('出发地点不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit8.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('目的地点不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit9.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('主件名称不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit10.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('主件数量不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit11.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('体积不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit12.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('附件数量不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit13.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('附件名称不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit14.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('吨位不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit15.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('距离不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit16.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('运费不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit17.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('分送数量不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (Edit18.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('合计金额不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
  if (ComboBox3.Text='') then 
  begin 
    Result:=False; 
    Application.MessageBox('所属部门不能为空!','提示信息',0+MB_ICONINFORMATION); 
    exit; 
  end; 
end; 
 
procedure TFRM_HWSQXX.bh; 
var 
i:integer; 
s,m:string; 
begin 
  s:= 'SQ'+ FormatDateTime('yyyymmdd',Now()); 
  With DM.QHWSQXX do 
  begin 
    Close; 
    SQL.Clear; 
    SQL.Add('select max(申请编号) as ss From 货物申请信息表'); 
    Open; 
  end; 
  If DM.QHWSQXX.FieldByName('ss').Value=null then 
    s := s + '001' 
  else 
  begin 
    m:= Trim(DM.QHWSQXX.FieldByName('ss').Value) ; 
    i:= StrToInt(Trim(Copy(m,11,8))) ; 
    s:= s +Formatfloat('000',i+1); 
  end; 
  Edit1.Text := s; 
end;           ///////////////////////////// 
procedure TFRM_HWSQXX.bh1; 
var 
i:integer; 
s,m:string; 
begin 
  s:= 'DD'+ FormatDateTime('yyyymmdd',Now()); 
  With DM.QHWSQXX do 
  begin 
    Close; 
    SQL.Clear; 
    SQL.Add('select max(订单编号) as ss From 货物申请信息表'); 
    Open; 
  end; 
  If DM.QHWSQXX.FieldByName('ss').Value=null then 
    s := s + '001' 
  else 
  begin 
    m:= Trim(DM.QHWSQXX.FieldByName('ss').Value) ; 
    i:= StrToInt(Trim(Copy(m,11,8))) ; 
    if i<9 then 
      s:= s + '00'+ InttoStr(i +1) 
    else if i<99 then 
      s:= s + '0'+ InttoStr(i +1) 
    else 
      s:= s +InttoStr(i +1); 
  end; 
  Edit3.Text := s; 
end;         ////////////////////////////////////////////// 
procedure TFRM_HWSQXX.bh2; 
var 
i:integer; 
s,m:string; 
begin 
  s:= 'HT'+ FormatDateTime('yyyymmdd',Now()); 
  With DM.QHWSQXX do 
  begin 
    Close; 
    SQL.Clear; 
    SQL.Add('select max(合同编号) as ss From 货物申请信息表'); 
    Open; 
  end; 
  If DM.QHWSQXX.FieldByName('ss').Value=null then 
    s := s + '001' 
  else 
  begin 
    m:= Trim(DM.QHWSQXX.FieldByName('ss').Value) ; 
    i:= StrToInt(Trim(Copy(m,11,8))) ; 
    if i<9 then 
      s:= s + '00'+ InttoStr(i +1) 
    else if i<99 then 
      s:= s + '0'+ InttoStr(i +1) 
    else 
      s:= s +InttoStr(i +1); 
  end; 
  Edit4.Text := s; 
end;///////////////////////// 
procedure TFRM_HWSQXX.bh3; 
var 
i:integer; 
s,m:string; 
begin 
  s:= 'FP'+ FormatDateTime('yyyymmdd',Now()); 
  With DM.QHWSQXX do 
  begin 
    Close; 
    SQL.Clear; 
    SQL.Add('select max(发票号码) as ss From 货物申请信息表'); 
    Open; 
  end; 
  If DM.QHWSQXX.FieldByName('ss').Value=null then 
    s := s + '001' 
  else 
  begin 
    m:= Trim(DM.QHWSQXX.FieldByName('ss').Value) ; 
    i:= StrToInt(Trim(Copy(m,11,8))) ; 
    if i<9 then 
      s:= s + '00'+ InttoStr(i +1) 
    else if i<99 then 
      s:= s + '0'+ InttoStr(i +1) 
    else 
      s:= s +InttoStr(i +1); 
  end; 
  Edit5.Text := s; 
end;///////////////////////// 
procedure TFRM_HWSQXX.GetAll; 
begin 
  Edit1.Text:=DM.DSOHWSQXX.FieldByName('申请编号').AsString; 
  ComboBox1.Text:=DM.DSOHWSQXX.FieldByName('客户编号').AsString; 
  Edit2.Text:=DM.DSOHWSQXX.FieldByName('客户名称').AsString; 
  Edit3.Text:=DM.DSOHWSQXX.FieldByName('订单编号').AsString; 
  Edit4.Text:=DM.DSOHWSQXX.FieldByName('合同编号').AsString; 
  Edit5.Text:=DM.DSOHWSQXX.FieldByName('发票号码').AsString; 
  DateTimePicker1.Date:=DM.DSOHWSQXX.FieldByName('开票日期').AsDateTime; 
  ComboBox2.Text:=DM.DSOHWSQXX.FieldByName('车辆编号').AsString; 
  Edit6.Text:=DM.DSOHWSQXX.FieldByName('车牌号码').AsString; 
  Edit7.Text:=DM.DSOHWSQXX.FieldByName('出发地点').AsString; 
  Edit8.Text:=DM.DSOHWSQXX.FieldByName('目的地点').AsString; 
  DateTimePicker2.Date:=DM.DSOHWSQXX.FieldByName('出货日期').AsDateTime; 
  Edit9.Text:=DM.DSOHWSQXX.FieldByName('主件名称').AsString; 
  Edit10.Text:=DM.DSOHWSQXX.FieldByName('主件数量').AsString; 
  Edit11.Text:=DM.DSOHWSQXX.FieldByName('体积').AsString; 
  Edit12.Text:=DM.DSOHWSQXX.FieldByName('附件数量').AsString; 
  Edit13.Text:=DM.DSOHWSQXX.FieldByName('附件名称').AsString; 
  Edit14.Text:=DM.DSOHWSQXX.FieldByName('吨位').AsString; 
  Edit15.Text:=DM.DSOHWSQXX.FieldByName('距离').AsString; 
  Edit16.Text:=DM.DSOHWSQXX.FieldByName('运费').AsString; 
  Edit17.Text:=DM.DSOHWSQXX.FieldByName('分送费用').AsString; 
  Edit18.Text:=DM.DSOHWSQXX.FieldByName('合计金额').AsString; 
  ComboBox3.Text:=DM.DSOHWSQXX.FieldByName('所属部门').AsString; 
  Edit19.Text:=DM.DSOHWSQXX.FieldByName('备注').AsString; 
  Edit20.Text:=DM.DSOHWSQXX.FieldByName('客户电话').AsString; 
  Edit21.Text:=DM.DSOHWSQXX.FieldByName('联系人').AsString; 
end; 
procedure TFRM_HWSQXX.Posting; 
begin 
  if ActionCD='N' then 
  BEGIN 
    with DM.QHWSQXX do 
    begin 
      Close; 
      SQL.Clear; 
      SQL.Add('INSERT INTO 货物申请信息表(申请编号,客户编号,客户名称,订单编号,合同编号,发票号码,'); 
      SQL.Add('开票日期,车辆编号,车牌号码,出发地点,目的地点,出货日期,主件名称,主件数量,体积,附件数量,'); 
      SQL.Add('附件名称,吨位,距离,运费,分送费用,合计金额,所属部门,备注,客户电话,联系人)'); 
      SQL.Add('Values(:申请编号,:客户编号,:客户名称,:订单编号,:合同编号,:发票号码,'); 
      SQL.Add(':开票日期,:车辆编号,:车牌号码,:出发地点,:目的地点,:出货日期,:主件名称,:主件数量,:体积,:附件数量,'); 
      SQL.Add(':附件名称,:吨位,:距离,:运费,:分送费用,:合计金额,:所属部门,:备注,:客户电话,:联系人)'); 
      Parameters.Items[0].Value:=Edit1.Text; 
      Parameters.Items[1].Value:=ComboBox1.Text; 
      Parameters.Items[2].Value:=Edit2.Text; 
      Parameters.Items[3].Value:=Edit3.Text; 
      Parameters.Items[4].Value:=Edit4.Text; 
      Parameters.Items[5].Value:=Edit5.Text; 
      DateTimePicker1.Date:=Date(); 
      Parameters.Items[6].Value:=FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date); 
      Parameters.Items[7].Value:=ComboBOx2.Text; 
      Parameters.Items[8].Value:=Edit6.Text; 
      Parameters.Items[9].Value:=Edit7.Text; 
      Parameters.Items[10].Value:=Edit8.Text; 
      DateTimePicker2.Date:=Date(); 
      Parameters.Items[11].Value:=FormatDateTime('yyyy-mm-dd',DateTimePicker2.Date); 
      Parameters.Items[12].Value:=Edit9.Text; 
      Parameters.Items[13].Value:=Edit10.Text; 
      Parameters.Items[14].Value:=Edit11.Text; 
      Parameters.Items[15].Value:=Edit12.Text; 
      Parameters.Items[16].Value:=Edit13.Text; 
      Parameters.Items[17].Value:=Edit14.Text; 
      Parameters.Items[18].Value:=Edit15.Text; 
      Parameters.Items[19].Value:=Edit16.Text; 
      Parameters.Items[20].Value:=Edit17.Text; 
      Parameters.Items[21].Value:=Edit18.Text; 
      Parameters.Items[22].Value:=ComboBox3.Text; 
      Parameters.Items[23].Value:=Edit19.Text; 
      Parameters.Items[24].Value:=Edit20.Text; 
      Parameters.Items[25].Value:=Edit21.Text; 
      Prepared:=True; 
      ExecSQL; 
    end; 
  END else 
  if ActionCD='M' then 
  begin 
    With DM.QHWSQXX DO 
    begin 
      Close; 
      SQL.Clear; 
      SQL.Add('update   货物申请信息表 Set 客户编号=:客户编号1,客户名称=:客户名称1,'); 
      SQL.Add('订单编号=:订单编号1,合同编号=:合同编号1,发票号码=:发票号码1,开票日期=:开票日期1,'); 
      SQL.Add('车辆编号=:车辆编号1,车牌号码=:车牌号码1,出发地点=:出发地点1,目的地点=:目的地点1,'); 
      SQL.Add('出货日期=:出货日期1,主件名称=:主件名称1,主件数量=:主件数量1,体积=:体积1,'); 
      SQL.Add('附件数量=:附件数量1,附件名称=:附件名称1,吨位=:吨位1,距离=:距离1,'); 
      SQL.Add('运费=:运费1,分送费用=:分送费用1,合计金额=:合计金额1,所属部门=:所属部门1,'); 
      SQL.Add('备注=:备注1,客户电话=:客户电话1,联系人=:联系人1 where 申请编号=:申请编号1'); 
      Parameters.Items[0].Value:=ComboBox1.Text; 
      Parameters.Items[1].Value:=Edit2.Text; 
      Parameters.Items[2].Value:=Edit3.Text; 
      Parameters.Items[3].Value:=Edit4.Text; 
      Parameters.Items[4].Value:=Edit5.Text; 
      DateTimePicker1.Date:=Date(); 
      Parameters.Items[5].Value:=FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date); 
      Parameters.Items[6].Value:=ComboBox2.Text; 
      Parameters.Items[7].Value:=Edit6.Text; 
      Parameters.Items[8].Value:=Edit7.Text; 
      Parameters.Items[9].Value:=Edit8.Text; 
      DateTimePicker2.Date:=Date(); 
      Parameters.Items[10].Value:=FormatDateTime('yyyy-mm-dd',DateTimePicker2.Date); 
      Parameters.Items[11].Value:=Edit9.Text; 
      Parameters.Items[12].Value:=Edit10.Text; 
      Parameters.Items[13].Value:=Edit11.Text; 
      Parameters.Items[14].Value:=Edit12.Text; 
      Parameters.Items[15].Value:=Edit13.Text; 
      Parameters.Items[16].Value:=Edit14.Text; 
      Parameters.Items[17].Value:=Edit15.Text; 
      Parameters.Items[18].Value:=Edit16.Text; 
      Parameters.Items[19].Value:=Edit17.Text; 
      Parameters.Items[20].Value:=Edit18.Text; 
      Parameters.Items[21].Value:=ComboBox3.Text; 
      Parameters.Items[22].Value:=Edit19.Text; 
      Parameters.Items[23].Value:=Edit20.Text; 
      Parameters.Items[24].Value:=Edit21.Text; 
      Parameters.Items[25].Value:=DM.DSOHWSQXX.FieldByName('申请编号').AsString; 
      Prepared:=true; 
      ExecSQL; 
    end; 
  end; 
end; 
procedure TFRM_HWSQXX.ENA; 
var 
  i:integer; 
begin 
  for i:=ComponentCount-1 downto 0 do 
  begin 
    if (Components[i] is TEdit) then 
    begin 
      TEdit(Components[i]).Color:=clWindow; 
      TEdit(Components[i]).ReadOnly:=False; 
    end; 
  end; 
  ComboBox1.Color:=clWindow; 
  ComboBox2.Color:=clWindow; 
  ComboBox3.Color:=clWindow; 
  DateTimePicker1.Color:=clWindow; 
  DateTimePicker2.Color:=clWindow; 
  SpeedButton1.Enabled:=False; 
  SpeedButton2.Enabled:=False; 
  SpeedButton3.Enabled:=True; 
  SpeedButton4.Enabled:=False; 
  Panel1.Enabled:=True; 
end; 
procedure TFRM_HWSQXX.DIS; 
var 
  i:integer; 
begin 
  for i:=ComponentCount-1 downto 0 do 
  begin 
    if (Components[i] is Tedit) then 
    begin 
      TEdit(Components[i]).Color:=$00EFEFEF; 
      TEdit(Components[i]).ReadOnly:=true; 
    end; 
  end; 
  ComboBox1.Color:=$00EFEFEF; 
  ComboBox2.Color:=$00EFEFEF; 
  ComboBox3.Color:=$00EFEFEF; 
  DateTimePicker1.Color:=$00EFEFEF; 
  DateTimePicker2.Color:=$00EFEFEF; 
  SpeedButton1.Enabled:=True; 
  SpeedButton2.Enabled:=True; 
  SpeedButton3.Enabled:=False; 
  SpeedButton4.Enabled:=False; 
  Panel1.Enabled:=False; 
end; 
procedure TFRM_HWSQXX.CLS; 
var 
  i:integer; 
begin 
  for i:=ComponentCount-1 downto 0 do 
  begin 
    if(Components[i] is TEdit) then 
      TEdit(Components[i]).Clear; 
  end; 
  ComboBox1.Clear; 
  ComboBox2.Clear; 
  ComboBox3.Clear; 
  DateTimePicker1.Date:=now; 
  DateTimePicker2.Date:=now; 
end; 
////////////////////////////////////////////////////// 
procedure TFRM_HWSQXX.SpeedButton6Click(Sender: TObject); 
begin 
  ACtionCD:=''; 
  Close; 
end; 
 
procedure TFRM_HWSQXX.FormCreate(Sender: TObject); 
begin 
  with DM.QHWSQXX do 
  begin 
    Close; 
    SQL.Clear; 
    SQL.Add('Select * from 货物申请信息表'); 
    Open; 
  end; 
  DM.DSOHWSQXX.Open; 
end; 
 
procedure TFRM_HWSQXX.FormShow(Sender: TObject); 
begin 
  DIS; 
  if ActionCD = 'M' then 
    GetAll 
  else if ActionCD = 'N' then 
  begin 
    CLS; 
    ENA; 
  end; 
end; 
 
procedure TFRM_HWSQXX.SpeedButton1Click(Sender: TObject); 
begin 
  CLS; 
  ENA; 
  ActionCD := 'N'; 
  bh; 
  bh1; 
  bh2; 
  bh3; 
  Edit16.Text:='0'; 
  Edit17.Text:='0'; 
  Edit18.Text:='0'; 
  ComboBox1.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.SpeedButton2Click(Sender: TObject); 
begin 
  ENA; 
  SpeedButton4.Enabled:=True; 
  ACtionCD := 'M'; 
end; 
 
procedure TFRM_HWSQXX.SpeedButton3Click(Sender: TObject); 
begin 
  if (cansave) then 
  begin 
//    Edit18.Text:=FloatToStr(StrToFloat(Edit16.Text)+StrToFloat(Edit17.Text)); 
    Posting; 
    DIS; 
    DM.DSOHWSQXX.Close; 
    DM.DSOHWSQXX.Open; 
    Application.MessageBox('保存成功!','提示!',64); 
    actioncd:=''; 
    self.Close; 
  end; 
end; 
 
procedure TFRM_HWSQXX.SpeedButton4Click(Sender: TObject); 
begin 
  if DM.DSOHWSQXX.RecordCount=0 then 
  begin 
    Application.MessageBox('没有记录可以删除!','提示',0+MB_ICONINFORMATION); 
    Exit; 
  end; 
  if DM.DSOHWSQXX.IsEmpty then 
    Exit; 
  if ID_YES=application.MessageBox('确实要删除这条记录吗?','提示',MB_YESNO) then 
  begin 
    DM.DSOHWSQXX.Delete; 
    self.OnShow(Sender); 
  end; 
end; 
 
procedure TFRM_HWSQXX.SpeedButton5Click(Sender: TObject); 
begin 
  DIS; 
  SpeedButton4.Enabled:=False; 
  FRM_HWSQXX.GetAll; 
  ActionCD:=''; 
end; 
 
procedure TFRM_HWSQXX.ComboBox1DropDown(Sender: TObject); 
var 
i:integer; 
begin 
  ComboBox1.Clear; 
  With DM.QKHJBXX do 
  begin 
    CLose; 
    SQL.Clear; 
    SQL.Add('Select 客户编号 from 客户信息表'); 
    Open; 
    if (Recordcount>0) then 
      First; 
    for i:=0 to Recordcount-1 do 
    begin 
      ComboBox1.Items.Add(FieldByName('客户编号').AsString); 
      Next; 
    end; 
  end; 
end; 
 
procedure TFRM_HWSQXX.ComboBox2DropDown(Sender: TObject); 
var 
i:integer; 
begin 
  ComboBox2.Clear; 
  With DM.QCLJBXX do 
  begin 
    CLose; 
    SQL.Clear; 
    SQL.Add('Select 车辆编号 from 车辆信息表'); 
    Open; 
    if (Recordcount>0) then 
      First; 
    for i:=0 to Recordcount-1 do 
    begin 
      ComboBox2.Items.Add(FieldByName('车辆编号').AsString); 
      Next; 
    end; 
  end; 
end; 
 
procedure TFRM_HWSQXX.ComboBox3DropDown(Sender: TObject); 
var 
i:integer; 
begin 
  ComboBox3.Clear; 
  With DM.QBMJBXX do 
  begin 
    CLose; 
    SQL.Clear; 
    SQL.Add('Select 部门名称 from 部门信息表'); 
    Open; 
    if (Recordcount>0) then 
      First; 
    for i:=0 to Recordcount-1 do 
    begin 
      ComboBox3.Items.Add(FieldByName('部门名称').AsString); 
      Next; 
    end; 
  end; 
end; 
 
procedure TFRM_HWSQXX.ComboBox1Change(Sender: TObject); 
begin 
  Edit2.Clear; 
  with DM.QKHJBXX do 
  begin 
    Close; 
    SQL.Clear; 
    SQL.Add('Select 客户名称 from 客户信息表 where 客户编号='+''''+ComboBox1.Text+''''); 
    Open; 
  end; 
  if ComboBox1.Text<>'' then 
  begin 
    Edit2.Text:=DM.QKHJBXX.FieldByName('客户名称').Value; 
  end; 
  Edit20.Clear; 
  with DM.QKHJBXX do 
  begin 
    Close; 
    SQL.Clear; 
    SQL.Add('Select 联系电话 from 客户信息表 where 客户编号='+''''+ComboBox1.Text+''''); 
    Open; 
  end; 
  if ComboBox1.Text<>'' then 
  begin 
    Edit20.Text:=DM.QKHJBXX.FieldByName('联系电话').Value; 
  end; 
  Edit21.Clear; 
  with DM.QKHJBXX do 
  begin 
    Close; 
    SQL.Clear; 
    SQL.Add('Select 联系人 from 客户信息表 where 客户编号='+''''+ComboBox1.Text+''''); 
    Open; 
  end; 
  if ComboBox1.Text<>'' then 
  begin 
    Edit21.Text:=DM.QKHJBXX.FieldByName('联系人').Value; 
  end; 
  DateTimePicker1.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.ComboBox2Change(Sender: TObject); 
begin 
  Edit6.Clear; 
  with DM.QCLJBXX do 
  begin 
    Close; 
    SQL.Clear; 
    SQL.Add('Select 车牌号码 from 车辆信息表 where 车辆编号='+''''+ComboBox2.Text+''''); 
    Open; 
  end; 
  if ComboBox2.Text<>'' then 
  begin 
    Edit6.Text:=DM.QCLJBXX.FieldByName('车牌号码').Value; 
    Edit7.SetFocus; 
  end; 
end; 
 
procedure TFRM_HWSQXX.Edit2KeyPress(Sender: TObject; var Key: Char); 
begin 
  key:=#0; 
end; 
 
procedure TFRM_HWSQXX.Edit6KeyPress(Sender: TObject; var Key: Char); 
begin 
  key:=#0; 
end; 
 
procedure TFRM_HWSQXX.Edit1KeyPress(Sender: TObject; var Key: Char); 
begin 
  key:=#0; 
end; 
 
procedure TFRM_HWSQXX.ComboBox1KeyPress(Sender: TObject; var Key: Char); 
begin 
  if not (key in[#13,#8]) then 
    key:=#0; 
end; 
 
procedure TFRM_HWSQXX.Edit3KeyPress(Sender: TObject; var Key: Char); 
begin 
  key:=#0; 
end; 
 
procedure TFRM_HWSQXX.Edit4KeyPress(Sender: TObject; var Key: Char); 
begin 
  key:=#0; 
end; 
 
procedure TFRM_HWSQXX.Edit5KeyPress(Sender: TObject; var Key: Char); 
begin 
  key:=#0; 
end; 
 
procedure TFRM_HWSQXX.DateTimePicker1KeyPress(Sender: TObject; 
  var Key: Char); 
begin 
  if key=#13 then 
    ComboBox2.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.ComboBox2KeyPress(Sender: TObject; var Key: Char); 
begin 
  if not (key in[#13,#8]) then 
    key:=#0; 
end; 
 
procedure TFRM_HWSQXX.Edit7KeyPress(Sender: TObject; var Key: Char); 
begin 
  if key in['a'..'z','A'..'Z','0'..'9'] then 
    key:=#0; 
  if key=#13 then 
    Edit8.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.Edit8KeyPress(Sender: TObject; var Key: Char); 
begin 
  if key in['a'..'z','A'..'Z','0'..'9'] then 
    key:=#0; 
  if key=#13 then 
    DateTimePicker2.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.DateTimePicker2KeyPress(Sender: TObject; 
  var Key: Char); 
begin 
  if key=#13 then 
    Edit9.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.Edit9KeyPress(Sender: TObject; var Key: Char); 
begin 
  if key in['a'..'z'] then 
    key:=#0; 
  if key=#13 then 
    Edit10.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.Edit10KeyPress(Sender: TObject; var Key: Char); 
begin 
  if not (key in['0'..'9',#13,#8,'.']) then 
    key:=#0; 
  if key=#13 then 
    Edit11.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.Edit11KeyPress(Sender: TObject; var Key: Char); 
begin 
  if not (key in['0'..'9',#13,#8,'.']) then 
    key:=#0; 
  if key=#13 then 
    Edit12.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.Edit12KeyPress(Sender: TObject; var Key: Char); 
begin 
  if not (key in['0'..'9',#13,#8,'.']) then 
    key:=#0; 
  if key=#13 then 
    Edit13.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.Edit13KeyPress(Sender: TObject; var Key: Char); 
begin 
  if key in['a'..'z'] then 
    key:=#0; 
  if key=#13 then 
    Edit14.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.Edit14KeyPress(Sender: TObject; var Key: Char); 
begin 
  if not (key in['0'..'9',#13,#8,'.']) then 
    key:=#0; 
  if key=#13 then 
    Edit15.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.Edit15KeyPress(Sender: TObject; var Key: Char); 
begin 
  if not (key in['0'..'9',#13,#8,'.']) then 
    key:=#0; 
  if key=#13 then 
    Edit16.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.Edit16KeyPress(Sender: TObject; var Key: Char); 
begin 
  if not (key in['0'..'9',#13,#8,'.']) then 
    key:=#0; 
  if key=#13 then 
    Edit17.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.Edit17KeyPress(Sender: TObject; var Key: Char); 
begin 
  if not (key in['0'..'9',#13,#8,'.']) then 
    key:=#0; 
  if key=#13 then 
    ComboBox3.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.ComboBox3KeyPress(Sender: TObject; var Key: Char); 
begin 
  if not (key in[#8,#13]) then 
    key:=#0; 
  if key=#13 then 
    Edit19.SetFocus; 
end; 
 
procedure TFRM_HWSQXX.DBGrid1CellClick(Column: TColumn); 
begin 
  GetAll; 
end; 
 
procedure TFRM_HWSQXX.Edit7Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit8Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit9Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit10Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit11Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit12Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit13Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit14Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit15Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit16Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit17Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit19Change(Sender: TObject); 
begin 
tr 
end; 
 
procedure TFRM_HWSQXX.Edit16Exit(Sender: TObject); 
begin 
  Edit18.Text:=FloatToStr(StrToFloat(Edit16.Text)+StrToFloat(Edit17.Text)); 
end; 
 
procedure TFRM_HWSQXX.Edit17Exit(Sender: TObject); 
begin 
  Edit18.Text:=FloatToStr(StrToFloat(Edit16.Text)+StrToFloat(Edit17.Text)); 
end; 
 
procedure TFRM_HWSQXX.DBGrid1DrawColumnCell(Sender: TObject; 
  const Rect: TRect; DataCol: Integer; Column: TColumn; 
  State: TGridDrawState); 
begin 
  FRM_MAIN.SetDBGird(Sender as TDBGrid,DM.QHWSQXX ,Rect,DataCol,Column,State); 
end; 
 
end.