Files

494 lines
23 KiB
C#
Raw Permalink Normal View History

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 <20><>ժҪ˵<D2AA><CBB5><EFBFBD><EFBFBD>
/// </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);
// <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Գ<EFBFBD>ʼ<EFBFBD><CABC>ҳ<EFBFBD><D2B3>
System.Data.DataSet Ds_Ads = daoAds.GetCacheList("top 1", "utype=N'<27><>̳<EFBFBD><CCB3><EFBFBD><EFBFBD>' 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 = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-" + config.webName;
Page.MetaDescription = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-" + config.webDescription;
Page.MetaKeywords = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-" + config.webKeywords;
strposition = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
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("<22><>ע<EFBFBD><D7A2><EFBFBD>û<EFBFBD>ע<EFBFBD><D7A2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>24Сʱ<D0A1>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", Hidd_Url.Value);
}
else
{
Select_Bind();
B_pid.Items.Insert(0, new ListItem("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ", "0"));
if (Request.QueryString["BBSID"] == null)
{
strtitle = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
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 = "<22>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>";
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("<22><><EFBFBD><EFBFBD>Ȩ<EFBFBD>޲<EFBFBD><DEB2>㣡", 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()
{
// <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Գ<EFBFBD>ʼ<EFBFBD><CABC>ҳ<EFBFBD><D2B3>
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)//<2F>󶨸<EFBFBD><F3B6A8B8><EFBFBD><EFBFBD><EFBFBD>
{
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 += "<22><>";
}
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("<22><><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>");
}
}
else
{
Mtxfw.Utility.Tools.Message("<22><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
else
{
Mtxfw.Utility.Tools.Message("<22><><EFBFBD><EFBFBD><E2B2BB>Ϊ<EFBFBD>գ<EFBFBD>");
}
}
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'><3E><><EFBFBD><EFBFBD><EFBFBD>ѱ<EFBFBD>" + (umodel.NCName != "" ? umodel.NCName : umodel.UserName) + "<22><>" + DateTime.Now + "<22><EFBFBD><E0BCAD></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("<22><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
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("<22><><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>");
}
}
else
{
Mtxfw.Utility.Tools.Message("<22><><EFBFBD><EFBFBD><E2B2BB>Ϊ<EFBFBD>գ<EFBFBD>");
}
}
}
}