ucgjh_lr.pas

来自「工廠採購管理系統」· PAS 代码 · 共 536 行 · 第 1/2 页

PAS
536
字号
end;

procedure Tfrmcgjh_lr.DBEdit1Change(Sender: TObject);
begin
if not adoquery4.Active then exit;
strsql:='select * from view_cgjh where cgjhdh='+''''+trim(dbedit1.Text)+'''';
adoexect(adoquery1,strsql);
end;

procedure Tfrmcgjh_lr.RzBitBtn8Click(Sender: TObject);
begin
RzBitBtn1.Enabled:=true;
RzBitBtn2.Enabled:=true;
RzBitBtn3.Enabled:=false;
adoquery4.CancelUpdates;
end;

procedure Tfrmcgjh_lr.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if (adoquery4.State in[dsinsert]) or (adoquery4.State in[dsedit]) then
   begin
   if messagebox(handle,'计划当前正处于编辑状态,是否需要保存?','询问'
   ,mb_yesno+mb_iconquestion)=idyes then
      begin
      RzBitBtn3Click(self);
      end else begin
      RzBitBtn8Click(self);
      end;
   end;
action:=cafree;

end;

procedure Tfrmcgjh_lr.RzBitBtn9Click(Sender: TObject);
begin
close;
end;

procedure Tfrmcgjh_lr.DBEdit2Enter(Sender: TObject);
begin
RzMenuToolbarButton1.Visible:=true;
end;

procedure Tfrmcgjh_lr.DBEdit2Exit(Sender: TObject);
begin
RzMenuToolbarButton1.Visible:=false;
end;

procedure Tfrmcgjh_lr.RzMenuToolbarButton1Click(Sender: TObject);
begin
if (not (adoquery4.State in[dsEdit])) and (not (adoquery4.State in[dsinsert])) then exit;
strsql:='select * from cgjh_detail where cgjhdh='+''''+trim(dbedit1.Text)+'''';
adoexect(adoquery3,strsql);
if not(adoquery3.Recordset.eof and adoquery3.Recordset.bof) then
   begin
   showmessage('该计划单已经存在了明细记录,不能更改需求单号');
   exit;
   end;
adoquery3.Close;
frmxqdh_lb:=tfrmxqdh_lb.Create(self);
frmxqdh_lb.ShowModal;
dbedit2.Text:=strhthm;
strhthm:='';
end;

procedure Tfrmcgjh_lr.TabSheet2Enter(Sender: TObject);
begin
if not adoquery1.Active then exit;
if adoquery1.Recordset.EOF and adoquery1.Recordset.BOF then exit;
edit1.Text:=inttostr(adoquery1.fieldbyname('jhsl').Value);
edit2.Text:=inttostr(adoquery1.fieldbyname('xqsl').Value);
dtp1.Date:=adoquery1.fieldbyname('srrq').Value;
edit1.SetFocus;
end;

procedure Tfrmcgjh_lr.RzBitBtn12Click(Sender: TObject);
begin
if strtoint(trim(edit1.Text))<cgsl then
   begin
        showmessage('计划数量不能少于必须订购的采购数量!');
        exit;
   end;
if trim(edit1.Text)='0' then
   begin
       showmessage('计划数量不呢为0');
       exit;
   end;
try
        strsql:='update cgjh_detail set jhsl='+trim(edit1.text)+
        ',srrq='+''''+datetostr(dtp1.Date)+''''+' where cgjhdh='+''''+
         trim(adoquery1.fieldbyname('cgjhdh').AsString)+''''+'and wldm='+
         ''''+trim(adoquery1.fieldbyname('wldm').AsString)+'''';
         adodel(adoquery3,strsql);
         adoquery3.Close;
         adoquery1.Requery;
except
         showmessage('更新数据失败');
end;
RzPageControl1.ActivePageIndex:=0;
end;

procedure Tfrmcgjh_lr.RzBitBtn13Click(Sender: TObject);
begin
RzPageControl1.ActivePageIndex:=0;
end;

procedure Tfrmcgjh_lr.RzBitBtn7Click(Sender: TObject);
begin
frmcx:=tfrmcx.Create(self);
frmcx.adocx:=adoquery4;
frmcx.ShowModal;
adoquery4:=frmcx.adocx;
ADOquery4.Requery();
end;

procedure Tfrmcgjh_lr.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if not (key in['0'..'9',#46,#8] ) then
    key:=#0;
end;

procedure Tfrmcgjh_lr.RzBitBtn5Click(Sender: TObject);
begin
if adoquery2.Active then adoquery2.Close;
adoquery2.Parameters.ParamByName('cgjhdh').Value:=trim(dbedit1.Text);
adoquery2.Open;
form3.frDBDataSet1.dataset:=adoquery1;
form3.frDBDataSet2.dataset:=adoquery2;
form3.frReport1.DoublePass := True;
form3.frReport1.Clear;
form3.frReport1.LoadFromFile(strpath+'/report/cgwljh_1.frf');
frVariables['username']:=username;
form3.frReport1.Preview := Form3.frPreview1;
if form3.frReport1.PrepareReport then
  begin
    form3.frReport1.ShowPreparedReport;
  end;
form3.ShowModal;
adoquery2.Close;
end;

procedure Tfrmcgjh_lr.RzBitBtn4Click(Sender: TObject);
begin
if not qxjc(userid,'jhd_shhe') then exit;
try
    strsql:='update cgjh_main set shhe=1'+
    ' where cgjhdh='+''''+trim(dbedit1.Text)+'''';
    adodel(adoquery3,strsql);
except
    showmessage('审核出错!');
    exit;
end;
adoquery3.Close;
end;

procedure Tfrmcgjh_lr.DBEdit5Exit(Sender: TObject);
begin
RzMenuToolbarButton2.Visible:=false;
end;

procedure Tfrmcgjh_lr.DBEdit5Enter(Sender: TObject);
begin
RzMenuToolbarButton2.Visible:=true;
end;

procedure Tfrmcgjh_lr.RzMenuToolbarButton2Click(Sender: TObject);
begin
if (not (adoquery4.State in [dsinsert])) and (not (adoquery4.State in [dsedit])) then
    begin
    showmessage('计划单号当前不处于编辑状态,请选择修改后进行编辑!');
    exit;
    end;
lbname:='';
strhthm:='';
frmgyslb:=tfrmgyslb.Create(self);
frmgyslb.ShowModal;
dbedit5.Text:=lbname;
dbedit10.Text:=strhthm;
end;

procedure Tfrmcgjh_lr.N1Click(Sender: TObject);
begin
if jcsj then exit;
if not qxjc(userid,'jhd_edit') then exit;
//判断是否已经保存计划单头
if (adoquery4.State in[dsinsert]) or (adoquery4.State in[dsedit]) then
   begin
   showmessage('请先保存计划数据,方能添加明细记录!');
   adoquery3.Close;
   exit;
   end;
title:='';
strhthm:=trim(dbedit2.Text);
frmcgxq_wllb:=tfrmcgxq_wllb.Create(self);
frmcgxq_wllb.ShowModal;
if title='' then exit;
try
    strsql:='select * from cgjh_detail where cgjhdh='+''''+trim(dbedit1.Text)+''''+
    'and wldm='+''''+title+'''';
    adoexect(adoquery3,strsql);
    if adoquery3.Recordset.eof and adoquery3.Recordset.BOF then
    begin
         adoquery3.Append;
         adoquery3.FieldByName('cgjhdh').AsString:=trim(dbedit1.Text);
         adoquery3.FieldByName('wldm').AsString:=trim(title);
         adoquery3.FieldByName('jhsl').Value:=jhsl;
         adoquery3.FieldByName('xqsl').Value:=jhsl;
         adoquery3.FieldByName('srrq').AsString:=datetostr(date+30);
         adoquery3.Post;
         adoquery1.Close;
         adoquery1.Open;
    end else begin
         showmessage('此物料在该计划单已存在!');
         exit;
    end;
except
     showmessage('增加数据失败');
end;
title:='';
end;

procedure Tfrmcgjh_lr.N2Click(Sender: TObject);
begin
if jcsj then exit;
if not qxjc(userid,'bjd_del')and (username<>trim(dbedit3.Text)) then exit;
try
    strsql:='delete from cgjh_detail where cgjhdh='+''''+
    trim(adoquery1.fieldbyname('cgjhdh').AsString)+''''+
    'and wldm='+''''+trim(adoquery1.fieldbyname('wldm').AsString)+'''';
    adodel(adoquery3,strsql);
    adoquery1.Close;
    adoquery1.Open;
    DBGridEh1.Refresh;
except
    showmessage('删除数据失败!');
end;
end;

procedure Tfrmcgjh_lr.dtp2Exit(Sender: TObject);
begin
csh;
end;

procedure Tfrmcgjh_lr.dtp3Exit(Sender: TObject);
begin
csh;
end;

procedure Tfrmcgjh_lr.RzPageControl1Change(Sender: TObject);
begin
if jcsj then
  begin
  RzPageControl1.ActivePageIndex:=0;
  end;
end;

procedure Tfrmcgjh_lr.DBGridEh1DblClick(Sender: TObject);
begin
  RzPageControl1.ActivePageIndex:=1;
end;

procedure Tfrmcgjh_lr.DBGridEh1TitleClick(Column: TColumnEh);
begin
 Compositor(adoquery1,Column);
end;

end.

⌨️ 快捷键说明

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