|
|
Public Class frmMain |
|
Private ColEmployee As New EmployeeCollection |
Private IsIDChanged As Boolean = False |
|
|
|
Private Sub TextBoxclear() |
txtID.Text = "" |
txtName.Text = "" |
txtBirthday.Text = "" |
cmbPost.Text = "" |
End Sub |
|
|
|
Private Sub cmdEntry_Click(ByVal sender As System.Object, |
ByVal e As System.EventArgs) _ |
Handles cmdEntry.Click |
If IsCheckedValidation(sender) = False Then Exit Sub |
Dim oDataService As New DataService |
ColEmployee.Add(txtID.Text, |
txtName.Text, |
CDate(txtBirthday.Text), |
oDataService.PostName_to_PostID(cmbPost.Text)) |
ListUpdate() |
TextBoxclear() |
End Sub |
|
|
|
Private Sub cmdExit_Click(ByVal sender As System.Object, |
ByVal e As System.EventArgs) _ |
Handles cmdExit.Click |
End |
End Sub |
|
|
|
Private Sub cmdDelete_Click(ByVal sender As System.Object, |
ByVal e As System.EventArgs) _ |
Handles cmdDelete.Click |
If IsCheckedValidation(sender) = False Then Exit Sub |
If MessageBox.Show("本当に削除してよろしいですか?", |
"操作の確認", |
MessageBoxButtons.YesNo, |
MessageBoxIcon.Question) = vbNo Then Exit Sub |
Dim oDataService As New DataService |
Dim TargetEmployee As New Employee With { |
.ID = CType(txtID.Text, Integer) |
} |
ColEmployee.Remove(TargetEmployee) |
ListUpdate() |
TextBoxclear() |
End Sub |
|
|
|
Private Sub cmdUpdate_Click(ByVal sender As System.Object, |
ByVal e As System.EventArgs) _ |
Handles cmdUpdate.Click |
If IsCheckedValidation(sender) = False Then Exit Sub |
If MessageBox.Show("本当に更新してよろしいですか?", |
"操作の確認", |
MessageBoxButtons.YesNo, |
MessageBoxIcon.Question) = vbNo Then Exit Sub |
Dim oDataService As New DataService |
Dim TargetEmployee As New Employee With { |
.ID = CType(txtID.Text, Integer), |
.Name = txtName.Text, |
.Birthday = CType(txtBirthday.Value, Date), |
.PostID = oDataService.PostName_to_PostID(cmbPost.Text) |
} |
ColEmployee.Update(TargetEmployee) |
ListUpdate() |
TextBoxclear() |
End Sub |
|
|
|
Private Sub frmMain_Load(ByVal sender As Object, |
ByVal e As System.EventArgs) Handles Me.Load |
|
Dim dgvTextBoxColumn_ID As New DataGridViewTextBoxColumn |
With dgvTextBoxColumn_ID |
.HeaderText = "ID" |
.Width = 55 |
End With |
|
Dim dgvTextBoxColumn_Name As New DataGridViewTextBoxColumn |
dgvTextBoxColumn_Name.HeaderText = "氏名" |
|
Dim dgvTestBoxColumn_Birthday As New DataGridViewTextBoxColumn |
With dgvTestBoxColumn_Birthday |
.HeaderText = "生年月日" |
.Width = 80 |
End With |
|
Dim dgvTestBoxColumn_Age As New DataGridViewTextBoxColumn |
With dgvTestBoxColumn_Age |
.HeaderText = "年齢" |
.Width = 55 |
.DefaultCellStyle.Alignment = |
DataGridViewContentAlignment.MiddleRight |
End With |
|
Dim dgvTestBoxColumn_Post As New DataGridViewTextBoxColumn |
With dgvTestBoxColumn_Post |
.HeaderText = "所属部署" |
.Width = 100 |
End With |
|
With dgvEntryList.Columns |
.Add(dgvTextBoxColumn_ID) |
.Add(dgvTextBoxColumn_Name) |
.Add(dgvTestBoxColumn_Birthday) |
.Add(dgvTestBoxColumn_Age) |
.Add(dgvTestBoxColumn_Post) |
End With |
With dgvEntryList |
.SelectionMode = DataGridViewSelectionMode.FullRowSelect |
.AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue |
.RowHeadersVisible = False |
End With |
|
Dim oDataService As New DataService |
With cmbPost.Items |
.Add(oDataService.PostID_to_PostName(DataService.PostNos.Soumu)) |
.Add(oDataService.PostID_to_PostName(DataService.PostNos.KeieiKikaku)) |
.Add(oDataService.PostID_to_PostName(DataService.PostNos.Jigyo)) |
End With |
ListUpdate() |
End Sub |
|
|
|
Private Sub MenuItemEnd_Click(ByVal sender As System.Object, |
ByVal e As System.EventArgs) _ |
Handles MenuItemEnd.Click |
cmdExit_Click(sender, e) |
End Sub |
|
|
|
Private Sub ListUpdate() |
dgvEntryList.Rows.Clear() |
Dim oDataService As New DataService |
Dim rs = From o As Employee In ColEmployee |
Order By o.ID Ascending |
For Each v As Employee In rs |
dgvEntryList.Rows.Add(v.ID, |
v.Name, |
CType(v.Birthday, String), |
v.Age, |
oDataService.PostID_to_PostName(v.PostID)) |
Next |
ToolStripStatusLabel1.Text = "登録者数 : " & ColEmployee.Count |
|
If ColEmployee.Count = 0 Then |
ToolStripStatusLabel2.Text = "" |
Else |
ToolStripStatusLabel2.Text = "平均年齢 : " & |
Format(ColEmployee.AveAge, "0.0歳") |
End If |
End Sub |
|
|
|
Private Sub dgvEntryList_Click(ByVal sender As Object, |
ByVal e As System.EventArgs) _ |
Handles dgvEntryList.Click |
If dgvEntryList.Rows.Count = 0 Then Exit Sub |
txtID.Text = |
CType(dgvEntryList.SelectedRows(0).Cells(0).Value, String) |
IsIDChanged = False |
txtName.Text = |
CType(dgvEntryList.SelectedRows(0).Cells(1).Value, String) |
txtBirthday.Text = |
CType(dgvEntryList.SelectedRows(0).Cells(2).Value, String) |
cmbPost.Text = |
CType(dgvEntryList.SelectedRows(0).Cells(4).Value, String) |
End Sub |
|
|
|
Private Sub txtID_TextChanged(ByVal sender As System.Object, |
ByVal e As System.EventArgs) _ |
Handles txtID.TextChanged |
IsIDChanged = True |
End Sub |
|
|
|
Private Function IsCheckedValidation(ByVal sender As System.Object) _ |
As Boolean |
Dim Response As Boolean = False |
Select Case CType(sender, Button).Name |
Case "cmdEntry" |
|
If txtID.Text = |
"" Or txtName.Text = "" Or txtBirthday.Text = "" Then |
MessageBox.Show("必須項目が入力されていません。", |
"入力確認", |
MessageBoxButtons.OK, |
MessageBoxIcon.Error) |
Response = False |
Return Response |
Exit Function |
Else |
Response = True |
End If |
Case "cmdDelete" |
|
If txtID.Text = "" Then |
MessageBox.Show("削除する対象が選択されていません。", |
"操作確認", |
MessageBoxButtons.OK, |
MessageBoxIcon.Error) |
Response = False |
Return Response |
Exit Function |
Else |
Response = True |
End If |
If IsIDChanged = True Then |
MessageBox.Show("IDが変更されています。", |
"操作確認", |
MessageBoxButtons.OK, |
MessageBoxIcon.Error) |
txtID.Text = |
dgvEntryList.SelectedRows(0).Cells(0).Value.ToString |
Response = False |
Return Response |
Exit Function |
Else |
Response = True |
End If |
Case "cmdUpdate" |
|
If txtID.Text = "" Then |
MessageBox.Show("更新する対象が選択されていません。", |
"操作確認", |
MessageBoxButtons.OK, |
MessageBoxIcon.Error) |
Response = False |
Return Response |
Exit Function |
Else |
Response = True |
End If |
If IsIDChanged = True Then |
MessageBox.Show("IDが変更されています。", |
"操作確認", |
MessageBoxButtons.OK, |
MessageBoxIcon.Error) |
txtID.Text = |
dgvEntryList.SelectedRows(0).Cells(0).Value.ToString |
Response = False |
Return Response |
Exit Function |
Else |
Response = True |
End If |
Case Else |
Response = True |
End Select |
Return Response |
End Function |
End Class |
kobe shoes
返信削除off white nike
goyard store
kyrie 8
fear of god outlet
kd shoes
jordan shoes
yeezys
bape clothing
curry 8