Пример #1
0
        private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string        deleteoftype = "select TYPE from UI where UID='" + DB.UserData.PublicValue.UserID + "'";
                string        strFLR       = queryofretext.SelectedRows[0].Cells["楼层数"].Value.ToString();
                string        deleteofuid  = "select UID from RETEXT where PID=" + DB.UserData.PublicValue.viewPID + " AND FLR='" + strFLR + "'";
                DB.SQLHelper  delete       = new DB.SQLHelper();
                SqlDataReader readuid      = delete.read(deleteofuid);
                readuid.Read();

                DialogResult dialogResult = MessageBox.Show("你确定要删除" + strFLR + "楼的回复吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.No)//选择NO则不进行下一步
                {
                    return;
                }

                if (deleteoftype == "1" || readuid[0].ToString() == DB.UserData.PublicValue.UserID) //判断,若为管理员或回复者则可以删除回复
                {
                    string       deleteRetext = "delete from RETEXT where PID=" + DB.UserData.PublicValue.viewPID + " and FLR='" + strFLR + "'";
                    DB.SQLHelper sqlhelp      = new DB.SQLHelper();
                    sqlhelp.OperateTb(deleteRetext);
                    Queryretextbutton_Click(null, null);
                }
                else
                {
                    MessageBox.Show("你不是回复用户或管理员,不能删除该回复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        private void  除ToolStripMenuItem_Click(object sender, EventArgs e) //删除菜单
        {
            string deleteoftype = "select TYPE from UI where UID='" + DB.UserData.PublicValue.UserID + "'";

            string strPID = dataGridViewpost.SelectedRows[0].Cells["帖子ID"].Value.ToString();//捕捉选中的单元格

            string deleteofuid = "select UID from POST where PID='" + strPID + "'";

            DB.SQLHelper  delete  = new DB.SQLHelper();
            SqlDataReader readuid = delete.read(deleteofuid);

            readuid.Read();

            DialogResult dialogResult = MessageBox.Show("你确定要删除帖子ID为:" + strPID + "的帖子信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.No)//选择NO则不进行下一步
            {
                return;
            }

            if (deleteoftype == "1" || readuid[0].ToString() == DB.UserData.PublicValue.UserID)
            {
                string strdelete = "Delete From POST Where PID='" + strPID + "'";
                try
                {
                    DB.SQLHelper sqlhelp = new DB.SQLHelper();
                    sqlhelp.OperateTb(strdelete);
                    Qpost_Click(null, null);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("你不是发帖用户或管理员,不能删除该帖子!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }