📄 unit1.cpp
字号:
Query2->Active=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button19Click(TObject *Sender)
{
Edit37->Text="";
Edit38->Text="";
Edit39->Text="";
Query5->Active=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button18Click(TObject *Sender)
{
String str;
Query5->Active=false;
Query5->RequestLive=true;
str="select * from 就业信息表 ";
if(Edit37->Text!=""&&Edit38->Text==""&&Edit39->Text=="")
str=str+" where 学号='"+Edit37->Text+"'";
if(Edit37->Text==""&&Edit38->Text!=""&&Edit39->Text=="")
str=str+" where 单位名称='"+Edit38->Text+"'";
if(Edit37->Text==""&&Edit38->Text==""&&Edit39->Text!="")
str=str+" where 所在城市='"+Edit39->Text+"'";
if(Edit37->Text!=""&&Edit38->Text!=""&&Edit39->Text=="")
str=str+" where 学号='"+Edit37->Text+"' and 单位名称='"+Edit38->Text+"'";
if(Edit37->Text!=""&&Edit38->Text==""&&Edit39->Text!="")
str=str+" where 学号='"+Edit37->Text+"' and 所在城市='"+Edit39->Text+"'";
if(Edit37->Text==""&&Edit38->Text!=""&&Edit39->Text!="")
str=str+" where 所在城市='"+Edit39->Text+"' and 单位名称='"+Edit38->Text+"'";
if(Edit37->Text!=""&&Edit38->Text!=""&&Edit39->Text!="")
str=str+" where 学号='"+Edit37->Text+"' and 单位名称='"+Edit38->Text+"' and 所在城市='"+Edit39->Text+"'";
Query5->SQL->Text=str;
Query5->Active=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button22Click(TObject *Sender)
{
Edit40->Text="";
Edit41->Text="";
Edit42->Text="";
Edit43->Text="";
Edit44->Text="";
Edit45->Text="";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button20Click(TObject *Sender)
{
int a,b,i,k=0;
float h;
String str;
if(Edit41->Text==""){ShowMessage("课程类别不能为空!");return;}
if(Edit42->Text==""){ShowMessage("开课学期不能为空!");return;}
if(Edit43->Text==""){ShowMessage("课时不能为空!");return;}
if(Edit44->Text==""){ShowMessage("学分不能为空!");return;}
if(Edit40->Text!="")
{
Query2->Active=false;
Query2->SQL->Text="select * from 学习情况表";
Query2->Active=true;
for(i=0;i<Query2->Fields->Count;i++)
if(Query2->Fields->Fields[i]->FieldName==Edit40->Text)
{
k=1;
break;
}
if(k==1)
{
a=Application->MessageBoxA("该门课程已存在,需要修改吗?","提示框",65);
if(a==1)
{
h=StrToFloat(Edit44->Text);
str="update 课程表 set 课程名='"+Edit40->Text+"',开课类别='"+Edit41->Text+"',开课学期='"+Edit42->Text+"',课时="+StrToInt(Edit43->Text)+",学分="+h+",备注='"+Edit45->Text+"'";
Query6->Active=false;
Query6->SQL->Text=str;
Query6->ExecSQL();
str="select * form 课程表";
Query6->SQL->Text=str;
Query6->Active=true;
for(i=0;i<ComboBox1->Items->Count;i++)
{
}
ComboBox3->Items->Add(Edit40->Text);
ShowMessage("修改成功!");
}
}
else
{
a=Application->MessageBoxA("你要添加该门课程吗?","提示框",65);
if(a==1)
{
h=StrToFloat(Edit44->Text);
str="Insert into 课程表 values('"+Edit40->Text+"','"+Edit41->Text+"','"+Edit42->Text+"',"+StrToInt(Edit43->Text)+","+h+",'"+Edit45->Text+"')";
Query6->Active=false;
Query6->SQL->Text=str;
Query6->ExecSQL();
str="select * from 课程表";
Query6->SQL->Text=str;
Query6->Active=true;
str="alter table 学习情况表 add "+Edit40->Text+" VARCHAR(2)";
Query2->Active=false;
Query2->SQL->Text=str;
Query2->ExecSQL();
ComboBox1->Items->Add(Edit40->Text);
ComboBox3->Items->Add(Edit40->Text);
ShowMessage("添加成功!");
}
}
}
else
{
ShowMessage("请输入学号!");
str="select * from 课程表";
Query6->SQL->Text=str;
Query6->Active=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button21Click(TObject *Sender)
{
int i,k=0,a;
String str;
if(Edit40->Text!="")
{
Query2->SQL->Text="select * from 学习情况表";
Query2->Active=true;
for(i=0;i<Query2->Fields->Count;i++)
if(Query2->Fields->Fields[i]->FieldName==Edit40->Text)
{k=1;break;}
if(k==1)
{
a=Application->MessageBoxA("你要删除该门课程吗?","提示框",65);
if(a==1)
{
str="delete from 课程表 where 课程名='"+Edit40->Text+"'";
Query6->Active=false;
Query6->SQL->Text=str;
Query6->ExecSQL();
str="select * from 课程表";
Query6->SQL->Text=str;
Query6->Active=true;
str="alter table 学习情况表 drop column "+Edit40->Text;
Query2->Active=false;
Query2->SQL->Text=str;
Query2->ExecSQL();
Query2->SQL->Text="select * from 学习情况表";
Query2->Active=true;
ComboBox1->Items->Clear();
ComboBox3->Items->Clear();
for(i=1;i<Query2->Fields->Count;i++)
{
ComboBox1->Items->Add(Query2->Fields->Fields[i]->FieldName);
ComboBox3->Items->Add(Query2->Fields->Fields[i]->FieldName);
}
ShowMessage("删除成功!");
}
}
else
{
ShowMessage("不存在该课程,请重新输入!");
return;
}
}
else
{
str="select * from 课程表";
Query6->SQL->Text=str;
Query6->Active=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::S1Click(TObject *Sender)
{
if(SaveDialog1->Execute())
{
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button23Click(TObject *Sender)
{
String str;
int a;
a=Application->MessageBoxA("你要确定修改吗?","主界面程序",65);
if(a==1)
{
Query2->Active=false;
str="update 学生基本信息表 set 姓名='"+DBEdit1->Text+"',性别='"+DBComboBox1->Text+"',民族='"+DBEdit3->Text+"',籍贯='"+DBEdit4->Text+"',家庭住址='"+DBEdit8->Text+"',家庭电话='"+DBEdit5->Text+"',政治面貌='"+DBEdit6->Text+"' where 学号='"+str10+"'";
Query2->SQL->Text=str;
Query2->ExecSQL();
str="update 在校信息表 set 班级='"+DBEdit7->Text+"',手机号='"+DBEdit9->Text+"',寝室号='"+DBEdit10->Text+"',寝室电话='"+DBEdit11->Text+"',班级职务='"+DBEdit12->Text+"',学生会职务='"+DBEdit13->Text+"' where 学号='"+str10+"'";
Query3->SQL->Text=str;
Query3->ExecSQL();
str="select * from 学生基本信息表 where 学号='"+str10+"'";
Query1->SQL->Text=str;
Query1->Active=true;
Query3->Active=false;
str="select * from 在校信息表 where 学号='"+str10+"'";
Query3->SQL->Text=str;
Query3->Active=true;
ShowMessage("修改成功!");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DBEdit1Change(TObject *Sender)
{
if(DBEdit1->Text!="")
{
Button23->Enabled=true;
Button3->Enabled=true;
Button5->Enabled=true;
}
else
{
Button23->Enabled=false;
Button3->Enabled=false;
Button5->Enabled=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button24Click(TObject *Sender)
{
ListBox2->DeleteSelected();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit18Change(TObject *Sender)
{
String str,str1;
Query4->Active=false;
Query4->SQL->Text="select * from 学生基本信息表 where 学号='"+Edit18->Text+"'";
Query4->Active=true;
if(Query4->Fields->FindField("学号")->AsString==Edit18->Text)
{
Button13->Enabled=true;
Button9->Enabled=true;
Edit19->Text=Query4->Fields->FieldByName("姓名")->AsString;
if(Query4->Fields->FieldByName("性别")->AsString=="男")
ComboBox2->ItemIndex=0;
if(Query4->Fields->FieldByName("性别")->AsString=="女")
ComboBox2->ItemIndex=1;
Edit21->Text=Query4->Fields->FieldByName("民族")->AsString;
Edit22->Text=Query4->Fields->FieldByName("籍贯")->AsString;
Edit23->Text=Query4->Fields->FieldByName("政治面貌")->AsString;
Edit24->Text=Query4->Fields->FieldByName("家庭住址")->AsString;
Edit25->Text=Query4->Fields->FieldByName("家庭电话")->AsString;
Edit26->Text=Query4->Fields->FieldByName("爱好")->AsString;
Edit27->Text=Query4->Fields->FieldByName("备注")->AsString;
str=Query4->Fields->FieldByName("照片")->AsString;
if(str!="")
{
Image2->Picture->LoadFromFile(str);
Image2->Show();
Button12->Enabled=true;
}
else
{
Button12->Enabled=false;
Image2->Visible=false;
}
}
else
{
Button13->Enabled=false;
Button9->Enabled=false;
Button12->Enabled=false;
Image2->Hide();
Edit19->Text="";
ComboBox2->ItemIndex=-1;
Edit21->Text="";
Edit22->Text="";
Edit23->Text="";
Edit24->Text="";
Edit25->Text="";
Edit26->Text="";
Edit27->Text="";
}
if(Edit18->Text=="")
{
Button13->Enabled=false;
Button9->Enabled=false;
Button12->Enabled=false;
}
if(Edit19->Text!="")
{
Button9->Enabled=true;
Button10->Enabled=true;
Button11->Enabled=true;
Button12->Enabled=true;
Button13->Enabled=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button25Click(TObject *Sender)
{
int a;
if(Image1->Visible==true)
{
a=Application->MessageBoxA("你要删除该照片吗?","删除程序",65);
if(a==1)
{
Image1->Picture->CleanupInstance();
Image1->Visible=false;
Button25->Enabled=false;
}
}
else ShowMessage("没有照片,不能删除!");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DBGrid4CellClick(TColumn *Column)
{
Query7->MoveBy(0);
Edit18->Text=DBGrid4->Columns->Items[0]->Field->AsString;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DBGrid8CellClick(TColumn *Column)
{
Query6->MoveBy(0);
if(DBGrid8->Columns->Items[0]->Field->AsString!="")
Edit40->Text=DBGrid8->Columns->Items[0]->Field->AsString;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit40Change(TObject *Sender)
{
Edit40->Text=Query6->FieldByName("课程名")->AsString;
Edit41->Text=Query6->FieldByName("开课类别")->AsString;
Edit42->Text=Query6->FieldByName("开课学期")->AsString;
Edit43->Text=Query6->FieldByName("课时")->AsString;
Edit44->Text=Query6->FieldByName("学分")->AsString;
Edit45->Text=Query6->FieldByName("备注")->AsString;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DBGrid5CellClick(TColumn *Column)
{
Query5->MoveBy(0);
if(DBGrid5->Columns->Items[0]->Field->AsString!="")
{
Edit28->Text=DBGrid5->Columns->Items[0]->Field->AsString;
Edit29->Text=DBGrid5->Columns->Items[1]->Field->AsString;
Edit30->Text=DBGrid5->Columns->Items[2]->Field->AsString;
Edit31->Text=DBGrid5->Columns->Items[4]->Field->AsString;
Edit32->Text=DBGrid5->Columns->Items[3]->Field->AsString;
Edit33->Text=DBGrid5->Columns->Items[5]->Field->AsString;
Edit34->Text=DBGrid5->Columns->Items[6]->Field->AsString;
}
}
//---------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -