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

📄 untpseed.pas

📁 养猪精液采集模块的相关大夫吗对方法对付法对
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    Exit;

 if not showquestion('确定要删除该条产仔记录吗?') then exit;

 with data.Birth do
   if not IsEmpty then
   begin
     //删除本地数据
     Delete;
     //删除远程数据
     if not Eh12Flag then
        ApplyUpdates(0);
   end;

end;

procedure TP_Seed.ToolButton30Click(Sender: TObject);
var
  i,j,k,l:integer;
  BM:TBookMark;
begin
 i:=0;
 j:=0;
 k:=0;
 l:=0;
 with Data.birth do
 begin
   DisableControls;
   BM:=GetBookmark;
   //检查记录
   first;
   while not eof do
   begin
     if (fieldbyname('childbirthdate').AsDateTime>main.EndDate) and (not checkbox3.Checked) then
       begin
        showinfo('存在操作时间不在本业务期间内的记录,本业务间时间为'+Datetimetostr(main.StartDate)+
         '至'+Datetimetostr(main.EndDate));
        inc(i,1);
        break;
       end;
     if fieldbyname('AmBoar').AsString='' then
        begin
        showinfo('没有公猪耳号!请输入公猪耳号。');
        inc(j,1);
        break;
       end;
     if fieldbyname('sonbreed').AsString='' then
       begin
        showinfo('后代品种为空!请查找母猪和公猪是否有品种。');
        inc(j,1);
        break;
       end;
     if (fieldbyname('mearid').AsString='') or
        (fieldbyname('livefair').AsInteger<0) or
        (fieldbyname('ChildbirthDate').AsString='') or
        (fieldbyname('livefemale').AsInteger<0) then
       begin
        showinfo('有记录填写不完整,请首先删除或者修改不完整记录!');
        inc(j,1);
        break;
       end;
     if (fieldbyname('livefair').AsInteger+fieldbyname('livefemale').AsInteger) <>
        //常规      活公+活母=健仔+弱仔
        (fieldbyname('lusty').AsInteger+fieldbyname('weak').AsInteger) then
        //朱仑      活公+活母=健仔+弱仔+畸形
        //(fieldbyname('lusty').AsInteger+fieldbyname('weak').AsInteger+fieldbyname('Abnormality').AsInteger) then
       begin
        //常规      活公+活母=健仔+弱仔
        showinfo('您输入的<活公数+活母数>不等于<健仔数+弱仔数>!');
        //朱仑      活公+活母=健仔+弱仔+畸形
        // showinfo('您输入的<活公数+活母数>不等于<健仔数+弱仔数+畸形>!');
         inc(k,1);
         break;
       end;
     if (fieldbyname('GestationDay').AsInteger<GesDay) and (GesDay>0) then
       begin
        showinfo('妊娠天数小于设定的最小天数'+char(13)+'您设定的妊娠最小天数为'+inttostr(GesDay)+'天!');
        inc(l,1);
        break;
       end;
     next;
   end;

   EnableControls;
   GotoBookMark(BM);
   FreeBooKmark(bm);
   if (i>0) or (j>0) or (k>0) or (l>0) then exit;
   //保存记录
   if not (State in [dsinsert,dsedit]) then  edit;
   Post;
   ApplyUpdates(0);
   showinfo('保存完毕!');
 end;

 //更改公猪、母猪状态 用触发器处理

 //还原DBGridEh设置
 DBGridEh7.Font.Size:=9;
 DBGridEh7.ReadOnly:=true;
 Eh7Flag:=true;
end;

procedure TP_Seed.ToolButton31Click(Sender: TObject);
begin
  //还原DBGridEh设置
 DBGridEh7.Font.Size:=9;
 DBGridEh7.ReadOnly:=true;
 Eh7Flag:=false;
 
 data.Birth.Cancel;
  //更改公猪\母猪状态 在触发器中处理
end;

procedure TP_Seed.ToolButton33Click(Sender: TObject);
begin
 try
 data.Birth.Refresh;
 except
 exit;
 end;
end;

procedure TP_Seed.ToolButton35Click(Sender: TObject);
begin
 //更改DBGridEh
 DBGridEh9.Font.Size:=12;
 DBGridEh9.ReadOnly:=false;
 Eh9Flag:=true;

 data.Ablactation.EmptyDataSet;
 data.Ablactation.Append;
 DBGridEh9.SetFocus;
end;

procedure TP_Seed.ToolButton36Click(Sender: TObject);
begin
 //更改DBGridEh
 DBGridEh9.Font.Size:=12;
 DBGridEh9.ReadOnly:=false;
 Eh9Flag:=true;

 data.Ablactation.Edit;
end;

procedure TP_Seed.ToolButton37Click(Sender: TObject);
 Function ISAm(MEar:string;EmbryoN:Integer):Boolean;
 var
   ENum:String;
 begin
   Result:=True;

   MEar:=quotedstr(MEar);
   ENum:=quotedstr(inttostr(EmbryoN));

   with data.Common do
   begin
    close;
    commandtext:='select * from t_amphimixis where mearid='+MEar+' and EmbryoNum='+ENum;
    open;
    if recordcount>0 then
       begin
       showinfo('母猪'+MEar+'已经再次配种,不能删除该条断奶记录!'+char(13)+
                 '如果您真的想删除该条断奶记录,请先删除该母猪所有第'+
                  ENum+'胎的配种记录!');
       exit;
       end;
   end;
   Result:=false;
   end;
begin
 //如果已经再次配种则断奶记录不能删除
 if ISAm(data.Ablactation.fieldbyname('MEarID').AsString,
         data.Ablactation.fieldbyname('EmbryoNum').AsInteger) then
    Exit;

 if not showquestion('确定要删除该条断奶记录吗?') then exit;

 with data.Ablactation do
   if not IsEmpty then
   begin
     //删除本地数据
     Delete;
     //删除远程数据
     if not Eh12Flag then
        ApplyUpdates(0);
   end;

end;

procedure TP_Seed.ToolButton38Click(Sender: TObject);
var
  i,j:integer;
  BM:TBookMark;
Function CompareDT(MEar:String;EmbryoN:Integer;AbDT:TDateTime):Boolean;
var
  ENum:String;
begin
  Result:=false;

  MEar:=quotedstr(MEar);
  ENum:=quotedstr(inttostr(EmbryoN-1));

  with data.Common do
   begin
     close;
     commandtext:='select childbirthdate from t_birth where Mearid='+MEar+' and embryonum='+ENum;
     open;
     //找不到产仔记录,退出
     if recordcount=0 then exit;
     if AbDT>fieldbyname('childbirthdate').AsDateTime then exit
     else
       begin
       showinfo('母猪'+MEar+'的断奶日期【'+datetimetostr(AbDT)+'】小于产仔日期【'+
                 datetimetostr(fieldbyname('childbirthdate').AsDateTime)+'】!');
       Result:=True;
       end;
   end;
end;
begin
 i:=0;
 j:=0;

 with Data.Ablactation do
 begin
   DisableControls;
   BM:=GetBookmark;
   //检查记录
   first;
   while not eof do
   begin
     if fieldbyname('abdate').AsDateTime>main.EndDate then
       begin
        showinfo('存在操作时间不在本业务期间内的记录,本业务间时间为'+Datetimetostr(main.StartDate)+
         '至'+Datetimetostr(main.EndDate));
        inc(i,1);
        break;
       end;
     if (fieldbyname('mearid').AsString='') or
        (fieldbyname('MPos').AsString='') or
        ((fieldbyname('AbDate').AsDateTime>main.EndDate) and (not checkbox4.Checked)) or
        (fieldbyname('abposition').AsString='') then
       begin
        showinfo('有记录填写不完整,请首先删除或者修改不完整记录!');
        inc(j,1);
        break;
       end;
     //产仔日期不能大于断奶日期
     if CompareDT(fieldbyname('mearid').AsString,
                  fieldbyname('embryonum').AsInteger,
                  fieldbyname('AbDate').AsDateTime) then
       begin 
        inc(j,1);
        break;
       end;
     next;
   end;

   EnableControls;
   GotoBookMark(BM);
   FreeBooKmark(bm);
   if (i>0) or (j>0) then exit;
   //保存记录
   if not (State in [dsinsert,dsedit]) then  edit;
   Post;
   ApplyUpdates(0);
   showinfo('保存完毕!');
 end;

 //更改公猪、母猪状态 用触发器处理

 //还原DBGridEh设置
 DBGridEh9.Font.Size:=9;
 DBGridEh9.ReadOnly:=true;
 Eh9Flag:=true;

end;

procedure TP_Seed.ToolButton39Click(Sender: TObject);
begin
 //还原DBGridEh设置
 DBGridEh9.Font.Size:=9;
 DBGridEh9.ReadOnly:=true;
 Eh9Flag:=false;

 data.Ablactation.Cancel;
  //更改公猪\母猪状态 在触发器中处理
end;

procedure TP_Seed.ToolButton32Click(Sender: TObject);
Const
  BaseSqlStr='select * from t_birth ';  //Remark:Remember set a space sign
var
  FindSqlStr:string;
begin
 //获得查询条件的SQL语句
 FindSqlStr:='';   
 try
    AdVanceF:=TadVanceF.Create(Application,DBGridEh7,'P08');
    AdVanceF.ShowModal;
    FindSqlStr:=AdVanceF.SearchStr;   //   remark:where statement
 Finally
    AdVanceF.Free;
 end;
 //查询数据
 if FindSqlStr='' then Exit;
 with data.Birth do
    begin
     Close;
     CommandText:=BaseSqlStr+FindSqlStr;
     try
       Open;
     except
       on E:exception  do
       showinfo(e.Message);
     end;
   end;
end;

procedure TP_Seed.ToolButton40Click(Sender: TObject);
Const
  BaseSqlStr='select * from t_ablactation ';  //Remark:Remember set a space sign
var
  FindSqlStr:string;
begin
 //获得查询条件的SQL语句
 FindSqlStr:='';   
 try
    AdVanceF:=TadVanceF.Create(Application,DBGridEh9,'P09');
    AdVanceF.ShowModal;
    FindSqlStr:=AdVanceF.SearchStr;   //   remark:where statement
 Finally
    AdVanceF.Free;
 end;
 //查询数据
 if FindSqlStr='' then Exit;
 with data.Ablactation do
    begin
     Close;
     CommandText:=BaseSqlStr+FindSqlStr;
     try
       Open;
     except
       on E:exception  do
       showinfo(e.Message);
     end;
   end;
end;

procedure TP_Seed.pagec_P_SeedChange(Sender: TObject);
begin
   Pagestr:=Pagec_p_seed.ActivePage.Caption;
   if pagestr='' then Exit;

   if Pagestr='配种登记' then
   begin
     DBGridEh6.FieldColumns['AmMan'].PickList.Clear;
   with data.Common do
     begin
       close;
       commandtext:='select * from t_basal where station=''配种员''';
       open;
       first;
       while not eof do
       begin
         DBGridEh6.FieldColumns['AmMan'].PickList.Add(fieldbyname('basalname').AsString);
         next;
       end;
     end;
     showfield(dbgrideh6,Pagestr);
     toolbar3.Parent:=Main.Panel1;
     toolbar3.Visible:=true;
     dtstart.Date:=Date-openday;
     dtend.Date:=Date;
     if not data.Amphimixis.Active then
     SpeedButton1Click(nil);
   end;

   if Pagestr='种猪耳缺信息' then
   begin
     showfield(dbgrideh10,Pagestr);
     toolbar2.Parent:=Main.Panel1;
     toolbar2.Visible:=true;
     if Panel5.visible then Panel5.visible:=false;
     dtstart5.Date:=Date-openday;
     dtend5.Date:=Date;
     if not data.gapinf.Active then
     SpeedButton5Click(nil);
     //添加来源下拉框
     DBGridEh10.FieldColumns['Source'].PickList.Clear;
     DBGridEh10.FieldColumns['Source'].PickList.Add('本场');
     with data.common do
     begin
       close;
       commandtext:='select * from t_Clientdata where Estate=1';
       open;
       while not eof do
       begin
        if fieldbyname('SName').AsString<>'' then
         DBGridEh10.FieldColumns['Source'].PickList.Add(fieldbyname('SName').AsString);
        next;
       end;
     end;  
   end;

   if Pagestr='种猪基本资料' then
   begin
      showfield(dbgrideh1,Pagestr);
      toolbar1.Parent:=Main.Panel1;
      toolbar1.Visible:=true;
      if Panel2.visible then Panel2.visible:=false;
      if TabSheet15.Enabled then
       begin
         Data.pigbaseinf.ApplyUpdates(0);
         Pnl_Edit.Color:=clBtnFace;
         TabSheet15.Enabled:=false;
         exit;
       end;
      dtp_start.Da

⌨️ 快捷键说明

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