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

📄 留言查看.cs

📁 vs2008 组织部信息系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 团委组织部信息系统
{
    public partial class 留言查看 : Form
    {
        SqlDataAdapter da;
        DataSet ds;

        public 留言查看()
        {
            InitializeComponent();
        }

        private void liuyan_infBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.liuyan_infBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.tuanweizuzhibu_infDataSet);

        }

        private void 留言查看_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“tuanweizuzhibu_infDataSet.liuyan_inf”中。您可以根据需要移动或移除它。


        }

        private void button1_Click(object sender, EventArgs e)
        {
            string connectionstring = @"data source=localhost;Initial catalog=tuanweizuzhibu_inf;integrated security=SSPI;";
            string commandstring = @"select * from liuyan_inf where 姓名 like'%" + textBox1.Text + "%'or 主题 like'%" + textBox1.Text + "%' or 留言 like'%" + textBox1.Text + "%'";
            da = new SqlDataAdapter(commandstring, connectionstring);
            ds = new DataSet();
            da.Fill(ds, "liuyan_inf");
            liuyan_infDataGridView.DataSource = ds.Tables["liuyan_inf"];
            留言TextBox.Text = liuyan_infDataGridView.Rows[0].Cells[2].Value.ToString();

            
           
        
        }

        private void 留言TextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            SqlDataAdapter da;
            DataSet ds;
            string connectionstring = @"data source=localhost;Initial catalog=tuanweizuzhibu_inf;integrated security=SSPI;";
            string commandstring = @"select * from liuyan_inf ";
            SqlConnection conn = new SqlConnection(connectionstring);
            string sqlStatement = "UPDATE liuyan_inf SET " +
                    "留言回复='" + textBox2.Text + "'" +
                    "WHERE 留言 = '" + 留言TextBox.Text + "'";
            SqlCommand cmd = new SqlCommand(sqlStatement, conn);
            try
            {
                conn.Open();
                int rowAffected = cmd.ExecuteNonQuery();
                if (rowAffected == 1)
                {
                    da = new SqlDataAdapter(commandstring, connectionstring);
                    ds = new DataSet();
                    da.Fill(ds, "liuyan_inf");
                    MessageBox.Show("回复成功!");
                    liuyan_infDataGridView.DataSource = ds.Tables["liuyan_inf"];
                    
                }

            }

            catch (SqlException ex)
            {
                MessageBox.Show("修改失败:" + ex.Message, "出现错误",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {

                conn.Close();
            }
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void liuyan_infDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            留言TextBox.Text = liuyan_infDataGridView.Rows[0].Cells[2].Value.ToString();
        }
    }
}

⌨️ 快捷键说明

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