private void PublishRetext_Load(object sender, EventArgs e) { dataGridViewofretext.SelectionMode = DataGridViewSelectionMode.FullRowSelect; showPID.Text = DB.UserData.PublicValue.viewPID.ToString(); try {//进行评论的加载 string sqlofretext = "select UID as 用户ID ,REDATE as 回复日期,RETEXT as 内容,FLR as 楼层数 from RETEXT where PID=" + DB.UserData.PublicValue.viewPID + ""; sqlofretext += " order by FLR"; DB.SQLHelper Queryretext = new DB.SQLHelper(); DataSet ds = Queryretext.GetDataSet(sqlofretext); DataTable dt = ds.Tables[0]; dataGridViewofretext.DataSource = dt; if (dt.Rows.Count == 0) { dataGridViewofretext.ContextMenuStrip = null; } else { dataGridViewofretext.ContextMenuStrip = contextMenuStripofretext; } } catch (Exception ex) { MessageBox.Show(ex.Message); } try { string title = "select TITLE from POST where PID=" + DB.UserData.PublicValue.viewPID + ""; string main = "select PTEXT from POST where PID=" + DB.UserData.PublicValue.viewPID + ""; DB.SQLHelper showpost = new DB.SQLHelper(); SqlDataReader readtitle = showpost.read(title); SqlDataReader readmain = showpost.read(main); readtitle.Read(); readmain.Read(); titletext.Text = readtitle[0].ToString().Trim(); maintext.Text = readmain[0].ToString().Trim(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Queryretextbutton_Click(object sender, EventArgs e) { string RUID = uidofretext.Text.Trim(); string Rtime = timeofretext.Text.Trim(); if (RUID == "" && Rtime == "") { MessageBox.Show("你必须输入一个查询约束条件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { string sqlquery = "select UID as 用户ID ,PID as 帖子ID,REDATE as 回复日期,RETEXT as 内容,FLR as 楼层数 from RETEXT where UID='" + RUID + "' "; if (Rtime.Length > 0) { sqlquery += " and REDATE='" + Rtime + "'"; } DB.SQLHelper Queryretext = new DB.SQLHelper(); DataSet ds = Queryretext.GetDataSet(sqlquery); DataTable dt = ds.Tables[0]; queryofretext.DataSource = dt; if (dt.Rows.Count == 0) { queryofretext.ContextMenuStrip = null;//删除菜单在无数据时不显示 MessageBox.Show("没有符合条件的帖子记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { queryofretext.ContextMenuStrip = contextMenuStripofretext; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void Qpost_Click(object sender, EventArgs e) { string Quid = QueryUID.Text.Trim();//查询的文本内容 string Qpid = QueryPID.Text.Trim(); string Qtime = time.Text.Trim(); if (Quid == "" && Qpid == "" && Qtime == "") { MessageBox.Show("你必须输入一个查询约束条件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { if (Qpid.Length == 0 && Quid.Length == 0) { string sql = "select UID as 用户ID ,PID as 帖子ID,PDATE as 发帖日期,TITLE as 标题,PTEXT as 内容,LV as 等级 from POST where PDATE between '" + Qtime + " 00:00:00' and '" + Qtime + " 23:59:59'"; sql += " order by PDATE"; DB.SQLHelper Querypost = new DB.SQLHelper(); DataSet ds = Querypost.GetDataSet(sql); DataTable dt = ds.Tables[0]; dataGridViewpost.DataSource = dt; if (dt.Rows.Count == 0) { MessageBox.Show("没有符合条件的帖子记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (Quid.Length == 0) { time.Text = ""; string sql = "select UID as 用户ID ,PID as 帖子ID,PDATE as 发帖日期,TITLE as 标题,PTEXT as 内容,LV as 等级 from POST where PID='" + Qpid + "' "; sql += " order by PDATE"; DB.SQLHelper Querypost = new DB.SQLHelper(); DataSet ds = Querypost.GetDataSet(sql); DataTable dt = ds.Tables[0]; dataGridViewpost.DataSource = dt; if (dt.Rows.Count == 0) { MessageBox.Show("没有符合条件的帖子记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { string sql = "select UID as 用户ID ,PID as 帖子ID,PDATE as 发帖日期,TITLE as 标题,PTEXT as 内容,LV as 等级 from POST where UID='" + Quid + "' "; if (Qpid.Length > 0) { sql += " and PID='" + Qpid + "' "; } if (Qtime.Length > 0) { sql += " and PDATE BETWEEN '" + Qtime + " 00:00:00' and '" + Qtime + " 23:59:59' "; } sql += " order by PDATE"; DB.SQLHelper Querypost = new DB.SQLHelper(); DataSet ds = Querypost.GetDataSet(sql); DataTable dt = ds.Tables[0]; dataGridViewpost.DataSource = dt; if (dt.Rows.Count == 0) { dataGridViewpost.ContextMenuStrip = null;//删除菜单在无数据时不显示 MessageBox.Show("没有符合条件的帖子记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { dataGridViewpost.ContextMenuStrip = deleteMenuStrip; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }