1,216
社区成员
发帖
与我相关
我的任务
分享
DataSet set1 = new DataSet("dsSource");
DataSet set2 = new DataSet("dsTarget");
adapter1.Fill(set1);
adapter1.FillSchema(set2, SchemaType.Mapped);
DataTable table1 = set1.Tables[0];
DataTable table2 = set2.Tables[0];
int num2 = table1.Rows.Count;
this.intPageCount = (int) Math.Round(Math.Ceiling(((double) num2) / PAGESIZE));
this.ViewState["PageCount"] = this.intPageCount;
for (int num1 = 1; ((((this.intCurPageIndex - 1) * PAGESIZE) + num1) <= num2) & (num1 <= PAGESIZE); num1++)
{
table2.ImportRow(table1.Rows[(((this.intCurPageIndex - 1) * PAGESIZE) + num1) - 1]);
}
this.dgDb.DataSource = table2.DefaultView;
this.dgDb.DataKeyField = "sender";
this.dgDb.DataBind();
Private Sub CmdAdd_Click()
Dim MemberID As Integer
Dim txtsql2 As String
Dim msgtext2 As String
txtsql2 = "select max(MemberID)+1 from MemberTable"
Set mrc2 = ExecuteSQL(txtsql2, msgtext2)
If mrc2.Fields(0) <> 0 Then
MemberID = mrc2.Fields(0)
Else
MemberID = 1
End If
mrc2.Close
Dim msgtext As String
If Not CmdAdd.Caption <> "添加学生" Then
CmdAdd.Caption = "更新"
CmdChange.Enabled = False
CmdDel.Enabled = False
TxtNo.Text = MemberID
TxtName.Text = ""
TxtTel.Text = ""
TxtDepartment.Text = ""
Else
If TestText(TxtName.Text) <> True Then
MsgBox "姓名不能为空!", , "提示"
Exit Sub
End If
If TestText(TxtTel.Text) = False Then
MsgBox "联系电话不能为空!", , "提示"
Exit Sub
End If
If TestText(TxtDepartment.Text) = False Then
MsgBox "班级不能为空!", , "提示"
Exit Sub
End If
If TestText(TxtPay.Text) = False Then
MsgBox "缴费不能为空!", , "提示"
Exit Sub
End If
Dim txtsql As String
txtsql = "select MemberID,MemberName,Sex,TelNO,Department,Pay from MemberTable"
Set mrc = ExecuteSQL(txtsql, msgtext)
While (mrc.EOF = False)
If (Trim(mrc.Fields(0)) = Trim(TxtName.Text)) Then
MsgBox "用户名已经存在", vbOKOnly + vbExclamation, "警告"
Exit Sub
TxtName.Text = ""
TxtName.SetFocus
Else
mrc.MoveNext
End If
Wend
mrc.AddNew
mrc.Fields(0) = MemberID
mrc.Fields(1) = Trim(TxtName.Text)
If OptBoy.value = True Then
mrc.Fields(2) = "男"
Else
mrc.Fields(2) = "女"
End If
mrc.Fields(3) = Trim(TxtTel.Text)
mrc.Fields(4) = Trim(TxtDepartment.Text)
mrc.Fields(5) = Trim(TxtPay.Text)
mrc.Update
If MsgBox("添加学生" & TxtName.Text & "成功!", vbOKOnly + vbExclamation, "提示") Then
Adodc1.Refresh
End If
mrc.Close
CmdChange.Enabled = True
CmdDel.Enabled = True
CmdAdd.Caption = "添加学生"
End If
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
On Error GoTo b
If flag_change = True Then
If Adodc1.Recordset.EOF = False Then
TxtNo.Text = Adodc1.Recordset.Fields(0)
TxtName.Text = Adodc1.Recordset.Fields(1)
TxtTel.Text = Adodc1.Recordset.Fields(3)
TxtDepartment.Text = Adodc1.Recordset.Fields(4)
TxtPay.Text = Adodc1.Recordset.Fields(5)
If Not Adodc1.Recordset.Fields(2) <> "男" Then
OptBoy.value = True
Else
OptGirl.value = True
End If
End If
End If
b:
End Sub
Private Sub Form_Load()
flag_change = True
If conn = True Then
Adodc1.ConnectionString = SQLconn
ConnectString SQLconn
Else
Adodc1.ConnectionString = ACCESSconn
ConnectString ACCESSconn
End If
Adodc1.RecordSource = "select MemberID as 学生编号,MemberName as 姓名,Sex as 性别,TelNO as 联系电话,Department as 班级,Pay as 缴费 from MemberTable"
Adodc1.Refresh
If Adodc1.Recordset.EOF = False Then
TxtNo.Text = Adodc1.Recordset.Fields(0)
TxtName.Text = Adodc1.Recordset.Fields(1)
TxtTel.Text = Adodc1.Recordset.Fields(3)
TxtDepartment.Text = Adodc1.Recordset.Fields(4)
If Not Adodc1.Recordset.Fields(2) <> "男" Then
OptBoy.value = True
Else
OptGirl.value = True
End If
TxtPay.Text = Adodc1.Recordset.Fields(5)
End If
End Sub