📄 calendar.vb
字号:
Public Class calendar
Dim db_cmd As New System.Data.SqlServerCe.SqlCeCommand
Dim db_adp As System.Data.SqlServerCe.SqlCeDataAdapter
Dim DT_daily As System.Data.DataTable = New System.Data.DataTable("Daily")
Dim DT_row As System.Data.DataRow
Public year, month, day As Integer
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Form2.Show()
Me.Hide()
End Sub
Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
Dim time As Date
time = MonthCalendar1.SelectionStart
year = time.Year
month = time.Month
day = time.Day
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer = -1
db_cmd.CommandText = "select * from Daily where " & "(W_year = ' " & year & " ') AND (W_month = ' " & month & " ') AND (W_day = ' " & day & " ')"
db_cmd.Connection = db_c
db_adp = New System.Data.SqlServerCe.SqlCeDataAdapter(db_cmd)
DT_daily.Clear()
db_adp.Fill(DT_daily)
For Each DT_row In DT_daily.Rows
i += 1
If i >= 0 Then
Exit For
End If
Next
If i < 0 Then
TextBox1.Text = "没有日记"
Else
TextBox1.Text = month.ToString + "/" + day.ToString + "/" + year.ToString + vbCrLf + DT_daily.Rows(0)("M_mood").ToString + vbCrLf + DT_daily.Rows(0)("Weather") + vbCrLf + DT_daily.Rows(0)("M_daily")
End If
i = -1
End Sub
Private Sub calendar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
year = DateTime.Now.Year
month = DateTime.Now.Month
day = DateTime.Now.Day
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Dim i As Integer = -1
db_cmd.CommandText = "select * from Daily where " & "(W_year = ' " & year & " ') AND (W_month = ' " & month & " ') AND (W_day = ' " & day & " ')"
db_cmd.Connection = db_c
db_adp = New System.Data.SqlServerCe.SqlCeDataAdapter(db_cmd)
DT_daily.Clear()
db_adp.Fill(DT_daily)
For Each DT_row In DT_daily.Rows
i += 1
If i >= 0 Then
Exit For
End If
Next
If i < 0 Then
MsgBox("没有日记")
Else
See.Text = year.ToString + "-" + month.ToString + "-" + day.ToString
See.TextBox1.Text = year.ToString + "-" + month.ToString + "-" + day.ToString
See.TextBox3.Text = DT_daily.Rows(0)("M_mood").ToString
See.TextBox2.Text = DT_daily.Rows(0)("Weather").ToString
See.DBrowsew.Text = DT_daily.Rows(0)("M_daily").ToString
See.TextBox4.Text = WhichWeek(DT_daily.Rows(0)("W_year"), DT_daily.Rows(0)("W_month"), DT_daily.Rows(0)("W_day"))
See.Show()
End If
i = -1
End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
Dim i As Integer = -1
rewrite.year = year
rewrite.month = month
rewrite.day = day
rewrite.YearBox.Text = rewrite.year.ToString
rewrite.MonthBox.Text = rewrite.month.ToString
rewrite.DayBox.Text = rewrite.day.ToString
db_cmd.CommandText = "select * from Daily where " & "(W_year = ' " & year & " ') AND (W_month = ' " & month & " ') AND (W_day = ' " & day & " ')"
db_cmd.Connection = db_c
db_adp = New System.Data.SqlServerCe.SqlCeDataAdapter(db_cmd)
DT_daily.Clear()
db_adp.Fill(DT_daily)
For Each DT_row In DT_daily.Rows
i += 1
If i >= 0 Then
Exit For
End If
Next
If i < 0 Then
MsgBox("没有日记")
Else
rewrite.Weather1.Text = DT_daily.Rows(0)("Weather").ToString
rewrite.weather = DT_daily.Rows(0)("Weather").ToString
rewrite.TextBox1.Text = DT_daily.Rows(0)("M_daily").ToString
rewrite.moodBox.Text = DT_daily.Rows(0)("M_mood").ToString
rewrite.TextBox2.Text = WhichWeek(DT_daily.Rows(0)("W_year"), DT_daily.Rows(0)("W_month"), DT_daily.Rows(0)("W_day"))
rewrite.Button1.Enabled = True
rewrite.Button2.Enabled = True
rewrite.Show()
End If
i = -1
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -