请教编程高手一个简单的小程序
发布网友
发布时间:2022-07-15 03:30
我来回答
共4个回答
热心网友
时间:2023-11-18 14:20
建议你用VB编写一个带数据库的程序,那样简单方便。
相关代码相关控件代码
Private Sub Cmdadd_Click()(添加控件)
Adodc1.Recordset.AddNew
For i = 0 To 6
Text1(i).Enabled = True
Text1(i).Text = ""
Next i
Text1(0).SetFocus
Cmdadd.Enabled = False
Cmddelete.Enabled = False
Cmdmodify.Enabled = False
Cmdsave.Enabled = True
End Sub
Private Sub Cmddelete_Click()(删除控件)
Dim myval As String
myval = MsgBox("是否要删除记录?", vbYesNo)
If myval = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
For i = 0 To 6
Text1(i).Enabled = False
Next i
End If
End Sub
Private Sub Cmdexit_Click()(退出控件)
Unload Me
End Sub
Private Sub Cmdmodify_Click()(修改控件)
If Adodc1.Recordset.RecordCount <> 0 Then
Text1(0).Enabled = False
For i = 1 To 6
Text1(i).Enabled = True
Next i
Cmdsave.Enabled = True
Cmdadd.Enabled = False
Cmddelete.Enabled = False
Cmdmodify.Enabled = False
End If
End Sub
Private Sub Cmdsave_Click()(保存控件)
If Text1(0).Text = "" Then
MsgBox "学号不允许为空!"
Exit Sub
End If
If Text1(1).Text = "" Then
MsgBox "姓名不允许为空!"
Exit Sub
End If
If Text1(3).Text = "" Then
MsgBox "出生日期不允许为空!"
Exit Sub
End If
Adodc1.Recordset.Update
For i = 0 To 6
Text1(i).Enabled = False
Next i
Cmdsave.Enabled = False
Cmdadd.Enabled = ture
Cmddelete.Enabled = True
Cmdmodify.Enabled = True
查询控件代码
If Left((Text1.Text), 1) <> "S" Then
MsgBox "学号格式输入错误!!"
ElseIf Len((Text1.Text)) <> 8 Then
MsgBox "学号长度错误!"
Else
Adodc1.RecordSource = "select * from VIEW_cj where 学号=" + Chr(39) + Text1.Text + Chr(39) + " "
Adodc1.Refresh
End If
热心网友
时间:2023-11-18 14:21
#include <iostream.h>
#include <string.h>
struct node
{
float no; /*学号*/
char name[8]; /*姓名*/
float cj1; /*成绩1*/
float cj2; /*成绩2*/
float cj3; /*成绩3*/
float zf; /*总分*/
float pj; /*平均分*/
node *next;
};
node *student,*top,*head;
node *Create(node *student)//建立单链表(从键盘输入数据或从文件读入数据)
{
node *Ttemp;
char Tname[8];float Tcj1,Tcj2,Tcj3,Tno,Tmake=1;
student=new node;
student->next=NULL;head=top=student;
cout<<"输入学号,姓名,成绩1,成绩2,成绩3,成绩4\n";
while (Tmake)
{
cout<<"学号:";cin>>Tno;cout<<"姓名:";cin>>Tname;cout<<"成绩1:";cin>>Tcj1;
cout<<"成绩2:";cin>>Tcj2;cout<<"成绩3:";cin>>Tcj3;cout<<endl;
cout<<"是否继续添加学生('0'结束 '1'继续)";cin>>Tmake;
Ttemp=new node;
Ttemp->no=Tno;
strcpy(Ttemp->name,Tname);
Ttemp->cj1=Tcj1;Ttemp->cj2=Tcj2;Ttemp->cj3=Tcj3;
Ttemp->next=NULL;
top->next=Ttemp;top=Ttemp;
}
return student;
}
void Chang() //计算每个结点总分与平均分并存入结点中
{
node *total=head;
while(total->next!=NULL)
{
total->next->zf=total->next->cj1+total->next->cj2+total->next->cj3;
total->next->pj=total->next->zf/3;total=total->next;
}
}
void Append() //在单链表中插入结点
{
char Aname[8];float Acj1,Acj2,Acj3,Ano;
node *Atemp=new node;
cout<<"学号:";cin>>Ano;cout<<"姓名:";cin>>Aname;cout<<"成绩1:";cin>>Acj1;
cout<<"成绩2:";cin>>Acj2;cout<<"成绩3:";cin>>Acj3;cout<<endl;
Atemp=new node;Atemp->no=Ano;
strcpy(Atemp->name,Aname);
Atemp->cj1=Acj1;Atemp->cj2=Acj2;Atemp->cj3=Acj3;
Atemp->next=NULL;
top->next=Atemp;top=Atemp;
}
void Delete() //删除指定学号或姓名的结点
{
热心网友
时间:2023-11-18 14:21
可以用access或者sql server加.net做,很快的。
热心网友
时间:2023-11-18 14:22
想和你讨论