protected void lvNews_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { Label lblnID = (Label)lvNews.Rows[e.NewSelectedIndex].FindControl("lblnID"); int nNewsID = 0; if (int.TryParse(lblnID.Text, out nNewsID) && nNewsID > 0) { DBLL.clsNews clsnews = new DBLL.clsNews(); DataTable dtnewsone = clsnews.Select_tb_NewsBynNewsID(nNewsID); if (dtnewsone != null && dtnewsone.Rows.Count > 0) { Panel1.Visible = false; Panel2.Visible = true; Label1.Text = dtnewsone.Rows[0]["sTitle"].ToString(); lblsAuthor.Text = dtnewsone.Rows[0]["sAuthor"].ToString(); lblsCreatedBy.Text = dtnewsone.Rows[0]["dCreatedTime"].ToString(); Image1.ImageUrl = dtnewsone.Rows[0]["sImagePath"].ToString(); if (Image1.ImageUrl == "") { Image1.Visible = false; } divNewsdetail.InnerHtml = dtnewsone.Rows[0]["sContent"].ToString(); } } }
protected void lvNews_SelectedIndexChanging(object sender, ListViewSelectEventArgs e) { try { Label lblnID = (Label)lvNews.Items[e.NewSelectedIndex].FindControl("lblnID"); int nID = 0; if (int.TryParse(lblnID.Text.Trim(), out nID) && nID > 0) { DBLL.clsNews clsnews = new DBLL.clsNews(); DataTable dtnews = clsnews.Select_tb_NewsBynNewsID(nID); if (dtnews != null && dtnews.Rows.Count > 0) { lblNewsDetailtitle.Text = dtnews.Rows[0]["sTitle"].ToString(); lblNewsDetailTime.Text = dtnews.Rows[0]["dCreatedTime"].ToString(); divNewsDetail.InnerHtml = dtnews.Rows[0]["sContent"].ToString(); PnlNewsDetail.Visible = true; lvNews.Visible = false; } } } catch (Exception) { throw; } }
protected void Button1_Click(object sender, EventArgs e) { DBLL.clsNews News = new DBLL.clsNews(); DBLL.OptionSysDBLL option = new DBLL.OptionSysDBLL(); bool _Result = News.update_tb_NewsBynNewsID(int.Parse(hfNewsUpdateID.Value), int.Parse(ddlnTCategoryID.SelectedValue), int.Parse(rblnLangType.SelectedValue), txtsTitle.Text, txtsAuthor.Text, "", CKEditorControl1.Text, Session["user"].ToString(), DateTime.Now, true, int.Parse(ddlnSorting.SelectedValue)); if (_Result) { string sSaveFolderFullPath = Server.MapPath(Image3.ImageUrl); if (File.Exists(sSaveFolderFullPath)) { //如果存在则删除 File.Delete(sSaveFolderFullPath); System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(sSaveFolderFullPath.Substring(0, sSaveFolderFullPath.LastIndexOf("\\")).ToString()); System.IO.FileInfo[] dirs = dir.GetFiles(); if (dirs.Length > 0) { //有子文件夹 } else { Directory.Delete(sSaveFolderFullPath.Substring(0, sSaveFolderFullPath.LastIndexOf("\\")).ToString()); } } lblsImagePath.Visible = true; MutileUploaderUserControl3.Visible = true; Label2.Visible = false; Button1.Visible = false; Image3.Visible = false; } }
public void SetTyp3News(string sName, int nTCID, int nLangType) { MultiView1.ActiveViewIndex = 2; lblBigTitle.Text = sName; DBLL.clsNews clsnew = new DBLL.clsNews(); lvNews.DataSource = clsnew.Select_tb_NewsBynTCategoryIDAndnLangType(nTCID, nLangType); lvNews.DataBind(); }
protected void BtnUpdate_Click(object sender, EventArgs e) { //判断session if (Session["User"] == null || Session["User"].ToString().Length < 1) { Response.Redirect(Request.RawUrl); } try { if (ValiEdit()) { DBLL.clsNews News = new DBLL.clsNews(); DBLL.OptionSysDBLL option = new DBLL.OptionSysDBLL(); bool _Result = false; MutileUploaderUserControl3.sNewName = txtsTitle.Text; MutileUploaderUserControl3.SavePath(); if (MutileUploaderUserControl3.filepathlist.Count > 0) { for (int i = 0; i < MutileUploaderUserControl3.filepathlist.Count; i++) { _Result = News.update_tb_NewsBynNewsID(int.Parse(hfNewsUpdateID.Value), int.Parse(ddlnTCategoryID.SelectedValue), int.Parse(rblnLangType.SelectedValue), txtsTitle.Text, txtsAuthor.Text, MutileUploaderUserControl3.filepathlist[i].ToString(), CKEditorControl1.Text, Session["user"].ToString(), DateTime.Now, true, int.Parse(ddlnSorting.SelectedValue)); } } else { if (Image3.ImageUrl != "") { _Result = News.update_tb_NewsBynNewsID(int.Parse(hfNewsUpdateID.Value), int.Parse(ddlnTCategoryID.SelectedValue), int.Parse(rblnLangType.SelectedValue), txtsTitle.Text, txtsAuthor.Text, Image3.ImageUrl.ToString(), CKEditorControl1.Text, Session["user"].ToString(), DateTime.Now, true, int.Parse(ddlnSorting.SelectedValue)); } else { _Result = News.update_tb_NewsBynNewsID(int.Parse(hfNewsUpdateID.Value), int.Parse(ddlnTCategoryID.SelectedValue), int.Parse(rblnLangType.SelectedValue), txtsTitle.Text, txtsAuthor.Text, "", CKEditorControl1.Text, Session["user"].ToString(), DateTime.Now, true, int.Parse(ddlnSorting.SelectedValue)); } } if (_Result == true) { ShowMsg1.InnerContent = option.GetOptionValue("FormatSetting", "CommandControl", "UpdateSuccess"); ShowMsg1.Show(); MultiView1.ActiveViewIndex = 0; ReBindPageList(); } else { //失败就一条 ShowMsg1.InnerContent = option.GetOptionValue("FormatSetting", "CommandControl", "UpdateFail"); ShowMsg1.Show(); } } } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int nID = 0; if (Request.QueryString["nID"] != null && int.TryParse(Request.QueryString["nID"].ToString(), out nID) && nID > 0) { lblBigtitle.Text = "编辑数据"; BtnAdd.Visible = false; btnUpdate.Visible = true; DBLL.clsNews clNews = new DBLL.clsNews(); DataTable dt = clNews.Select_tb_NewsBynNewsID(nID); if (dt != null && dt.Rows.Count > 0) { hfID.Value = dt.Rows[0]["nNewsID"].ToString(); RadioButtonList2.SelectedValue = dt.Rows[0]["nLangType"].ToString(); txtsTitle.Text = dt.Rows[0]["sTitle"].ToString(); txtsAuthor.Text = dt.Rows[0]["sAuthor"].ToString(); Image3.ImageUrl = dt.Rows[0]["sImagePath"].ToString(); if (Image3.ImageUrl != "") { lblsImagePath.Visible = false; MutileUploaderUserControl31.Visible = false; Label2.Visible = true; Button1.Visible = true; Image3.Visible = true; } else { lblsImagePath.Visible = true; MutileUploaderUserControl31.Visible = true; Label2.Visible = false; Button1.Visible = false; Image3.Visible = false; } CKEditorControl1.Text = dt.Rows[0]["sContent"].ToString(); txtnSorting.Text = dt.Rows[0]["nSorting"].ToString(); //绑定数据 } } else { lblBigtitle.Text = "添加数据"; btnUpdate.Visible = false; BtnAdd.Visible = true; Label2.Visible = false; Button1.Visible = false; Image3.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DBLL.clsJob clsjob = new DBLL.clsJob(); DBLL.DBcommon dbcon = new DBLL.DBcommon(); BindData(); lblcur.Text = (lvNews.PageIndex + 1).ToString(); lbltotal.Text = lvNews.PageCount.ToString(); int nNewsID = 0; if (Request.QueryString["nNewsID"] != null && int.TryParse(Request.QueryString["nNewsID"].ToString(), out nNewsID) && nNewsID > 0) { DBLL.clsNews clsnews = new DBLL.clsNews(); DataTable dtnewsone = clsnews.Select_tb_NewsBynNewsID(nNewsID); if (dtnewsone != null && dtnewsone.Rows.Count > 0) { Panel1.Visible = false; Panel2.Visible = true; Label1.Text = dtnewsone.Rows[0]["sTitle"].ToString(); lblsAuthor.Text = dtnewsone.Rows[0]["sAuthor"].ToString(); lblsCreatedBy.Text = dtnewsone.Rows[0]["dCreatedTime"].ToString(); Image1.ImageUrl = dtnewsone.Rows[0]["sImagePath"].ToString(); if (Image1.ImageUrl == "") { Image1.Visible = false; } divNewsdetail.InnerHtml = dtnewsone.Rows[0]["sContent"].ToString(); } } else { Panel1.Visible = true; Panel2.Visible = false; } if (DataTableNews == null || DataTableNews.Rows.Count < 1) { Label14.Visible = true; } else { Label14.Visible = false; } } OnSetLanguage(); }
protected void BtnAdd_Click(object sender, EventArgs e) { try { //判断session if (Session["User"] == null || Session["User"].ToString().Length < 1) { Response.Redirect(Request.RawUrl); } if (ValiAdd()) { DBLL.clsNews News = new DBLL.clsNews(); DBLL.OptionSysDBLL option = new DBLL.OptionSysDBLL(); int _Result = 0; MutileUploaderUserControl31.sNewName = txtsTitle.Text; MutileUploaderUserControl31.SavePath(); if (MutileUploaderUserControl31.filepathlist.Count > 0) { for (int i = 0; i < MutileUploaderUserControl31.filepathlist.Count; i++) { _Result = News.insert_tb_News(0, int.Parse(RadioButtonList2.SelectedValue), txtsTitle.Text, txtsAuthor.Text, MutileUploaderUserControl31.filepathlist[i].ToString(), CKEditorControl1.Text, Session["User"].ToString(), DateTime.Now, Session["User"].ToString(), DateTime.Now, true, int.Parse(txtnSorting.Text)); } } else { _Result = News.insert_tb_News(0, int.Parse(RadioButtonList2.SelectedValue), txtsTitle.Text, txtsAuthor.Text, "", CKEditorControl1.Text, Session["User"].ToString(), DateTime.Now, Session["User"].ToString(), DateTime.Now, true, int.Parse(txtnSorting.Text)); } if (_Result > 0) { ShowMsg1.InnerContent = option.GetOptionValue("FormatSetting", "CommandControl", "InsertSuccess"); ShowMsg1.Show(); Clear(); } else { ShowMsg1.InnerContent = option.GetOptionValue("FormatSetting", "CommandControl", "InsertFail"); ShowMsg1.Show(); } } else { ShowMsg1.Show(); } } catch (Exception) { throw; } }
public void ReBindPageList() { DBLL.clsNews News = new DBLL.clsNews(); DataTable dt = new DataTable(); dt = News.sp_selectNormalTableOfAllByNews(false); if (dt != null) { NewsList.Merge(dt); lvNewsList.DataSource = NewsList; lvNewsList.DataBind(); } else { lvNewsList.DataSource = null; lvNewsList.DataBind(); } }
protected void lvNewsList_SelectedIndexChanging(object sender, ListViewSelectEventArgs e) { Label lblnID = (Label)lvNewsList.Items[e.NewSelectedIndex].FindControl("lblnNewsID"); int _nID = 0; DBLL.clsNews News = new DBLL.clsNews(); if (int.TryParse(lblnID.Text.Trim(), out _nID) && _nID > 0) { MultiView1.ActiveViewIndex = 1; DBLL.DBcommon dbcom = new DBLL.DBcommon(); DataTable TopicCategorydt = dbcom.selectNormalTableofAll(false, "tb_TopicCategory"); ddlnTCategoryID.DataSource = TopicCategorydt; ddlnTCategoryID.DataValueField = "nTCategoryID"; ddlnTCategoryID.DataTextField = "sTCategoryNameCN"; ddlnTCategoryID.DataBind(); DataTable dt = News.Select_tb_NewsBynNewsID(_nID); ddlnTCategoryID.SelectedValue = dt.Rows[0]["nTCategoryID"].ToString(); txtsTitle.Text = dt.Rows[0]["sTitle"].ToString(); txtsAuthor.Text = dt.Rows[0]["sAuthor"].ToString(); rblnLangType.SelectedValue = dt.Rows[0]["nLangType"].ToString(); Image3.ImageUrl = dt.Rows[0]["sImagePath"].ToString(); if (Image3.ImageUrl != "") { lblsImagePath.Visible = false; MutileUploaderUserControl3.Visible = false; Label2.Visible = true; Button1.Visible = true; Image3.Visible = true; } else { lblsImagePath.Visible = true; MutileUploaderUserControl3.Visible = true; Label2.Visible = false; Button1.Visible = false; Image3.Visible = false; } CKEditorControl1.Text = dt.Rows[0]["sContent"].ToString(); ddlnSorting.SelectedValue = dt.Rows[0]["nSorting"].ToString(); MutileUploaderUserControl3.Refresh(); hfNewsUpdateID.Value = _nID.ToString(); } }
protected void btnUpdate_Click(object sender, EventArgs e) { //判断session if (Session["User"] == null || Session["User"].ToString().Length < 1) { Response.Redirect(Request.RawUrl); } try { int nID = 0; if (int.TryParse(hfID.Value.ToString(), out nID) && nID > 0) { //更新 if (ValiEdit()) { DBLL.clsNews clNews = new DBLL.clsNews(); DBLL.OptionSysDBLL option = new DBLL.OptionSysDBLL(); bool _Result = false; MutileUploaderUserControl31.sNewName = txtsTitle.Text; MutileUploaderUserControl31.SavePath(); if (MutileUploaderUserControl31.filepathlist.Count > 0) { for (int i = 0; i < MutileUploaderUserControl31.filepathlist.Count; i++) { _Result = clNews.update_tb_NewsBynNewsID(nID, 0, int.Parse(RadioButtonList2.SelectedValue), txtsTitle.Text, txtsAuthor.Text, MutileUploaderUserControl31.filepathlist[i].ToString(), CKEditorControl1.Text, Session["user"].ToString(), DateTime.Now, true, int.Parse(txtnSorting.Text)); } } else { if (Image3.ImageUrl != "") { _Result = clNews.update_tb_NewsBynNewsID(nID, 0, int.Parse(RadioButtonList2.SelectedValue), txtsTitle.Text, txtsAuthor.Text, Image3.ImageUrl.ToString(), CKEditorControl1.Text, Session["user"].ToString(), DateTime.Now, true, int.Parse(txtnSorting.Text)); } else { _Result = clNews.update_tb_NewsBynNewsID(nID, 0, int.Parse(RadioButtonList2.SelectedValue), txtsTitle.Text, txtsAuthor.Text, "", CKEditorControl1.Text, Session["user"].ToString(), DateTime.Now, true, int.Parse(txtnSorting.Text)); } } if (_Result == true) { ShowMsg1.InnerContent = option.GetOptionValue("FormatSetting", "CommandControl", "UpdateSuccess"); ShowMsg1.Show(); } else { //失败就一条 ShowMsg1.InnerContent = option.GetOptionValue("FormatSetting", "CommandControl", "UpdateFail"); ShowMsg1.Show(); } } else { ShowMsg1.Show(); } } } catch (Exception) { throw; } }