494 lines
23 KiB
C#
494 lines
23 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Web;
|
||
using System.Web.SessionState;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using System.Web.UI.HtmlControls;
|
||
using System.Globalization;
|
||
namespace Mtxfw.shop.bbs
|
||
{
|
||
/// <summary>
|
||
/// myShoppingCart 的摘要说明。
|
||
/// </summary>
|
||
public partial class add : Mtxfw.Utility.MemberBase
|
||
{
|
||
Mtxfw.DAL.Ads daoAds = new Mtxfw.DAL.Ads();
|
||
public Mtxfw.DAL.user_info daoUser = new Mtxfw.DAL.user_info();
|
||
public Mtxfw.DAL.forum daoforum = new Mtxfw.DAL.forum();
|
||
public Mtxfw.DAL.bbs daobbs = new Mtxfw.DAL.bbs();
|
||
Mtxfw.Utility.Config config = new Mtxfw.Utility.Config();
|
||
protected int MemberId=0;
|
||
protected string AdsName01, AdsName02;
|
||
protected string indexTP01, indexTP02;
|
||
protected string indexTPLink01, indexTPLink02;
|
||
protected string strposition = "", iftj = "0", B_ID = "0", B_ForumId = "0", B_Title = "", B_ForumName = "", strBody="",strtitle="";
|
||
protected override void OnLoad(EventArgs e)
|
||
{
|
||
base.OnLoad(e);
|
||
// 在此处放置用户代码以初始化页面
|
||
|
||
System.Data.DataSet Ds_Ads = daoAds.GetCacheList("top 1", "utype=N'论坛广告' Order By AdsSort desc", "bbs_Ads2");
|
||
System.Data.DataTable Dt_Ads = Ds_Ads != null && Ds_Ads.Tables[0] != null ? Ds_Ads.Tables[0] : null;
|
||
foreach (System.Data.DataRow Dr in Dt_Ads.Rows)
|
||
{
|
||
indexTP01 = Dr["AdsPic"].ToString();
|
||
indexTPLink01 = Dr["AdsUrl"].ToString();
|
||
AdsName01 = Dr["AdsName"].ToString();
|
||
}
|
||
if (!Page.IsPostBack)
|
||
{
|
||
|
||
if (Request.UrlReferrer != null)
|
||
{
|
||
Hidd_Url.Value = Request.UrlReferrer.ToString();
|
||
}
|
||
if (Hidd_Url.Value.Trim() == "")
|
||
{
|
||
Hidd_Url.Value = "/";
|
||
}
|
||
if (Session["MemberId"] == null)
|
||
{
|
||
Session["returnurl"] = Hidd_Url.Value;
|
||
|
||
}
|
||
else
|
||
{
|
||
Page.Title = "发表帖子-" + config.webName;
|
||
Page.MetaDescription = "发表帖子-" + config.webDescription;
|
||
Page.MetaKeywords = "发表帖子-" + config.webKeywords;
|
||
strposition = "发表帖子";
|
||
MemberId = Convert.ToInt32(Session["MemberId"].ToString());
|
||
Mtxfw.Model.user_info umodel = daoUser.GetModel(MemberId);
|
||
if (umodel != null)
|
||
{
|
||
if (Mtxfw.Utility.Common.DateDiff(DateTime.Now, umodel.RegTime) <= 0)
|
||
{
|
||
Mtxfw.Utility.Tools.Message("新注册用户注册时间在24小时内不允许发贴!", Hidd_Url.Value);
|
||
}
|
||
else
|
||
{
|
||
|
||
Select_Bind();
|
||
B_pid.Items.Insert(0, new ListItem("顶级栏目", "0"));
|
||
if (Request.QueryString["BBSID"] == null)
|
||
{
|
||
strtitle = "发表新贴";
|
||
Btn_Update.Visible = false;
|
||
if (Session["B_ForumId"] != null)
|
||
{
|
||
for (int i = 0; i < B_pid.Items.Count; i++)
|
||
{
|
||
if (B_pid.Items[i].Value == Session["B_ForumId"].ToString())
|
||
{
|
||
B_pid.Items[i].Selected = true;
|
||
}
|
||
else
|
||
{
|
||
B_pid.Items[i].Selected = false;
|
||
}
|
||
}
|
||
}
|
||
if (Request.QueryString["ClassID"] != null)
|
||
{
|
||
for (int i = 0; i < B_pid.Items.Count; i++)
|
||
{
|
||
string[] lbPid = B_pid.Items[i].Value.Split('|');
|
||
if (lbPid[0] == Mtxfw.Utility.Tools.SafeSQL(Request.QueryString["ClassID"].ToString()))
|
||
{
|
||
B_pid.Items[i].Selected = true;
|
||
}
|
||
else
|
||
{
|
||
B_pid.Items[i].Selected = false;
|
||
}
|
||
}
|
||
|
||
}
|
||
if (Session["B_TType"] != null)
|
||
{
|
||
for (int i = 0; i < B_TType.Items.Count; i++)
|
||
{
|
||
if (B_TType.Items[i].Value == Session["B_TType"].ToString())
|
||
{
|
||
B_TType.Items[i].Selected = true;
|
||
}
|
||
else
|
||
{
|
||
B_TType.Items[i].Selected = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
strtitle = "修改贴子";
|
||
Btn_Insert.Visible = false;
|
||
|
||
Mtxfw.Model.bbs mbbs = daobbs.GetModel(int.Parse(Mtxfw.Utility.Tools.SafeSQL(Request.QueryString["BBSID"])));
|
||
if (mbbs != null)
|
||
{
|
||
if (mbbs.B_MemberId != MemberId && !daoforum.IsForumManager(mbbs.B_MemberId, umodel.UserName))
|
||
{
|
||
Mtxfw.Utility.Tools.Message("您的权限不足!", Hidd_Url.Value);
|
||
}
|
||
else
|
||
{
|
||
if (mbbs.B_Layer != 0)
|
||
{
|
||
showPanel.Visible = false;
|
||
Text_Title.Enabled = false;
|
||
}
|
||
Text_Title.Text = mbbs.B_Title;
|
||
strBody = mbbs.B_Body;
|
||
if (!String.IsNullOrEmpty(mbbs.B_Pic))
|
||
{
|
||
Image_PicTrue.Visible = true;
|
||
Image_PicTrue.ImageUrl = Mtxfw.Utility.Common.GetCoverPic(mbbs.B_Pic, "250x250", "cut");
|
||
Hidd_PicTrue.Value = mbbs.B_Pic;
|
||
}
|
||
for (int i = 0; i < B_pid.Items.Count; i++)
|
||
{
|
||
string[] lbPid = B_pid.Items[i].Value.Split('|');
|
||
if (lbPid[0] == mbbs.B_ForumId.ToString())
|
||
{
|
||
B_pid.Items[i].Selected = true;
|
||
}
|
||
else
|
||
{
|
||
B_pid.Items[i].Selected = false;
|
||
}
|
||
}
|
||
for (int i = 0; i < B_TType.Items.Count; i++)
|
||
{
|
||
if (B_TType.Items[i].Value == mbbs.B_TType.ToString())
|
||
{
|
||
B_TType.Items[i].Selected = true;
|
||
}
|
||
else
|
||
{
|
||
B_TType.Items[i].Selected = false;
|
||
}
|
||
}
|
||
if (mbbs.B_TitleColor != "")
|
||
{
|
||
for (int i = 0; i < B_TitleColor.Items.Count; i++)
|
||
{
|
||
if (B_TitleColor.Items[i].Value == mbbs.B_TitleColor.ToString())
|
||
{
|
||
B_TitleColor.Items[i].Selected = true;
|
||
}
|
||
else
|
||
{
|
||
B_TitleColor.Items[i].Selected = false;
|
||
}
|
||
}
|
||
}
|
||
if (mbbs.B_IFReBack == 1)
|
||
{
|
||
B_IFReBack.Checked = true;
|
||
}
|
||
if (mbbs.B_IFLogin == 1)
|
||
{
|
||
B_IFLogin.Checked = true;
|
||
}
|
||
if (mbbs.B_IFShow == 1)
|
||
{
|
||
B_IFShow.Checked = true;
|
||
}
|
||
Hidd_C.Value = mbbs.B_Id.ToString();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
protected void Select_Bind()
|
||
{
|
||
|
||
// 在此处放置用户代码以初始化页面
|
||
string remark = null;
|
||
int lbConut2 = 0;
|
||
DataSet ds = daoforum.GetList("B_seef=1 Order By B_Layer asc,B_linkid asc");
|
||
foreach (DataRowView drv2 in ds.Tables[0].DefaultView)//绑定根结点
|
||
{
|
||
lbConut2 = Convert.ToInt32(drv2["B_Layer"].ToString());
|
||
string LB = drv2["B_ForumName"].ToString();
|
||
string Pid = drv2["B_pid"].ToString();
|
||
string id = drv2["B_Id"].ToString();
|
||
remark = "";
|
||
for (int l = 0; l < lbConut2; l++)
|
||
{
|
||
remark += "├";
|
||
}
|
||
if (lbConut2 == 1)
|
||
{
|
||
B_pid.Items.Add(new ListItem(remark + LB, id + "|" + Pid));
|
||
}
|
||
else
|
||
{
|
||
int jj = 0;
|
||
for (int j = 0; j < B_pid.Items.Count; j++)
|
||
{
|
||
string[] lbpid = B_pid.Items[j].Value.Split('|');
|
||
if (lbpid.Length == 2)
|
||
{
|
||
if (Pid == lbpid[1])
|
||
{
|
||
jj += 1;
|
||
}
|
||
}
|
||
}
|
||
|
||
for (int j = 0; j < B_pid.Items.Count; j++)
|
||
{
|
||
string[] lbpid = B_pid.Items[j].Value.Split('|');
|
||
if (lbpid.Length == 2)
|
||
{
|
||
if (Pid == lbpid[0])
|
||
{
|
||
if (jj != 0)
|
||
{
|
||
B_pid.Items.Insert(j + jj + 1, new ListItem(remark + LB, id + "|" + Pid));
|
||
}
|
||
else
|
||
{
|
||
B_pid.Items.Insert(j + 1, new ListItem(remark + LB, id + "|" + Pid));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
ds.Clear();
|
||
}
|
||
|
||
protected void Btn_Insert_Click(object sender, EventArgs e)
|
||
{
|
||
if (!String.IsNullOrEmpty(Text_Title.Text))
|
||
{
|
||
if (B_pid.SelectedItem.Value != "0")
|
||
{
|
||
if (!String.IsNullOrEmpty(Hidd_myEditor.Value))
|
||
{
|
||
Mtxfw.Model.bbs model = new Mtxfw.Model.bbs();
|
||
model.B_ForumId = Convert.ToInt32(B_pid.SelectedItem.Value.Split('|')[0]);
|
||
Session["B_ForumId"] = B_pid.SelectedItem.Value;
|
||
model.B_ForumIds = daoforum.Getzd("B_pids", "B_ID=" + B_pid.SelectedItem.Value).ToString();
|
||
model.B_Title = Text_Title.Text;
|
||
model.B_TitleColor = B_TitleColor.Value;
|
||
model.B_Body = Hidd_myEditor.Value;
|
||
model.B_Layer = 0;
|
||
model.B_FatherId = 0;
|
||
model.B_MemberId = Convert.ToInt32(Session["MemberId"].ToString());
|
||
model.B_IP = Mtxfw.Utility.Common.GetIP;
|
||
model.B_LastMemberId = Convert.ToInt32(Session["MemberId"].ToString());
|
||
model.B_TPDA_LinkID = 0;
|
||
model.B_TP_StarDate = DateTime.Now;
|
||
model.B_TP_EndDate = DateTime.Now;
|
||
if (File_PicTrue.FileContent.Length > 0)
|
||
{
|
||
Mtxfw.Utility.UploadFile upload = new Mtxfw.Utility.UploadFile(File_PicTrue.PostedFile, config.webUpPath, config.webUpType, int.Parse(config.webUpSize));
|
||
if (upload.StatrUpFile())
|
||
{
|
||
model.B_Pic = upload.UploadPath;
|
||
}
|
||
else model.B_Pic = String.Empty;
|
||
}
|
||
else model.B_Pic = String.Empty;
|
||
model.B_Url = "";
|
||
model.B_TType = Convert.ToInt32(B_TType.SelectedItem.Value);
|
||
model.B_IFGG = (model.B_TType == 7 ? 1 : 0);
|
||
Session["B_TType"] = model.B_TType;
|
||
model.B_seef = 1;
|
||
if (B_IFReBack.Checked)
|
||
{
|
||
model.B_IFReBack = 1;
|
||
}
|
||
else
|
||
{
|
||
model.B_IFReBack = 0;
|
||
}
|
||
if (B_IFLogin.Checked)
|
||
{
|
||
model.B_IFLogin = 1;
|
||
}
|
||
else
|
||
{
|
||
model.B_IFLogin = 0;
|
||
}
|
||
if (B_IFShow.Checked)
|
||
{
|
||
model.B_IFShow = 1;
|
||
}
|
||
else
|
||
{
|
||
model.B_IFShow = 0;
|
||
}
|
||
daobbs.Add(model);
|
||
daoUser.UpdateuLevel0("ArticleNum", 1, model.B_MemberId);
|
||
daoUser.UpdateuLevel0("ArticleJF", 4, model.B_MemberId);
|
||
daoUser.UpdateuLevel0("ArticleMoney", 2, model.B_MemberId);
|
||
if (Session["UploadFileIng"] != null)
|
||
{
|
||
string[] stra = Session["UploadFileIng"].ToString().Split(',');
|
||
foreach (string str in stra)
|
||
{
|
||
if (str.Trim() != "")
|
||
{
|
||
if (model.B_Body.IndexOf(str.Trim()) == -1)
|
||
{
|
||
if (System.IO.File.Exists(Server.MapPath(str.Trim())))
|
||
{
|
||
System.IO.File.Delete(Server.MapPath(str.Trim()));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
Session.Remove("UploadFileIng");
|
||
System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
|
||
while (CacheEnum.MoveNext())
|
||
{
|
||
Cache.Remove(CacheEnum.Key.ToString());
|
||
}
|
||
|
||
Response.Redirect(Hidd_Url.Value);
|
||
}
|
||
else
|
||
{
|
||
Mtxfw.Utility.Tools.Message("内容不能为空!");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Mtxfw.Utility.Tools.Message("分类选择错误!");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Mtxfw.Utility.Tools.Message("标题不能为空!");
|
||
}
|
||
}
|
||
|
||
protected void Btn_Update_Click(object sender, EventArgs e)
|
||
{
|
||
if (!String.IsNullOrEmpty(Text_Title.Text))
|
||
{
|
||
|
||
if (!String.IsNullOrEmpty(Hidd_myEditor.Value))
|
||
{
|
||
int MemberId = Convert.ToInt32(Session["MemberId"].ToString());
|
||
Mtxfw.Model.user_info umodel = daoUser.GetModel(MemberId);
|
||
Int32 ID = int.Parse(Request.QueryString["BBSID"]);
|
||
Mtxfw.Model.bbs model = daobbs.GetModel(ID);
|
||
|
||
model.B_Title = Text_Title.Text;
|
||
string strt = "<div class='IFIntro'>该贴已被" + (umodel.NCName != "" ? umodel.NCName : umodel.UserName) + "于" + DateTime.Now + "编辑过</div>";
|
||
model.B_Body = Hidd_myEditor.Value + strt;
|
||
|
||
//model.B_IP = Mtxfw.Utility.Common.GetIP;
|
||
|
||
|
||
if (model.B_Layer == 0)
|
||
{
|
||
if (B_pid.SelectedItem.Value != "0")
|
||
{
|
||
if (File_PicTrue.FileContent.Length > 0)
|
||
{
|
||
Mtxfw.Utility.UploadFile upload = new Mtxfw.Utility.UploadFile(File_PicTrue.PostedFile, config.webUpPath, config.webUpType, int.Parse(config.webUpSize));
|
||
if (upload.StatrUpFile())
|
||
{
|
||
model.B_Pic = upload.UploadPath;
|
||
}
|
||
else model.B_Pic = String.Empty;
|
||
}
|
||
else model.B_Pic = Hidd_PicTrue.Value;
|
||
model.B_ForumId = Convert.ToInt32(B_pid.SelectedItem.Value.Split('|')[0]);
|
||
model.B_ForumIds = daoforum.Getzd("B_pids", "B_ID=" + B_pid.SelectedItem.Value).ToString();
|
||
model.B_TType = Convert.ToInt32(B_TType.SelectedItem.Value);
|
||
model.B_IFGG = (model.B_TType == 7 ? 1 : 0);
|
||
if (B_IFReBack.Checked)
|
||
{
|
||
model.B_IFReBack = 1;
|
||
}
|
||
else
|
||
{
|
||
model.B_IFReBack = 0;
|
||
}
|
||
if (B_IFLogin.Checked)
|
||
{
|
||
model.B_IFLogin = 1;
|
||
}
|
||
else
|
||
{
|
||
model.B_IFLogin = 0;
|
||
}
|
||
if (B_IFShow.Checked)
|
||
{
|
||
model.B_IFShow = 1;
|
||
}
|
||
else
|
||
{
|
||
model.B_IFShow = 0;
|
||
}
|
||
daobbs.Update(model);
|
||
}
|
||
else
|
||
{
|
||
Mtxfw.Utility.Tools.Message("分类选择错误!");
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
daobbs.Update(model);
|
||
}
|
||
|
||
if (Session["UploadFileIng"] != null)
|
||
{
|
||
string[] stra = Session["UploadFileIng"].ToString().Split(',');
|
||
foreach (string str in stra)
|
||
{
|
||
if (str.Trim() != "")
|
||
{
|
||
if (model.B_Body.IndexOf(str.Trim()) == -1)
|
||
{
|
||
if (System.IO.File.Exists(Server.MapPath(str.Trim())))
|
||
{
|
||
System.IO.File.Delete(Server.MapPath(str.Trim()));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
Session.Remove("UploadFileIng");
|
||
System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
|
||
while (CacheEnum.MoveNext())
|
||
{
|
||
Cache.Remove(CacheEnum.Key.ToString());
|
||
}
|
||
Response.Redirect(Hidd_Url.Value);
|
||
}
|
||
else
|
||
{
|
||
Mtxfw.Utility.Tools.Message("内容不能为空!");
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
Mtxfw.Utility.Tools.Message("标题不能为空!");
|
||
}
|
||
}
|
||
}
|
||
}
|