C语言 编写一个宿舍管理查询系统数据结构的课程设计
发布网友
发布时间:2024-10-06 14:32
我来回答
共1个回答
热心网友
时间:2024-11-03 01:20
宿舍管理源代码
procere TDormForm.BitBtn1Click(Sender: TObject);
begin
if edit1.Text='' then
begin
messagedlg('请输入寝室号!',mtinformation,[mbok],0);
exit;
end;
if edit2.Text='' then
begin
messagedlg('请输入寝室应住人数!',mtinformation,[mbok],0);
exit;
end;
if edit4.Text='' then
begin
messagedlg('请为该寝室确定住宿费用!',mtinformation,[mbok],0);
exit;
end;
if ComboBox2.Text='' then
begin
messagedlg('请选择居住性别!',mtinformation,[mbok],0);
exit;
end;
//检查系统中是否存在该寝室号
datamd.ADODorm.Close ;
datamd.ADODorm.SQL.Clear ;
datamd.ADODorm.SQL.Text:='select Dor_Id from Dorm where Dor_Id='''+Edit1.Text+'''';
datamd.ADODorm.Prepared ;
datamd.ADODorm.Open ;
if not datamd.ADODorm.IsEmpty then
begin
MessageBox(handle,'该寝室号已录入!','警告',MB_OK+MB_ICONWARNING);
Edit1.SetFocus ;
exit;
end;
//寝室信息录入
datamd.ADODorm.Close ;
datamd.ADODorm.SQL.Clear ;
datamd.ADODorm.SQL.Add('select * from dorm');
datamd.ADODorm.Open ;
datamd.ADODorm.Insert;
datamd.ADODorm.FieldByName('Dor_Id').AsString:=trim(edit1.Text);
datamd.ADODorm.FieldByName('Dor_Num').AsString:=trim(edit2.Text);
datamd.ADODorm.FieldByName('Dor_Price').AsString:=trim(edit4.Text); datamd.ADODorm.FieldByName('Dor_sex').AsString:=trim(ComboBox2.Text);
datamd.ADODorm.FieldByName('Dor_Tel').AsString:=trim(edit5.Text);
datamd.ADODorm.FieldByName('Dor_Des').AsString:=trim(edit6.Text); datamd.ADODorm.Post;
ShowMessage('宿舍信息插入完毕!');
edit1.Text:='';
edit2.Text:='';
edit4.Text:='';
edit5.Text:='';
edit6.Text:='';
end;
procere TDormForm.BitBtn2Click(Sender: TObject);
begin
close;
end;
procere TDormForm.FormShow(Sender: TObject);
begin
datamd.ADODorm.Close ;
datamd.ADODorm.SQL.Clear ;
datamd.ADODorm.SQL.Add('select * from dorm order by dor_id asc' );
datamd.ADODorm.Open ;
end;
end.