回 帖 发 新 帖 刷新版面

主题:[讨论]各位大虾帮我看看~我都不知道怎么做了哈~

下面具体的删除和添加代码哈~但是我不知道“修改”怎么做了哈!你们哪个能帮帮我好吗???这个修改代码只是当我选择到具体的章节的时候就能修改:::
procedure Tchooseform.DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
begin

  DBMemo2.DataSource:=DataModule4.DataSource_choose;
  DBEdit8.DataSource:=DataModule4.DataSource_choose;
  DBEdit9.DataSource:=DataModule4.DataSource_choose ;
  DBEdit10.DataSource:=DataModule4.DataSource_choose;
  DBEdit11.DataSource:=DataModule4.DataSource_choose;
  DBEdit12.DataSource:=DataModule4.DataSource_choose;
  DBEdit13.DataSource:=DataModule4.DataSource_choose ;
  DBComboBox1.DataSource:=DataModule4.DataSource_choose ;
  DBRadioGroup2.DataSource:=DataModule4.DataSource_choose;



case button of
nbInsert:
begin
addchoose:=true;

if Treeview1.Focused=false then
begin
showmessage('请选择一个章节点') ;
  DBNavigator1.BtnClick(nbCancel);
 // nbInsert
// DBNavigator1.
  DBNavigator1.Enabled:=false;
end
else
if treeview1.Focused=true then
begin
 DBNavigator1.Enabled:=false;
if (temp mod 10)=0 then
begin
showmessage('本章知识点已满!');
DBNavigator1.BtnClick(nbCancel);
end
else
begin
DBEdit13.text:=inttostr(temp);
end;
end;
end;
end;

   case button of
   nbDelete:
   begin
   
if Treeview1.Focused=false then
begin
DBNavigator1.BtnClick(nbCancel);
showmessage('请选择一个章节点') ;
  DBNavigator1.BtnClick(nbCancel);
  DBNavigator1.Enabled:=false;
end
else
//DBNavigator1.d
query2.close;
query2.sql.clear;
query2.sql.text:='delete ti_choose where tno='''+inttostr(mainform.updateno)+''' ';
query2.ExecSQL;

query2.close;
query2.sql.clear;
query2.sql.text:='update ti_choose set tno=tno-1 where tno>'''+inttostr(mainform.updateno)+''' and tno like '''+inttostr(mainform.updateno div 10)+'%''';
query2.ExecSQL;
DBNavigator2.DataSource:=DataModule4.DataSource_choose;
dataModule4.Table_choose.First;
//  showmessage(inttostr(DataModule4.Table_choose.FieldValues['tno']));
   end;
   end;


case button of
nbPost:
begin
DataModule4.Table_choose.Close;
DataModule4.Table_choose.Open;

end;
end;
end;

procedure Tchooseform.TreeView1Click(Sender: TObject);
begin


 if TreeView1.Selected.text='第一知识点 C语言的特点' then  //第一章第一节第一知识点
   begin
  query1.Active:=false;
  query1.Active:=true;
if(query1.Active=true)then
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select * from ti_choose where tno like ''111%'' order by tno');
query1.Open;
begin
  if query1.RecordCount<>0 then
  begin
  query1.Last;
  temp:=query1.FieldValues['tno']+1;
  end
  else if query1.RecordCount=0 then
  begin
     temp:=1111;
  end;
end;


  end;
 end;


 if TreeView1.Selected.text='第一知识点 C语言的标识符和保留字' then  //第一章第二节第一知识点
   begin
  query1.Active:=false;
  query1.Active:=true;
if(query1.Active=true)then
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select * from ti_choose where tno like ''121%'' order by tno');
query1.Open;
begin
  if query1.RecordCount<>0 then
  begin
  query1.Last;
  temp:=query1.FieldValues['tno']+1;
  end
  else if query1.RecordCount=0 then
  begin
     temp:=1211;
  end;
end;


 end;
 end;
 {
 
     if TreeView1.Selected.text='第三节' then    //第一章第三节
   begin

  query1.Active:=false;
  query1.Active:=true;


if(query1.Active=true)then
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select * from ti_choose where tno like ''13%%'' order by tno');
query1.Open;
 end;
 end;
                           }
if TreeView1.Selected.text='第一知识点 C程序的结构' then      //第一章第三节第一知识点
   begin

  query1.Active:=false;
  query1.Active:=true;


if(query1.Active=true)then
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select * from ti_choose where tno like ''131%'' order by tno');
query1.Open;
begin
  if query1.RecordCount<>0 then
  begin
  query1.Last;
  temp:=query1.FieldValues['tno']+1;
  end
  else if query1.RecordCount=0 then
  begin
     temp:=1311;
  end;
end;

 end;
 end;
                        {
 if TreeView1.Selected.text='第四节' then             //第一章第四节
   begin

  query1.Active:=false;
  query1.Active:=true;


if(query1.Active=true)then
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select * from ti_choose where tno like ''14%%''');
query1.Open;
 end;
 end;
                            }


if TreeView1.Selected.text='第一知识点 C程序的开发过程' then     //第一章第四节第一知识点
   begin
  query1.Active:=false;
  query1.Active:=true;
if(query1.Active=true)then
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select * from ti_choose where tno like ''141%'' order by tno');
query1.Open;
begin
  if query1.RecordCount<>0 then
  begin
  query1.Last;
  temp:=query1.FieldValues['tno']+1;
  end
  else if query1.RecordCount=0 then
  begin
     temp:=1411;
  end;
end;

 end;
 end;

 //-----------------------------------------------------------------
 {
 if TreeView1.Selected.text='第二章 数据类型、运算符与表达式' then
   begin
  query1.Active:=false;
  query1.Active:=true;
if(query1.Active=true)then
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select * from ti_choose where tno like ''2%%%''');
query1.Open;
 end;
 end;

                     }
                     {
if TreeView1.Selected.text='第一节' then
   begin
  query1.Active:=false;
  query1.Active:=true;
if(query1.Active=true)then
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select * from ti_choose where tno like ''21%%''');
query1.Open;
 end;
 end;

                             }

  DBMemo2.DataSource:=DataSource1;
  DBEdit8.DataSource:=DataSource1;
  DBEdit9.DataSource:=DataSource1;
  DBEdit10.DataSource:=DataSource1;
  DBEdit11.DataSource:=DataSource1;
  DBEdit12.DataSource:=DataSource1;
  DBEdit13.DataSource:=DataSource1;
  DBComboBox1.DataSource:=DataSource1;
  DBRadioGroup2.DataSource:=DataSource1;
 DBNavigator2.DataSource:=DataSource1;
end;

procedure Tchooseform.BitBtn3Click(Sender: TObject);
begin
DBNavigator1.BtnClick(nbCancel);
end;


function Tchooseform.checknewchoose:boolean;
var
success:boolean;
begin
success:=true;
with DataModule4.Table_choose do
begin
if DBEdit8.Text='' then
success:=false;
if DBEdit9.Text='' then
success:=false;
if DBEdit10.Text='' then
success:=false;
if DBEdit11.Text='' then
success:=false;
if DBComboBox1.Text='' then
success:=false;

if DBMemo2.Text='' then
success:=false;

if DBRadioGroup2.Value='' then
success:=false;

if not success then
begin
showmessage('红色项必须填写,请补上未填的红色项!');
end;
  checknewchoose:=success;
end;

end;


procedure Tchooseform.BitBtn2Click(Sender: TObject);
begin

 if addchoose then
     begin
       if checknewchoose then
       begin

       DataModule4.Table_choose.Post;
DataModule4.Table_choose.Close;
DataModule4.Table_choose.Open;
       showmessage('添加成功!');

       addchoose:=false;
       DBNavigator2.DataSource:=DataModule4.DataSource_choose;
    //   inc(newshijuanhao);
     //  DataModule4.Table_shijuan.UpdateRecord;
     DBNavigator1.Enabled:=true;
        end
    else
    exit;
end;


end;

procedure Tchooseform.FormCreate(Sender: TObject);

begin
//bw:=DBNavigator1.Width;
//ew:=(DBNavigator1.Width div 2);
addchoose:=false;

end;

procedure Tchooseform.DBMemo2MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
//
 //  DBMemo2.ReadOnly:=false;

  //             DataModule4.Table_choose.
{                                                     
DBMemo2.DataSource:=DataModule4.DataSource_choose;
  DBEdit8.DataSource:=DataModule4.DataSource_choose;
  DBEdit9.DataSource:=DataModule4.DataSource_choose ;
  DBEdit10.DataSource:=DataModule4.DataSource_choose;
  DBEdit11.DataSource:=DataModule4.DataSource_choose;
  DBEdit12.DataSource:=DataModule4.DataSource_choose;
  DBEdit13.DataSource:=DataModule4.DataSource_choose ;
  DBEdit14.DataSource:=DataModule4.DataSource_choose ;
  DBRadioGroup2.DataSource:=DataModule4.DataSource_choose;    }
end;

procedure Tchooseform.TreeView1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
DBNavigator1.Enabled:=true;
end;

procedure Tchooseform.DBNavigator2Click(Sender: TObject;
  Button: TNavigateBtn);
begin


case button of
nbFirst:

begin
  DataModule4.Table_choose.First;
  end;
end;

end;
procedure Tchooseform.DBEdit13Change(Sender: TObject);

begin

//showmessage(inttostr(bw));
//showmessage(inttostr(ew));
if DBEdit13.Text='' then
begin
DBNavigator1.VisibleButtons:=[nbInsert];

 DBNavigator1.Width:=28;
 end;
if DBEdit13.Text<>'' then
begin
 DBNavigator1.Width:=56;
DBNavigator1.VisibleButtons:=[nbInsert,nbDelete];

end;
end;

end.

回复列表 (共1个回复)

沙发

太长了,晕

我来回复

您尚未登录,请登录后再回复。点此登录或注册