⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 look.vb

📁 windows mobile下的一个东西
💻 VB
字号:
Public Class look

    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

    Dim year, month, day, D_ID As Integer

    Private Sub MenuItem2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click '写日记
        write.Button1.Enabled = True
        write.Button2.Enabled = True
        write.Button3.Visible = False
        write.Button2.Visible = True
        write.MenuItem5.Enabled = True
        write.Show()
        Me.Hide()
    End Sub

    Private Sub MenuItem6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click '返回
        Form2.Show()
        Me.Hide()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '查看
        Dim C_year, C_month, C_day, D_ID As Integer
        Dim C_weather As String
        C_year = 0
        C_month = 0
        C_day = 0
        C_year = DataGrid1.Item(DataGrid1.CurrentRowIndex, 0)
        C_month = DataGrid1.Item(DataGrid1.CurrentRowIndex, 1)
        C_day = DataGrid1.Item(DataGrid1.CurrentRowIndex, 2)
        C_weather = DataGrid1.Item(DataGrid1.CurrentRowIndex, 3)
        D_ID = DataGrid1.Item(DataGrid1.CurrentRowIndex, 4)
        See.TextBox1.Text = C_year.ToString + "-" + C_month.ToString + "-" + C_day.ToString
        See.TextBox2.Text = C_weather

        db_cmd.CommandText = "select * from Daily where M_ID = '" & D_ID & "'"
        db_cmd.Connection = db_c
        db_adp = New System.Data.SqlServerCe.SqlCeDataAdapter(db_cmd)
        DT_daily.Clear()
        db_adp.Fill(DT_daily)


        See.Text = C_year.ToString + "-" + C_month.ToString + "-" + C_day.ToString
        See.TextBox3.Text = DT_daily.Rows(0)("M_mood").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 Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click '修改

        Dim C_year, C_month, C_day As Integer
        Dim C_weather As String
        C_year = 0
        C_month = 0
        C_day = 0
        C_year = DataGrid1.Item(DataGrid1.CurrentRowIndex, 0)
        C_month = DataGrid1.Item(DataGrid1.CurrentRowIndex, 1)
        C_day = DataGrid1.Item(DataGrid1.CurrentRowIndex, 2)
        C_weather = DataGrid1.Item(DataGrid1.CurrentRowIndex, 3)
        rewrite.D_ID = DataGrid1.Item(DataGrid1.CurrentRowIndex, 4)
        rewrite.year = C_year
        rewrite.month = C_month
        rewrite.day = C_day
        rewrite.weather = C_weather
        rewrite.YearBox.Text = rewrite.year.ToString
        rewrite.MonthBox.Text = rewrite.month.ToString
        rewrite.DayBox.Text = rewrite.day.ToString
        rewrite.Weather1.Text = rewrite.weather
        db_cmd.CommandText = "select * from Daily where (M_ID = ' " & rewrite.D_ID & " ')"
        db_cmd.Connection = db_c
        db_adp = New System.Data.SqlServerCe.SqlCeDataAdapter(db_cmd)
        DT_daily.Clear()
        db_adp.Fill(DT_daily)
        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 Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click '删除
        Dim ask As Boolean
        ask = MsgBox("确定删除?", MsgBoxStyle.YesNo)
        If ask = True Then
            D_ID = DataGrid1.Item(DataGrid1.CurrentRowIndex, 4)
            db_cmd.CommandText = "DELETE from Daily WHERE (M_ID = ' " & D_ID & " ')"
            db_cmd.Connection = db_c
            db_cmd.Connection.Open()
            db_cmd.ExecuteNonQuery()
            db_cmd.Connection.Close()
            MsgBox("删除成功", MsgBoxStyle.OkOnly)
        End If

        db_cmd.CommandText = "select W_year,W_month,W_day,Weather,M_ID From Daily"
        db_cmd.Connection = db_c
        db_adp = New System.Data.SqlServerCe.SqlCeDataAdapter(db_cmd)
        DT_daily.Clear()
        db_adp.Fill(DT_daily)

        DataGrid1.Visible = False
        DataGrid1.DataSource = DT_daily
        DataGrid1.Visible = True
        DataGrid1.Refresh()

    End Sub

    Private Sub look_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'TODO: 这行代码将数据加载到表“DailyDataSet1.Daily”中。您可以根据需要移动或移除它。
        Me.DailyTableAdapter.Fill(Me.DailyDataSet.Daily)

        Dim y(1000) As Integer
        Dim i As Integer = 0
        Dim j As Integer
        Dim flag As Boolean = False
        Yearselect.Items.Clear()

        db_cmd.CommandText = "select W_year,W_month,W_day,Weather,M_ID from Daily where W_year>=1980 ORDER BY W_year ASC"
        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
            If i = 0 Then
                Yearselect.Items.Add(DT_row("W_year"))
                y(0) = DT_row("W_year")
                i += 1
            Else
                For j = 0 To i - 1 Step 1
                    If y(j) = DT_row("W_year") Then
                        flag = True
                    End If
                Next
                If flag = True Then
                    flag = False
                Else
                    Yearselect.Items.Add(DT_row("W_year"))
                    y(i) = DT_row("W_year")
                    i += 1
                End If
            End If
        Next

    End Sub




    Public Sub New()

        ' 此调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        ' 在 InitializeComponent() 调用之后添加任何初始化。

        'DataGrid1.TableStyles.Clear()
        DataGrid1.BackColor = Color.Wheat
        DataGrid1.GridLineColor = Color.Black
        DataGrid1.TableStyles.Add(ModifyDTGColumn(51, 62))

    End Sub

    Private Sub Yearselect_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Yearselect.SelectedIndexChanged
        year = Val(Yearselect.Text.ToString)
        Dim m(12) As Integer
        Dim i As Integer = 0
        Dim j As Integer
        Dim flag As Boolean = False
        Monthselect.Items.Clear()

        db_cmd.CommandText = "select W_year,W_month,W_day,Weather,M_ID from Daily where(W_year = ' " & year & " ') ORDER BY W_month ASC"
        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
            If i = 0 Then
                Monthselect.Items.Add(DT_row("W_month"))
                m(0) = DT_row("W_month")
                i += 1
            Else
                For j = 0 To i - 1 Step 1
                    If m(j) = DT_row("W_month") Then
                        flag = True
                    End If
                Next
                If flag = True Then
                    flag = False
                Else
                    Monthselect.Items.Add(DT_row("W_month"))
                    m(i) = DT_row("W_month")
                    i += 1
                End If
            End If
        Next
        DataGrid1.Visible = False
        DataGrid1.DataSource = DT_daily
        DataGrid1.Visible = True
        DataGrid1.Refresh()
    End Sub

    Private Sub Monthselect_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Monthselect.SelectedIndexChanged
        month = Val(Monthselect.Text.ToString)
        Dim d(33) As Integer
        Dim i As Integer = 0
        Dim j As Integer
        Dim flag As Boolean = False
        Dayselect.Items.Clear()

        db_cmd.CommandText = "select W_year,W_month,W_day,Weather,M_ID from Daily where " & "(W_year = ' " & year & " ') AND (W_month = ' " & month & " ') ORDER BY W_day ASC"
        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
            If i = 0 Then
                Dayselect.Items.Add(DT_row("W_day"))
                d(0) = DT_row("W_day")
                i += 1
            Else
                For j = 0 To i - 1 Step 1
                    If d(j) = DT_row("W_day") Then
                        flag = True
                    End If
                Next
                If flag = True Then
                    flag = False
                Else
                    Dayselect.Items.Add(DT_row("W_day"))
                    d(i) = DT_row("W_day")
                    i += 1
                End If
            End If
        Next
        DataGrid1.Visible = False
        DataGrid1.DataSource = DT_daily
        DataGrid1.Visible = True
        DataGrid1.Refresh()
    End Sub

    Private Sub Dayselect_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dayselect.SelectedIndexChanged
        day = Val(Dayselect.Text.ToString)
        db_cmd.CommandText = "select W_year,W_month,W_day,Weather,M_ID from Daily where " & "(W_year = ' " & year & " ') AND (W_month = ' " & month & " ') AND (W_day = ' " & day & " ') ORDER BY M_ID ASC"
        db_cmd.Connection = db_c
        db_adp = New System.Data.SqlServerCe.SqlCeDataAdapter(db_cmd)
        DT_daily.Clear()
        db_adp.Fill(DT_daily)

        DataGrid1.Visible = False
        DataGrid1.DataSource = DT_daily
        DataGrid1.Visible = True
        DataGrid1.Refresh()
    End Sub

    Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click '查看
        Dim C_year, C_month, C_day, D_ID As Integer
        Dim C_weather As String
        C_year = 0
        C_month = 0
        C_day = 0
        C_year = DataGrid1.Item(DataGrid1.CurrentRowIndex, 0)
        C_month = DataGrid1.Item(DataGrid1.CurrentRowIndex, 1)
        C_day = DataGrid1.Item(DataGrid1.CurrentRowIndex, 2)
        C_weather = DataGrid1.Item(DataGrid1.CurrentRowIndex, 3)
        D_ID = DataGrid1.Item(DataGrid1.CurrentRowIndex, 4)
        See.TextBox1.Text = C_year.ToString + "-" + C_month.ToString + "-" + C_day.ToString
        See.TextBox2.Text = C_weather

        db_cmd.CommandText = "select * from Daily where M_ID = '" & D_ID & "'"
        db_cmd.Connection = db_c
        db_adp = New System.Data.SqlServerCe.SqlCeDataAdapter(db_cmd)
        DT_daily.Clear()
        db_adp.Fill(DT_daily)

        See.Text = C_year.ToString + "-" + C_month.ToString + "-" + C_day.ToString
        See.TextBox3.Text = DT_daily.Rows(0)("M_mood").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 Sub

    Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click '修改
        Dim C_year, C_month, C_day As Integer
        Dim C_weather As String
        C_year = 0
        C_month = 0
        C_day = 0
        C_year = DataGrid1.Item(DataGrid1.CurrentRowIndex, 0)
        C_month = DataGrid1.Item(DataGrid1.CurrentRowIndex, 1)
        C_day = DataGrid1.Item(DataGrid1.CurrentRowIndex, 2)
        C_weather = DataGrid1.Item(DataGrid1.CurrentRowIndex, 3)
        rewrite.D_ID = DataGrid1.Item(DataGrid1.CurrentRowIndex, 4)
        rewrite.year = C_year
        rewrite.month = C_month
        rewrite.day = C_day
        rewrite.weather = C_weather
        rewrite.YearBox.Text = rewrite.year.ToString
        rewrite.MonthBox.Text = rewrite.month.ToString
        rewrite.DayBox.Text = rewrite.day.ToString
        rewrite.Weather1.Text = rewrite.weather
        db_cmd.CommandText = "select * from Daily where (M_ID = ' " & rewrite.D_ID & " ')"
        db_cmd.Connection = db_c
        db_adp = New System.Data.SqlServerCe.SqlCeDataAdapter(db_cmd)
        DT_daily.Clear()
        db_adp.Fill(DT_daily)
        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 Sub

    Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click '删除
        Dim ask As Boolean
        ask = MsgBox("确定删除?", MsgBoxStyle.YesNo)
        If ask = True Then
            D_ID = DataGrid1.Item(DataGrid1.CurrentRowIndex, 4)
            db_cmd.CommandText = "DELETE from Daily WHERE (M_ID = ' " & D_ID & " ')"
            db_cmd.Connection = db_c
            db_cmd.Connection.Open()
            db_cmd.ExecuteNonQuery()
            db_cmd.Connection.Close()
            MsgBox("删除成功", MsgBoxStyle.OkOnly)
        End If

        db_cmd.CommandText = "select W_year,W_month,W_day,Weather,M_ID From Daily"
        db_cmd.Connection = db_c
        db_adp = New System.Data.SqlServerCe.SqlCeDataAdapter(db_cmd)
        DT_daily.Clear()
        db_adp.Fill(DT_daily)

        DataGrid1.Visible = False
        DataGrid1.DataSource = DT_daily
        DataGrid1.Visible = True
        DataGrid1.Refresh()
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -