📄 unit1.cpp
字号:
}
if(RadioGroup1->ItemIndex==-1&&CheckBox10->Checked==false&&CheckBox11->Checked==false&&Edit11->Text==""&&Edit12->Text==""&&Edit13->Text=="")
str=str+" 学习情况表.学号=学生基本信息表.学号 ";
Query4->Active=false;
Query4->SQL->Text=str;
Query4->Active=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
int i=0,h=0;
if(ListBox1->Items->GetText()=="")
ListBox1->Items->Add(ComboBox1->Text);
else
{
for(i=0;i<ListBox1->Items->Count;i++)
if(ListBox1->Items->Strings[i]==ComboBox1->Text)
h=1;
if(h==1) {ShowMessage("该项已存在,请重新输入!");return;}
else ListBox1->Items->Add(ComboBox1->Text);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button8Click(TObject *Sender)
{
Edit14->Text="";
Edit15->Text="";
Edit16->Text="";
Edit17->Text="";
Query4->Active=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
String str;
Query5->RequestLive=false;
str="select 学生基本信息表.姓名,就业信息表.* from 学生基本信息表,就业信息表 where ";
if(Edit14->Text==""&&Edit15->Text==""&&Edit16->Text==""&&Edit17->Text=="")
str=str+" 学生基本信息表.学号=就业信息表.学号 " ;
else
{
if(Edit14->Text!=""&&Edit15->Text==""&&Edit16->Text==""&&Edit17->Text=="")
{
str=str+" 学生基本信息表.学号='"+Edit14->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text==""&&Edit15->Text!=""&&Edit16->Text==""&&Edit17->Text=="")
{
str=str+" 学生基本信息表.姓名='"+Edit15->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text==""&&Edit15->Text==""&&Edit16->Text!=""&&Edit17->Text=="")
{
str=str+" 就业信息表.单位名称='"+Edit16->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text==""&&Edit15->Text==""&&Edit16->Text==""&&Edit17->Text!="")
{
str=str+" 就业信息表.所在城市='"+Edit17->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text!=""&&Edit15->Text!=""&&Edit16->Text==""&&Edit17->Text=="")
{
str=str+" 学生基本信息表.学号='"+Edit14->Text+"' and 学生基本信息表.姓名='"+Edit15->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text!=""&&Edit15->Text==""&&Edit16->Text!=""&&Edit17->Text=="")
{
str=str+" 学生基本信息表.学号='"+Edit14->Text+"' and 就业信息表.单位名称='"+Edit16->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text!=""&&Edit15->Text==""&&Edit16->Text==""&&Edit17->Text!="")
{
str=str+" 学生基本信息表.学号='"+Edit14->Text+"' and 就业信息表.所在城市='"+Edit17->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text==""&&Edit15->Text!=""&&Edit16->Text!=""&&Edit17->Text=="")
{
str=str+" 学生基本信息表.姓名='"+Edit15->Text+"' and 就业信息表.单位名称='"+Edit16->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text==""&&Edit15->Text!=""&&Edit16->Text==""&&Edit17->Text!="")
{
str=str+" 学生基本信息表.姓名='"+Edit15->Text+"' and 就业信息表.所在城市='"+Edit17->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text==""&&Edit15->Text==""&&Edit16->Text!=""&&Edit17->Text!="")
{
str=str+" 就业信息表.单位名称='"+Edit16->Text+"' and 就业信息表.所在城市='"+Edit17->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text!=""&&Edit15->Text!=""&&Edit16->Text!=""&&Edit17->Text=="")
{
str=str+" 学生基本信息表.学号='"+Edit14->Text+"' and 学生基本信息表.姓名='"+Edit15->Text+"' and 就业信息表.单位名称='"+Edit16->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text!=""&&Edit15->Text!=""&&Edit16->Text==""&&Edit17->Text!="")
{
str=str+" 学生基本信息表.学号='"+Edit14->Text+"' and 学生基本信息表.姓名='"+Edit15->Text+"' and 就业信息表.所在城市='"+Edit17->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text==""&&Edit15->Text!=""&&Edit16->Text!=""&&Edit17->Text!="")
{
str=str+" 学生基本信息表.姓名='"+Edit15->Text+"' and 就业信息表.单位名称='"+Edit16->Text+"' and 就业信息表.所在城市='"+Edit17->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
if(Edit14->Text!=""&&Edit15->Text!=""&&Edit16->Text!=""&&Edit17->Text!="")
{
str=str+" 学生基本信息表.学号='"+Edit14->Text+"' and 学生基本信息表.姓名='"+Edit15->Text+"' and 就业信息表.单位名称='"+Edit16->Text+"' and 就业信息表.所在城市='"+Edit17->Text+"' and 学生基本信息表.学号=就业信息表.学号 ";
}
}
Query4->Active=false;
Query4->SQL->Text=str;
Query4->Active=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button9Click(TObject *Sender)
{
if(OpenPictureDialog1->Execute())
{
picture1=OpenPictureDialog1->FileName;
Image2->Picture->LoadFromFile(picture1);
Image2->Show();
Button12->Enabled=true;
}
else
{
str1="select * from 学生基本信息表 where 学号='"+Edit18->Text+"'";
Query5->Active=false;
Query5->SQL->Text=str1;
Query5->Active=true;
if(Edit18->Text==Query1->Fields->FindField("学号")->AsString)
picture1=Query5->Fields->FieldByName("照片")->AsString;
else picture1="";
Query5->Active=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button10Click(TObject *Sender)
{
int a;
String str,str1,str2,str3,str4,class1,grade1,numb1;
int h=0,i,j=0,k=0,l=0,m=0,n=1,p=1,q=1,r=0,s=0,t=0,u=0,y=0,z=0,v=0,w=0;
if(Edit18->Text!="")
{
if(Edit19->Text=="")
{ShowMessage("姓名不能为空!");Query1->Active=false;return;}
if(ComboBox2->ItemIndex==-1)
{ShowMessage("请选择性别!");Query1->Active=false;return;}
if(Edit21->Text=="")
{ShowMessage("民族不能为空!");Query1->Active=false;return;}
if(Edit22->Text=="")
{ShowMessage("籍贯不能为空!");Query1->Active=false;return;}
if(Edit23->Text=="")
{ShowMessage("政治面貌不能为空!");Query1->Active=false;return;}
if(Edit24->Text=="")
{ShowMessage("家庭住址不能为空!");Query1->Active=false;return;}
if(Edit25->Text=="")
{ShowMessage("家庭电话不能为空!");Query1->Active=false;return;}
//修改记录
Query1->Active=false;
Query1->SQL->Text="select 学号,姓名,性别,民族,籍贯,家庭住址,家庭电话,政治面貌,爱好,备注 from 学生基本信息表 where 学号='"+Edit18->Text+"'";
Query1->Active=true;
if(Query1->Fields->FindField("学号")->AsString==Edit18->Text)
{
a=Application->MessageBoxA("该学号已存在,是否进行修改?","提示框",65);
if(a==1)
{
str="update 学生基本信息表 set 姓名='"+Edit19->Text+"',性别='"+ComboBox2->Text+"',民族='"+Edit21->Text+"',籍贯='"+Edit22->Text+"',政治面貌='"+Edit23->Text+"',家庭住址='"+Edit24->Text+"',家庭电话='"+Edit25->Text+"',爱好='"+Edit26->Text+"',照片='"+picture1+"',备注='"+Edit27->Text+"' where 学号='"+Edit18->Text+"'";
str1="select 学号,姓名,性别,民族,籍贯,家庭住址,家庭电话,政治面貌,爱好,备注 from 学生基本信息表 where 学号='"+Edit18->Text+"'" ;
Query1->Active=false;
Query1->SQL->Text=str;
Query1->ExecSQL();
Query1->SQL->Text=str1;
Query1->Active=true;
ShowMessage("修改成功!");
}
}
//添加记录
else
{
Query1->Active=false;
Query1->SQL->Text="select 学号,姓名,性别,民族,籍贯,家庭住址,家庭电话,政治面貌,爱好,备注 from 学生基本信息表 order by 学号 asc";
Query1->Active=true;
a=Application->MessageBoxA("是否添加该记录?","提示框",65);
if(a==1)
{
s=Query1->RecordCount+1;
class1=Edit18->Text.SubString(1,6);
str="insert into 学生基本信息表(学号,姓名,性别,民族,籍贯,家庭住址,家庭电话,政治面貌,爱好,照片,备注) values('"+Edit18->Text+"','"+Edit19->Text+"','"+ComboBox2->Text+"','"+Edit21->Text+"','"+Edit22->Text+"','"+Edit24->Text+"','"+Edit25->Text+"','"+Edit23->Text+"','"+Edit26->Text+"','"+picture1+"','"+Edit27->Text+"')";
str1="select 学号,姓名,性别,民族,籍贯,家庭住址,家庭电话,政治面貌,爱好,备注 from 学生基本信息表 where 学号='"+Edit18->Text+"'";
str2="insert into 在校信息表(学号,班级) values('"+Edit18->Text+"','"+class1+"')";
str3="insert into 学习情况表(学号,班级) values('"+Edit18->Text+"','"+class1+"')";
str4="insert into 就业信息表(学号) values('"+Edit18->Text+"')";
Query1->Active=false;
Query1->SQL->Text=str;
Query1->ExecSQL();
Query1->SQL->Text=str2;
Query1->ExecSQL();
Query1->SQL->Text=str3;
Query1->ExecSQL();
Query1->SQL->Text=str4;
Query1->ExecSQL();
Query1->Active=false;
Query1->SQL->Text=str1;
Query1->Active=true;
//TreeView的显示
str1="select 学号 from 学生基本信息表 order by 学号 asc";
Query5->Active=false;
Query5->SQL->Text=str1;
Query5->Active=true;
for(i=0;i<s;i++)
{
Query5->First();
Query5->MoveBy(i);
if(i==0)
{
grade1=DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,2);
class1=DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,6);
}
if(grade1!=DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,2))
{
p++; //年级数
grade1=DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,2);
}
if(class1!=DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,6))
{
q++; //班级数
class1=DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,6);
}
}
Query5->First();
Query5->MoveBy(0);
grade1=DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,2);
TTreeNode *Node1,*Node2,*Node3;//Node1指向年级,Node2指向班级,Node3指向成员
TreeView1->Items->Clear();
TreeView1->Items->Add(NULL, grade1);
Node1=TreeView1->Items->Item[0];
for(i=0;i<p;i++)
{
Node2=TreeView1->Items->Item[m];
l=0;
if(i==0)
{
for(j=t;j<q;j++)
{
Query5->First();
Query5->MoveBy(r);//指向第h个学号
if(grade1==DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,2))
class1=DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,6); //如果为该年级,则将班级放入该年级子目录中
else break;
TreeView1->Items->AddChild(Node2,class1);
Node3=TreeView1->Items->Item[n];
for(k=r;k<s;k++)
{
Query5->First();
Query5->MoveBy(k);
if(class1==DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,6))
{
TreeView1->Items->AddChild(Node3,DBGrid9->Columns->Items[0]->Field->AsString);//如果为该班级,则将对应学号放入该班级子目录中
l++;
h++;//向下指数据表中一个学号
}
else break;
}
r=k;
n=n+l+1;
l=0;
t=j;
}
}
else
{
n++;
for(j=t;j<q;j++)
{
Query5->First();
Query5->MoveBy(r);//指向第h个学号
if(grade1==DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,2))
class1=DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,6); //如果为该年级,则将班级放入该年级子目录中
else break;
TreeView1->Items->AddChild(Node2,class1);
Node3=TreeView1->Items->Item[n];
for(k=r;k<s;k++)
{
Query5->First();
Query5->MoveBy(k);
if(class1==DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,6))
{
TreeView1->Items->AddChild(Node3,DBGrid9->Columns->Items[0]->Field->AsString);//如果为该班级,则将对应学号放入该班级子目录中
l++;
h++;//向下指数据表中一个学号
v++;
}
else break;
}
r=k;
n=n+l+1;
l=0;
t=j;
}
}
m=n;
for(y=j;y<s;y++)
{
Query5->First();
Query5->MoveBy(r);
if(grade1!=DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,2))
{
grade1=DBGrid9->Columns->Items[0]->Field->AsString.SubString(1,2);
break;
}
}
TreeView1->Items->Add(Node1,grade1);
}
for(i=0;i<p;i++)
TreeView1->Items->Item[m-i]->Delete();
}
Query7->Active=false;
Query7->SQL->Text="select * from 学生基本信息表";
Query7->Active=true;
ShowMessage("添加成功!");
}
}
Button13->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button11Click(TObject *Sender)
{
Query7->Active=false;
Query7->SQL->Text="select 学号,姓名,性别,民族,籍贯,家庭住址,家庭电话,政治面貌,爱好,备注 from 学生基本信息表 order by 学号 asc";
Query7->Active=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N11Click(TObject *Sender)
{
String str;
mainview->Visible=false;
studentview->Visible=false;
learnview->Visible=false;
workview->Visible=false;
basechange->Visible=true;
studentchange->Visible=false;
learnchange->Visible=false;
workchange->Visible=false;
lessonchange->Visible=false;
main->Enabled=true;
details->Enabled=true;
learn->Enabled=true;
work->Enabled=true;
N11->Enabled=false;
N12->Enabled=true;
N13->Enabled=true;
N14->Enabled=true;
N15->Enabled=true;
if(DBEdit1->Text!="")
{
Edit18->Text=str10;
Button9->Enabled=true;
Button12->Enabled=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N12Click(TObject *Sender)
{
mainview->Visible=false;
studentview->Visible=false;
learnview->Visible=false;
workview->Visible=false;
basechange->Visible=false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -