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

📄 ubunit.~pas

📁 是分布式粮库程序,是采用Delphi实现的
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
      Application.MessageBox('删除货位信息出错!','系统错误',MB_OK+MB_ICONERROR);
      Exit;
      end;
      dtmdl.Database1.Commit;
      qryfdposition.Close;
      qryfdposition.Open;
   end;
end;

procedure Tfbaseunit.fdpmodBitBtnClick(Sender: TObject);
begin
  fdpnewormod:='modify';

  edit8.Enabled :=true;
  edit9.Enabled :=true;
  memo3.Enabled :=true;

  fdpdelbitbtn.Enabled :=false;
  fdpaddbitbtn.Enabled :=false;
end;

procedure Tfbaseunit.fdpsavBitBtnClick(Sender: TObject);
begin
    if dblookupcombobox4.Text ='' then
     begin
     showmessage('必须输入库点编号!');
     dblookupcombobox4.SetFocus ;
     exit;
     end;
    if dblookupcombobox6.Text ='' then
     begin
     showmessage('必须输入仓库编号!');
     dblookupcombobox6.SetFocus ;
     exit;
     end;

    if edit7.Text ='' then
     begin
     showmessage('必须输入货位编号!');
     edit7.SetFocus ;
     exit;
     end;

    if edit8.Text ='' then
     begin
     showmessage('必须输入货位名称!');
     edit8.SetFocus ;
     exit;
     end;

  if fdpnewormod='insert' then
  begin
     query3.ParamByName('unit_id').AsInteger :=unitid;
     query3.ParamByName('site_id').AsInteger :=dblookupcombobox4.KeyValue;
     query3.ParamByName('depot_id').AsInteger :=dblookupcombobox6.KeyValue;
     query3.ParamByName('foodposition_id').AsInteger :=strtoint(edit7.Text);
     query3.Close;
     query3.Open;
     if not query3.IsEmpty then
      begin
       showmessage('已经有重复的货位编号,输入错误!') ;
       edit7.Text :='';
       edit7.SetFocus ;
       exit;
      end;
     query6.ParamByName('unit_id').AsInteger :=unitid;
     query6.ParamByName('site_id').AsInteger :=dblookupcombobox4.KeyValue;
     query6.ParamByName('depot_id').AsInteger :=dblookupcombobox6.KeyValue;
     query6.ParamByName('foodposition_name').AsString :=edit8.Text ;
     query6.Close;
     query6.Open;
     if not query6.IsEmpty then
      begin
       showmessage('已经有重复的货位名称,输入错误!');
       edit8.Text:='';
       edit8.SetFocus ;
       exit;
      end;
     fdpnewquery.ParamByName('unit_id').AsInteger :=unitid;   //strtoint(statictext4.Caption);
     fdpnewquery.ParamByName('site_id').AsInteger :=strtoint(dblookupcombobox4.Text) ;
     fdpnewquery.ParamByName('depot_id').AsInteger :=strtoint(dblookupcombobox6.Text) ;
     fdpnewquery.ParamByName('foodposition_id').AsInteger :=strtoint(edit7.Text);
     fdpnewquery.ParamByName('foodposition_name').asstring :=edit8.Text;
     fdpnewquery.ParamByName('capacity').AsFloat :=strtofloat(edit9.Text);
     fdpnewquery.ParamByName('memo').asstring :=memo3.Text;
   try
//   showmessage(fdpnewquery.SQL.Text);
   fdpnewquery.ExecSQL ;
   except
   showmessage('添加货位时出错!');
   exit;
   end;
 end;

  if fdpnewormod='modify' then
  begin
   fdpmodquery.ParamByName('unit_id').AsInteger :=unitid;    //strtoint(statictext4.Caption);
   fdpmodquery.ParamByName('site_id').AsInteger :=strtoint(dblookupcombobox4.Text);
   fdpmodquery.ParamByName('depot_id').AsInteger :=strtoint(dblookupcombobox6.Text) ;
   fdpmodquery.ParamByName('foodposition_id').AsInteger :=strtoint(edit7.Text);
   fdpmodquery.ParamByName('foodposition_name').asstring :=edit8.Text;
   fdpmodquery.ParamByName('capacity').AsFloat :=strtofloat(edit9.Text);
   fdpmodquery.ParamByName('memo').asstring :=memo3.Text;

    try
    fdpmodquery.ExecSQL ;
    except
    showmessage('修改货位信息时出错!');
    exit;
    end;
  end;
   qryfdposition.Close;
   qryfdposition.Open;
   dblookupcombobox4.Enabled :=false;
   dblookupcombobox5.Enabled :=false;
   dblookupcombobox6.Enabled :=false;
   dblookupcombobox7.Enabled :=false;
   edit7.Enabled :=false;
   edit8.Enabled :=false;
   edit9.Enabled :=false;
   memo3.Enabled :=false;

   fdpaddbitbtn.Enabled :=true;
   fdpdelbitbtn.Enabled :=true;
   fdpmodbitbtn.Enabled :=true;
end;

procedure Tfbaseunit.fdpcanBitBtnClick(Sender: TObject);
begin
   fdpaddbitbtn.Enabled :=true;
   fdpdelbitbtn.Enabled :=true;
   fdpmodbitbtn.Enabled :=true;

   dblookupcombobox4.Enabled :=false;
   dblookupcombobox5.Enabled :=false;
   dblookupcombobox6.Enabled :=false;
   dblookupcombobox7.Enabled :=false;
   edit7.Enabled :=false;
   edit8.Enabled :=false;
   edit9.Enabled :=false;
   memo3.Enabled :=false;
end;

procedure Tfbaseunit.fdpexiBitBtnClick(Sender: TObject);
begin
  close;
end;

procedure Tfbaseunit.qryfdpositionAfterScroll(DataSet: TDataSet);
begin
    fsiteid:=dataset.fieldbyname('site_id').AsInteger ;
    fdepotid:=dataset.fieldbyname('depot_id').AsInteger ;
    fdpositionid:=dataset.fieldbyname('foodposition_id').AsInteger ;
    dblookupcombobox4.KeyValue:=dataset.fieldbyname('site_id').AsInteger;
    dblookupcombobox5.KeyValue:=dataset.fieldbyname('site_id').AsInteger;
    dblookupcombobox6.KeyValue:=dataset.fieldbyname('depot_id').AsInteger;
    dblookupcombobox7.KeyValue:=dataset.fieldbyname('depot_id').AsInteger;
    edit7.Text :=inttostr(dataset.fieldbyname('foodposition_id').AsInteger);
    edit8.Text :=dataset.fieldbyname('name').AsString ;
    edit9.Text :=floattostr(dataset.fieldbyname('capacity').AsFloat);
    memo3.Text :=dataset.fieldbyname('memo').AsString ;
end;

procedure Tfbaseunit.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
      if (Key<>'0') and (Key<>'1') and (Key<>'2') and (Key<>'3') and (Key<>'4')and
        (Key<>'5') and (Key<>'6') and (Key<>'7') and (Key<>'8') and (Key<>'9')  and
        (ord(Key)<>8) then
       Key:=chr(0);
end;


procedure Tfbaseunit.Edit4KeyPress(Sender: TObject; var Key: Char);
begin
     if (Key<>'0') and (Key<>'1') and (Key<>'2') and (Key<>'3') and (Key<>'4')and
        (Key<>'5') and (Key<>'6') and (Key<>'7') and (Key<>'8') and (Key<>'9')  and
        (ord(Key)<>8) then
       Key:=chr(0);
end;

procedure Tfbaseunit.Edit6KeyPress(Sender: TObject; var Key: Char);
begin
     if (Key<>'0') and (Key<>'1') and (Key<>'2') and (Key<>'3') and (Key<>'4')and
        (Key<>'5') and (Key<>'6') and (Key<>'7') and (Key<>'8') and (Key<>'9')  and
         (Key<>'.') and (ord(Key)<>8) then
       Key:=chr(0);
end;

procedure Tfbaseunit.Edit7KeyPress(Sender: TObject; var Key: Char);
begin
     if (Key<>'0') and (Key<>'1') and (Key<>'2') and (Key<>'3') and (Key<>'4')and
        (Key<>'5') and (Key<>'6') and (Key<>'7') and (Key<>'8') and (Key<>'9')  and
        (ord(Key)<>8) then
       Key:=chr(0);
end;

procedure Tfbaseunit.Edit9KeyPress(Sender: TObject; var Key: Char);
begin
     if (Key<>'0') and (Key<>'1') and (Key<>'2') and (Key<>'3') and (Key<>'4')and
        (Key<>'5') and (Key<>'6') and (Key<>'7') and (Key<>'8') and (Key<>'9')  and
         (Key<>'.') and (ord(Key)<>8) then
       Key:=chr(0);
end;

procedure Tfbaseunit.DBLookupComboBox1CloseUp(Sender: TObject);
begin
   if dblookupcombobox1.Text <>'' then
    dblookupcombobox2.KeyValue :=dblookupcombobox1.KeyValue ;
end;

procedure Tfbaseunit.DBLookupComboBox2CloseUp(Sender: TObject);
begin
   if dblookupcombobox2.Text <>'' then
   dblookupcombobox1.KeyValue :=dblookupcombobox2.KeyValue ;
end;

procedure Tfbaseunit.DBLookupComboBox4CloseUp(Sender: TObject);
begin
   if dblookupcombobox4.Text <>'' then
   begin
   dblookupcombobox5.KeyValue :=dblookupcombobox4.KeyValue ;
   dblookupcombobox6.Enabled :=true;
   dblookupcombobox7.Enabled :=true;
   end;
end;

procedure Tfbaseunit.DBLookupComboBox5CloseUp(Sender: TObject);
begin
   if dblookupcombobox5.Text <>'' then
   begin
   dblookupcombobox4.KeyValue :=dblookupcombobox5.KeyValue ;
   dblookupcombobox6.Enabled :=true;
   dblookupcombobox7.Enabled :=true;
   end;
end;

procedure Tfbaseunit.DBLookupComboBox6CloseUp(Sender: TObject);
begin
   if dblookupcombobox6.Text <>'' then
   dblookupcombobox7.KeyValue :=dblookupcombobox6.KeyValue ;
end;

procedure Tfbaseunit.DBLookupComboBox7CloseUp(Sender: TObject);
begin
   if dblookupcombobox7.Text <>'' then
   dblookupcombobox6.KeyValue :=dblookupcombobox7.KeyValue ;
end;


procedure Tfbaseunit.PageControl1Change(Sender: TObject);
begin
   if pagecontrol1.ActivePage=tabsheet3 then
   sitequery.ParamByName('unit_id').AsInteger :=unitid;
   sitequery.Close;
   sitequery.Open;

end;

procedure Tfbaseunit.DBLookupComboBox8CloseUp(Sender: TObject);
begin
   if dblookupcombobox8.KeyValue =999 then
   begin
     qrydepot.SQL.Clear ;
     qrydepot.SQL.Add(qrydepotsql);
     qrydepot.ParamByName('unitid').AsInteger :=unitid;
     qrydepot.Close;
     qrydepot.Open;
   end else
   begin
     qrydepot.SQL.Clear;
     qrydepot.SQL.Add(qrydepotsql);
     qrydepot.SQL.Add(' and site_id=:siteid');
     qrydepot.ParamByName('unitid').AsInteger :=unitid;
     qrydepot.ParamByName('siteid').AsInteger :=dblookupcombobox8.KeyValue ;
     qrydepot.Close;
     qrydepot.Open;
   end;
end;

procedure Tfbaseunit.DBLookupComboBox9CloseUp(Sender: TObject);
begin
   if dblookupcombobox9.KeyValue =999 then
   begin
     qryfdposition.SQL.Clear ;
     qryfdposition.SQL.Add(qryfdsql);
     qryfdposition.ParamByName('unitid').AsInteger :=unitid;
     qryfdposition.Close;
     qryfdposition.Open;

     query11.close;
   end else
   begin
     qryfdposition.SQL.Clear;
     qryfdposition.SQL.Add(qryfdsql);
     qryfdposition.SQL.Add(' and site_id=:siteid');
     qryfdposition.ParamByName('unitid').AsInteger :=unitid;
     qryfdposition.ParamByName('siteid').AsInteger :=dblookupcombobox9.KeyValue ;
     qryfdposition.Close;
     qryfdposition.Open;

     query11.ParamByName('site_id').AsInteger :=dblookupcombobox9.KeyValue ;
     query11.ParamByName('unit_id').AsInteger :=unitid;
     query11.close;
     query11.open;

     dblookupcombobox10.KeyValue :=999;
   end;

  
end;

procedure Tfbaseunit.DBLookupComboBox10CloseUp(Sender: TObject);
begin
   if dblookupcombobox10.KeyValue =999 then
   begin
     qryfdposition.SQL.Clear;
     qryfdposition.SQL.Add(qryfdsql);
     qryfdposition.SQL.Add(' and site_id=:siteid');
     qryfdposition.ParamByName('unitid').AsInteger :=unitid;
     qryfdposition.ParamByName('siteid').AsInteger :=dblookupcombobox9.KeyValue ;
     qryfdposition.Close;
     qryfdposition.Open;
   end else
   begin
     qryfdposition.SQL.Clear;
     qryfdposition.SQL.Add(qryfdsql);
     qryfdposition.SQL.Add(' and site_id=:siteid');
     qryfdposition.SQL.Add(' and depot_id=:depotid');
     qryfdposition.ParamByName('unitid').AsInteger :=unitid;
     qryfdposition.ParamByName('siteid').AsInteger :=dblookupcombobox9.KeyValue ;
     qryfdposition.ParamByName('depotid').AsInteger :=dblookupcombobox10.KeyValue ;
     qryfdposition.Close;
     qryfdposition.Open;
   end;
end;

procedure Tfbaseunit.TabSheet3Show(Sender: TObject);
begin
    if edit6.Text ='' then
      edit6.Text :='0';
end;

procedure Tfbaseunit.TabSheet4Show(Sender: TObject);
begin
    if edit9.Text ='' then
      edit9.Text :='0';
end;

end.

⌨️ 快捷键说明

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