/// <summary> /// 增加一条数据 /// </summary> public void Add(Maticsoft.Model.NewsManage.News model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_News("); strSql.Append("UserId,Heading,Content,Frequency,IssueDate,Dormancy,ClassId,Focus,Priority,IsTop)"); strSql.Append(" values ("); strSql.Append("@UserId,@Heading,@Content,@Frequency,@IssueDate,@Dormancy,@ClassId,@Focus,@Priority,@IsTop)"); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.Int, 4), new SqlParameter("@Heading", SqlDbType.VarChar, 200), new SqlParameter("@Content", SqlDbType.Text), new SqlParameter("@Frequency", SqlDbType.Int, 4), new SqlParameter("@IssueDate", SqlDbType.DateTime), new SqlParameter("@Dormancy", SqlDbType.VarChar, 10), new SqlParameter("@ClassId", SqlDbType.Int, 4), new SqlParameter("@Focus", SqlDbType.VarChar, 200), new SqlParameter("@Priority", SqlDbType.Int, 4), new SqlParameter("@IsTop", SqlDbType.Int, 4) }; parameters[0].Value = model.UserId; parameters[1].Value = model.Heading; parameters[2].Value = model.Content; parameters[3].Value = model.Frequency; parameters[4].Value = model.IssueDate; parameters[5].Value = model.Dormancy; parameters[6].Value = model.ClassId; parameters[7].Value = model.Focus; parameters[8].Value = model.Priority; parameters[9].Value = model.IsTop; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
private void ShowInfo(int Id) { Navigation011.Para_Str = "id=" + Id; Maticsoft.BLL.NewsManage.News bll = new Maticsoft.BLL.NewsManage.News(); Maticsoft.Model.NewsManage.News model = bll.GetModel(Id); this.lblNewsId.Text = model.NewsId.ToString(); this.lblHeading.Text = model.Heading; this.lblFocus.Text = model.Focus; this.lblFrequency.Text = model.Frequency.ToString(); if (model.Dormancy == "True") { this.lblDormancy.Text = "·¢²¼"; } else { this.lblDormancy.Text = "ÐÝÃß"; } lblistop.Text = model.IsTop == 1 ? "ÊÇ" : "·ñ"; this.lblIssueDate.Text = model.IssueDate.ToString(); this.lblContent.Text = model.Content; Maticsoft.BLL.NewsManage.NewsClass bllc = new Maticsoft.BLL.NewsManage.NewsClass(); this.lblClass.Text = bllc.GetModel(model.ClassId).ClassDesc; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //ck.AutoConfigure = AutoConfigure.EnableAll; //this.ck.HelperFilesPath = "HelperScripts"; ////this.ck.ImageGalleryPath="images"; string UpNewsImageFolder = LTP.Common.ConfigHelper.GetConfigString("UpNewsImageFolder"); //this.ck.ImageGalleryPath = UpNewsImageFolder; BiudTree(); if (Session["news"] != null) { Maticsoft.Model.NewsManage.News news = (Maticsoft.Model.NewsManage.News)Session["news"]; for (int i = 0; i < this.dropNewsClass.Items.Count; i++) { if (this.dropNewsClass.Items[i].Value == news.ClassId.ToString()) { this.dropNewsClass.Items[i].Selected = true; } } this.chkDormancy.Checked = news.Dormancy == "True" ? true : false; this.chkAddContinue.Checked = true; } } }
private void ShowNews(int NewsId)//显示新闻 { Maticsoft.BLL.NewsManage.News bll = new Maticsoft.BLL.NewsManage.News(); Maticsoft.Model.NewsManage.News model = bll.GetModelByCache(NewsId); strHeading = model.Heading; strDate = model.IssueDate.ToString(); strContent = model.Content; strfrquency = model.Frequency.ToString(); if (model.IsLimited == 1) { string XmlPath = Server.MapPath("~/app_data/AllowIp.xml"); string thisIp = ""; thisIp = Page.Request.UserHostAddress; Maticsoft.BLL.NewsManage.NewsViewIpcontrol newsipcontrol = new Maticsoft.BLL.NewsManage.NewsViewIpcontrol(); if (!newsipcontrol.IpAllow(thisIp, XmlPath)) { strContent = "对不起,您的IP:" + thisIp + "不在本文允许的访问范围内,请联系管理员!"; return; } } //附件信息 this.newsimagescontent.InnerHtml = ShowNewsImage(NewsId).ToString(); this.newsaffixcontent.InnerHtml = ShowNewsAffix(NewsId).ToString(); GenNavigate(model.ClassId); //点击率增加 model.Frequency++; bll.FrequencyAdd(model); }
/// <summary> /// 增加一条数据(父子表,事务处理) /// </summary> public void Add2(Maticsoft.Model.NewsManage.News model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_News("); strSql.Append("UserId,Heading,Content,Frequency,IssueDate,Dormancy,ClassId,Focus,Priority,IsTop)"); strSql.Append(" values ("); strSql.Append("@UserId,@Heading,@Content,@Frequency,@IssueDate,@Dormancy,@ClassId,@Focus,@Priority,@IsTop)"); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.Int, 4), new SqlParameter("@Heading", SqlDbType.VarChar, 200), new SqlParameter("@Content", SqlDbType.Text), new SqlParameter("@Frequency", SqlDbType.Int, 4), new SqlParameter("@IssueDate", SqlDbType.DateTime), new SqlParameter("@Dormancy", SqlDbType.VarChar, 10), new SqlParameter("@ClassId", SqlDbType.Int, 4), new SqlParameter("@Focus", SqlDbType.VarChar, 200), new SqlParameter("@Priority", SqlDbType.Int, 4), new SqlParameter("@IsTop", SqlDbType.Int, 4) }; parameters[0].Value = model.UserId; parameters[1].Value = model.Heading; parameters[2].Value = model.Content; parameters[3].Value = model.Frequency; parameters[4].Value = model.IssueDate; parameters[5].Value = model.Dormancy; parameters[6].Value = model.ClassId; parameters[7].Value = model.Focus; parameters[8].Value = model.Priority; parameters[9].Value = model.IsTop; List <string> sqla = new List <string>(); sqla.Add(strSql.ToString()); StringBuilder strSql2; foreach (Maticsoft.Model.NewsManage.NewsReply nr in model.NewsReplys) { strSql2 = new StringBuilder(); strSql2.Append("insert into T_NewsReply("); strSql2.Append("NewsId,Content,IssueDate)"); strSql2.Append(" values ("); strSql2.Append("@NewsId,@Content,@IssueDate)"); SqlParameter[] parameters2 = { new SqlParameter("@NewsId", SqlDbType.Int, 4), new SqlParameter("@Content", SqlDbType.Text), new SqlParameter("@IssueDate", SqlDbType.DateTime) }; parameters2[0].Value = nr.NewsId; parameters2[1].Value = nr.Content; parameters2[2].Value = DateTime.Now; sqla.Add(strSql2.ToString()); } DbHelperSQL.ExecuteSqlTran(sqla); }
private void ShowNews(int NewsId)//显示新闻 { Maticsoft.BLL.NewsManage.News bll = new Maticsoft.BLL.NewsManage.News(); Maticsoft.Model.NewsManage.News model = bll.GetModelByCache(NewsId); strHeading = model.Heading; strDate = model.IssueDate.ToString(); strContent = model.Content; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.NewsManage.News model) { DataSet Ds = dal.Add(model); int NewsId = -1; try { NewsId = int.Parse(Ds.Tables[0].Rows[0][0].ToString()); } catch { }; return(NewsId); }
private void ShowInfo(int Id) { Navigation011.Para_Str = "id=" + Id; Maticsoft.BLL.NewsManage.News bll = new Maticsoft.BLL.NewsManage.News(); Maticsoft.Model.NewsManage.News model = bll.GetModel(Id); Session["news"] = model; lblNewsId.Text = model.NewsId.ToString(); this.txtHeading.Text = model.Heading; this.FreeTextBox1.Text = model.Content; }
/// <summary> /// 增加点击率 /// </summary> public void FrequencyAdd(Maticsoft.Model.NewsManage.News model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_News set "); strSql.Append("Frequency=@Frequency"); strSql.Append(" where NewsId=@NewsId"); SqlParameter[] parameters = { new SqlParameter("@NewsId", SqlDbType.Int, 4), new SqlParameter("@Frequency", SqlDbType.Int, 4) }; parameters[0].Value = model.NewsId; parameters[1].Value = model.Frequency; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Maticsoft.Model.NewsManage.News model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_News set "); strSql.Append("UserId=@UserId,"); strSql.Append("Heading=@Heading,"); strSql.Append("Content=@Content,"); strSql.Append("IssueDate=@IssueDate,"); strSql.Append("ClassId=@ClassId,"); strSql.Append("Dormancy=@Dormancy,"); strSql.Append("Focus=@Focus,"); strSql.Append("Priority=@Priority,"); strSql.Append("IsTop=@IsTop,"); strSql.Append("IsLimited=@IsLimited"); strSql.Append(" where NewsId=@NewsId"); SqlParameter[] parameters = { new SqlParameter("@NewsId", SqlDbType.Int, 4), new SqlParameter("@UserId", SqlDbType.Int, 4), new SqlParameter("@Heading", SqlDbType.VarChar, 200), new SqlParameter("@Content", SqlDbType.Text), new SqlParameter("@IssueDate", SqlDbType.DateTime), new SqlParameter("@ClassId", SqlDbType.Int, 4), new SqlParameter("@Dormancy", SqlDbType.VarChar, 10), new SqlParameter("@Focus", SqlDbType.VarChar, 200), new SqlParameter("@Priority", SqlDbType.Int, 4), new SqlParameter("@IsTop", SqlDbType.Int, 4), new SqlParameter("@IsLimited", SqlDbType.Int, 4) }; parameters[0].Value = model.NewsId; parameters[1].Value = model.UserId; parameters[2].Value = model.Heading; parameters[3].Value = model.Content; parameters[4].Value = model.IssueDate; parameters[5].Value = model.ClassId; parameters[6].Value = model.Dormancy; parameters[7].Value = model.Focus; parameters[8].Value = model.Priority; parameters[9].Value = model.IsTop; parameters[10].Value = model.IsLimited; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
private void ShowInfo(int Id) { Navigation011.Para_Str = "id=" + Id; Maticsoft.BLL.NewsManage.News bll = new Maticsoft.BLL.NewsManage.News(); Maticsoft.Model.NewsManage.News model = bll.GetModel(Id); Session["news"] = model; lblNewsId.Text = model.NewsId.ToString(); for (int i = 0; i < this.dropNewsClass.Items.Count; i++) { if (this.dropNewsClass.Items[i].Value == model.ClassId.ToString()) { this.dropNewsClass.Items[i].Selected = true; } } this.txtHeading.Text = model.Heading; this.txtFocus.Text = model.Focus; this.txtIssueDate.Text = model.IssueDate.ToString(); this.chkIsTop.Checked = (model.IsTop == 1); this.chkIsLimited.Checked = (model.IsLimited == 1); if (model.Dormancy.ToString().ToLower() == "true") { this.chkDormancy.Checked = false; } else { this.chkDormancy.Checked = true; } // if(news.Opened.ToString().ToLower()=="true") // { // this.radlistOpened.SelectedIndex=1; // } // else // { // this.radlistOpened.SelectedIndex=0; // } //this.FreeTextBox1.Text = model.Content; this.ck_modify.Text = model.Content; }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr = ""; int newid = int.Parse(lblNewsId.Text); string heading = this.txtHeading.Text.Trim(); string content = FreeTextBox1.Text; if (heading == "") { strErr += "标题不能为空\\n"; } if (content == "") { strErr += "内容不能为空\\n"; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } if (Session["UserInfo"] == null) { return; } LTP.Accounts.Bus.User currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"]; Maticsoft.Model.NewsManage.News news = (Maticsoft.Model.NewsManage.News)Session["news"]; news.NewsId = newid; news.Heading = heading; news.Content = content; news.Frequency = 0; news.IssueDate = DateTime.Now; Maticsoft.BLL.NewsManage.News n = new Maticsoft.BLL.NewsManage.News(); n.Update(news); Response.Redirect("show.aspx?id=" + newid); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(Maticsoft.Model.NewsManage.News model) { dal.Add(model); }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr = ""; string heading = this.txtHeading.Text.Trim(); string focus = this.txtFocus.Text.Trim(); string content = this.FreeTextBox1.Text.Trim(); string classid = this.dropNewsClass.SelectedValue; bool dormancy = this.chkDormancy.Checked; if (heading == "") { strErr += "标题不能为空\\n"; } if (content == "") { strErr += "内容不能为空\\n"; } if ((this.dropNewsClass.Items.Count == 0) || (classid.Trim() == "")) { strErr += "没有可以选择的类别!\\n"; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } if (Session["UserInfo"] == null) { return; } LTP.Accounts.Bus.User currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"]; Maticsoft.Model.NewsManage.News news = new Maticsoft.Model.NewsManage.News(); news.ClassId = int.Parse(classid); news.Heading = heading; news.Focus = focus; news.Content = content; if (dormancy) { news.Dormancy = "False"; } else { news.Dormancy = "True"; } news.Dormancy = dormancy.ToString(); //news.Opened = opened; news.Frequency = 0; news.IssueDate = DateTime.Now; //news.ParentId = 0; news.Priority = 0; news.UserId = currentUser.UserID; //news.DepartmentID = int.Parse(currentUser.DepartmentID); if (chkIsTop.Checked) { news.IsTop = 1; } else { news.IsTop = 0; } Maticsoft.BLL.NewsManage.News n = new Maticsoft.BLL.NewsManage.News(); n.Add(news); if (chkAddContinue.Checked) { Session["news"] = news; Response.Redirect("Add.aspx"); } else { Session["news"] = null; Response.Redirect("index.aspx"); } }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr = ""; int newid = int.Parse(lblNewsId.Text); string heading = this.txtHeading.Text.Trim(); string focus = this.txtFocus.Text.Trim(); string content = this.ck_modify.Text.Trim(); string classid = this.dropNewsClass.SelectedValue; string strissuedate = this.txtIssueDate.Text; //bool opened = this.radlistOpened.SelectedValue == "1" ? true : false; bool dormancy = !this.chkDormancy.Checked; if (heading == "") { strErr += "标题不能为空\\n"; } if (content == "") { strErr += "内容不能为空\\n"; } if ((this.dropNewsClass.Items.Count == 0) || (classid.Trim() == "")) { strErr += "没有可以选择的类别!\\n"; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } if (Session["UserInfo"] == null) return; DateTime issuedate = DateTime.Now; try { issuedate = Convert.ToDateTime(strissuedate); } catch { } LTP.Accounts.Bus.User currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"]; Maticsoft.Model.NewsManage.News news = new Maticsoft.Model.NewsManage.News(); news.NewsId = newid; news.ClassId = int.Parse(classid); news.Heading = heading; news.Focus = focus; news.Content = content; news.IssueDate = issuedate; // news.Frequency = 0; if (dormancy) { news.Dormancy = "True"; } else { news.Dormancy = "False"; } news.IssueDate = issuedate;// DateTime.Now; news.Priority = 0; news.UserId = currentUser.UserID; if (chkIsTop.Checked) { news.IsTop = 1; } else { news.IsTop = 0; } if (chkIsLimited.Checked) { news.IsLimited = 1; } else { news.IsLimited = 0; } Maticsoft.BLL.NewsManage.News n = new Maticsoft.BLL.NewsManage.News(); n.Update(news); //处理新闻图片 if (Session["NewsImages_tempId"] != null) { int NewsImages_tempId = (int)Session["NewsImages_tempId"]; Maticsoft.BLL.NewsManage.NewsImages bll = new Maticsoft.BLL.NewsManage.NewsImages(); DataSet Dset = (DataSet)Session["FileList"]; //bll.GetNewsImagesList(-1, NewsImages_tempId, false); if (Dset != null && Dset.Tables[0].Rows.Count > 0) { string Sourcepath = Server.MapPath("~/upload/Temp/"); string Despath = Server.MapPath("~/upload/img/"); for (int i = 0; i < Dset.Tables[0].Rows.Count; i++) { try { string FileName = Dset.Tables[0].Rows[i]["linkurl"].ToString(); if (File.Exists(Sourcepath + FileName)) File.Copy(Sourcepath + FileName, Despath + FileName); if (File.Exists(Sourcepath + FileName)) File.Delete(Sourcepath + FileName); } catch { //this.Label_Msg.Text = "文件复制出错:" + Ex.Message.ToString(); } } //修改图片 // string strupdatestring = "newsid=" + newsid.ToString(); // bll.Update(strupdatestring, NewsImages_tempId); } } //处理新闻附件 if (Session["NewsAffix_tempId"] != null) { int NewsAffix_tempId = (int)Session["NewsAffix_tempId"]; Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix(); DataSet Dset = (DataSet)Session["FileList_Affix"]; //bll.GetNewsAffixList(-1, NewsAffix_tempId, false); if (Dset != null && Dset.Tables[0].Rows.Count > 0) { string Sourcepath = Server.MapPath("~/upload/Temp/"); string Despath = Server.MapPath("~/upload/affix/"); for (int i = 0; i < Dset.Tables[0].Rows.Count; i++) { try { string FileName = Dset.Tables[0].Rows[i]["linkurl"].ToString(); if (File.Exists(Sourcepath + FileName)) File.Copy(Sourcepath + FileName, Despath + FileName); if (File.Exists(Sourcepath + FileName)) File.Delete(Sourcepath + FileName); } catch { //this.Label_Msg.Text = "文件复制出错:" + Ex.Message.ToString(); } } //修改附件 //string strupdatestring = "newsid=" + newsid.ToString(); //bll.Update(strupdatestring, NewsAffix_tempId); } } Response.Redirect("show.aspx?id=" + newid); }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr = ""; int newid = int.Parse(lblNewsId.Text); string heading = this.txtHeading.Text.Trim(); string focus = this.txtFocus.Text.Trim(); string content = this.FreeTextBox1.Text.Trim(); string classid = this.dropNewsClass.SelectedValue; string strissuedate = this.txtIssueDate.Text; //bool opened = this.radlistOpened.SelectedValue == "1" ? true : false; bool dormancy = !this.chkDormancy.Checked; if (heading == "") { strErr += "标题不能为空\\n"; } if (content == "") { strErr += "内容不能为空\\n"; } if ((this.dropNewsClass.Items.Count == 0) || (classid.Trim() == "")) { strErr += "没有可以选择的类别!\\n"; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } if (Session["UserInfo"] == null) { return; } DateTime issuedate = DateTime.Now; try { issuedate = Convert.ToDateTime(strissuedate); } catch { } LTP.Accounts.Bus.User currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"]; Maticsoft.Model.NewsManage.News news = new Maticsoft.Model.NewsManage.News(); news.NewsId = newid; news.ClassId = int.Parse(classid); news.Heading = heading; news.Focus = focus; news.Content = content; news.IssueDate = issuedate; // news.Frequency = 0; if (dormancy) { news.Dormancy = "True"; } else { news.Dormancy = "False"; } news.IssueDate = issuedate;// DateTime.Now; news.Priority = 0; news.UserId = currentUser.UserID; if (chkIsTop.Checked) { news.IsTop = 1; } else { news.IsTop = 0; } if (chkIsLimited.Checked) { news.IsLimited = 1; } else { news.IsLimited = 0; } Maticsoft.BLL.NewsManage.News n = new Maticsoft.BLL.NewsManage.News(); n.Update(news); //处理新闻图片 if (Session["NewsImages_tempId"] != null) { int NewsImages_tempId = (int)Session["NewsImages_tempId"]; Maticsoft.BLL.NewsManage.NewsImages bll = new Maticsoft.BLL.NewsManage.NewsImages(); DataSet Dset = (DataSet)Session["FileList"]; //bll.GetNewsImagesList(-1, NewsImages_tempId, false); if (Dset != null && Dset.Tables[0].Rows.Count > 0) { string Sourcepath = Server.MapPath("~/upload/Temp/"); string Despath = Server.MapPath("~/upload/img/"); for (int i = 0; i < Dset.Tables[0].Rows.Count; i++) { try { string FileName = Dset.Tables[0].Rows[i]["linkurl"].ToString(); if (File.Exists(Sourcepath + FileName)) { File.Copy(Sourcepath + FileName, Despath + FileName); } if (File.Exists(Sourcepath + FileName)) { File.Delete(Sourcepath + FileName); } } catch { //this.Label_Msg.Text = "文件复制出错:" + Ex.Message.ToString(); } } //修改图片 // string strupdatestring = "newsid=" + newsid.ToString(); // bll.Update(strupdatestring, NewsImages_tempId); } } //处理新闻附件 if (Session["NewsAffix_tempId"] != null) { int NewsAffix_tempId = (int)Session["NewsAffix_tempId"]; Maticsoft.BLL.NewsManage.NewsAffix bll = new Maticsoft.BLL.NewsManage.NewsAffix(); DataSet Dset = (DataSet)Session["FileList_Affix"]; //bll.GetNewsAffixList(-1, NewsAffix_tempId, false); if (Dset != null && Dset.Tables[0].Rows.Count > 0) { string Sourcepath = Server.MapPath("~/upload/Temp/"); string Despath = Server.MapPath("~/upload/affix"); for (int i = 0; i < Dset.Tables[0].Rows.Count; i++) { try { string FileName = Dset.Tables[0].Rows[i]["linkurl"].ToString(); if (File.Exists(Sourcepath + FileName)) { File.Copy(Sourcepath + FileName, Despath + FileName); } if (File.Exists(Sourcepath + FileName)) { File.Delete(Sourcepath + FileName); } } catch { //this.Label_Msg.Text = "文件复制出错:" + Ex.Message.ToString(); } } //修改附件 //string strupdatestring = "newsid=" + newsid.ToString(); //bll.Update(strupdatestring, NewsAffix_tempId); } } Response.Redirect("show.aspx?id=" + newid); }
/// <summary> /// �õ�һ������ʵ��(���ӱ��������) /// </summary> public Maticsoft.Model.NewsManage.News GetModel(int NewsId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from T_News "); strSql.Append(" where NewsId=@NewsId"); SqlParameter[] parameters = { new SqlParameter("@NewsId", SqlDbType.Int,4)}; parameters[0].Value = NewsId; Maticsoft.Model.NewsManage.News model = new Maticsoft.Model.NewsManage.News(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); model.NewsId = NewsId; if (ds.Tables[0].Rows.Count > 0) { #region �ֶ���Ϣ if (ds.Tables[0].Rows[0]["UserId"].ToString() != "") { model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString()); } model.Heading = ds.Tables[0].Rows[0]["Heading"].ToString(); model.Content = ds.Tables[0].Rows[0]["Content"].ToString(); if (ds.Tables[0].Rows[0]["Frequency"].ToString() != "") { model.Frequency = int.Parse(ds.Tables[0].Rows[0]["Frequency"].ToString()); } if (ds.Tables[0].Rows[0]["IssueDate"].ToString() != "") { model.IssueDate = DateTime.Parse(ds.Tables[0].Rows[0]["IssueDate"].ToString()); } model.Dormancy = ds.Tables[0].Rows[0]["Dormancy"].ToString(); if (ds.Tables[0].Rows[0]["ClassId"].ToString() != "") { model.ClassId = int.Parse(ds.Tables[0].Rows[0]["ClassId"].ToString()); } model.Focus = ds.Tables[0].Rows[0]["Focus"].ToString(); if (ds.Tables[0].Rows[0]["Priority"].ToString() != "") { model.Priority = int.Parse(ds.Tables[0].Rows[0]["Priority"].ToString()); } if (ds.Tables[0].Rows[0]["IsTop"].ToString() != "") { model.IsTop = int.Parse(ds.Tables[0].Rows[0]["IsTop"].ToString()); } #endregion #region ���Żظ���Ϣ StringBuilder strSqlR = new StringBuilder(); strSqlR.Append("select * from T_NewsReply "); strSqlR.Append(" where NewsId=@NewsId"); SqlParameter[] parametersr = { new SqlParameter("@NewsId", SqlDbType.Int,4)}; parametersr[0].Value = NewsId; DataSet dsR = DbHelperSQL.Query(strSqlR.ToString(), parametersr); if ((dsR.Tables.Count>0)&&(dsR.Tables[0].Rows.Count > 0)) { int i = dsR.Tables[0].Rows.Count; List<Maticsoft.Model.NewsManage.NewsReply> newsReplys = new List<Maticsoft.Model.NewsManage.NewsReply>(); for (int n = 0; n < i; n++) { newsReplys[n] = new Maticsoft.Model.NewsManage.NewsReply(); if (dsR.Tables[0].Rows[0]["Id"].ToString() != "") { newsReplys[n].Id = int.Parse(dsR.Tables[0].Rows[0]["Id"].ToString()); } if (dsR.Tables[0].Rows[0]["NewsId"].ToString() != "") { newsReplys[n].NewsId = int.Parse(dsR.Tables[0].Rows[0]["NewsId"].ToString()); } newsReplys[n].Content = dsR.Tables[0].Rows[0]["Content"].ToString(); if (dsR.Tables[0].Rows[0]["IssueDate"].ToString() != "") { newsReplys[n].IssueDate = DateTime.Parse(dsR.Tables[0].Rows[0]["IssueDate"].ToString()); } } model.NewsReplys = newsReplys; } #endregion return model; } else { return null; } }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr = ""; int newid = int.Parse(lblNewsId.Text); string heading = this.txtHeading.Text.Trim(); string focus = this.txtFocus.Text.Trim(); string content = this.FreeTextBox1.Text.Trim(); string classid = this.dropNewsClass.SelectedValue; //bool opened = this.radlistOpened.SelectedValue == "1" ? true : false; bool dormancy = this.chkDormancy.Checked; if (heading == "") { strErr += "标题不能为空\\n"; } if (content == "") { strErr += "内容不能为空\\n"; } if ((this.dropNewsClass.Items.Count == 0) || (classid.Trim() == "")) { strErr += "没有可以选择的类别!\\n"; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } if (Session["UserInfo"] == null) { return; } LTP.Accounts.Bus.User currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"]; Maticsoft.Model.NewsManage.News news = new Maticsoft.Model.NewsManage.News(); news.NewsId = newid; news.ClassId = int.Parse(classid); news.Heading = heading; news.Focus = focus; news.Content = content; news.Frequency = 0; if (dormancy) { news.Dormancy = "True"; } else { news.Dormancy = "False"; } news.IssueDate = DateTime.Now; news.Priority = 0; news.UserId = currentUser.UserID; if (chkIsTop.Checked) { news.IsTop = 1; } else { news.IsTop = 0; } Maticsoft.BLL.NewsManage.News n = new Maticsoft.BLL.NewsManage.News(); n.Update(news); Response.Redirect("show.aspx?id=" + newid); }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr = ""; string heading = this.txtHeading.Text.Trim(); string focus = this.txtFocus.Text.Trim(); string content = this.FreeTextBox1.Text.Trim(); string classid = this.dropNewsClass.SelectedValue; bool dormancy = this.chkDormancy.Checked; if (heading == "") { strErr += "���ⲻ��Ϊ��\\n"; } if (content == "") { strErr += "���ݲ���Ϊ��\\n"; } if ((this.dropNewsClass.Items.Count == 0) || (classid.Trim() == "")) { strErr += "û�п���ѡ������\\n"; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } if (Session["UserInfo"] == null) return; LTP.Accounts.Bus.User currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"]; Maticsoft.Model.NewsManage.News news = new Maticsoft.Model.NewsManage.News(); news.ClassId = int.Parse(classid); news.Heading = heading; news.Focus = focus; news.Content = content; if (dormancy) { news.Dormancy = "False"; } else { news.Dormancy = "True"; } news.Dormancy = dormancy.ToString(); //news.Opened = opened; news.Frequency = 0; news.IssueDate = DateTime.Now; //news.ParentId = 0; news.Priority = 0; news.UserId = currentUser.UserID; //news.DepartmentID = int.Parse(currentUser.DepartmentID); if (chkIsTop.Checked) { news.IsTop = 1; } else { news.IsTop = 0; } Maticsoft.BLL.NewsManage.News n = new Maticsoft.BLL.NewsManage.News(); n.Add(news); if (chkAddContinue.Checked) { Session["news"] = news; Response.Redirect("Add.aspx"); } else { Session["news"] = null; Response.Redirect("index.aspx"); } }
/// <summary> /// 得到一个对象实体(父子表,事务处理) /// </summary> public Maticsoft.Model.NewsManage.News GetModel(int NewsId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from T_News "); strSql.Append(" where NewsId=@NewsId"); SqlParameter[] parameters = { new SqlParameter("@NewsId", SqlDbType.Int, 4) }; parameters[0].Value = NewsId; Maticsoft.Model.NewsManage.News model = new Maticsoft.Model.NewsManage.News(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); model.NewsId = NewsId; if (ds.Tables[0].Rows.Count > 0) { #region 字段信息 if (ds.Tables[0].Rows[0]["UserId"].ToString() != "") { model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString()); } model.Heading = ds.Tables[0].Rows[0]["Heading"].ToString(); model.Content = ds.Tables[0].Rows[0]["Content"].ToString(); if (ds.Tables[0].Rows[0]["Frequency"].ToString() != "") { model.Frequency = int.Parse(ds.Tables[0].Rows[0]["Frequency"].ToString()); } if (ds.Tables[0].Rows[0]["IssueDate"].ToString() != "") { model.IssueDate = DateTime.Parse(ds.Tables[0].Rows[0]["IssueDate"].ToString()); } model.Dormancy = ds.Tables[0].Rows[0]["Dormancy"].ToString(); if (ds.Tables[0].Rows[0]["ClassId"].ToString() != "") { model.ClassId = int.Parse(ds.Tables[0].Rows[0]["ClassId"].ToString()); } model.Focus = ds.Tables[0].Rows[0]["Focus"].ToString(); if (ds.Tables[0].Rows[0]["Priority"].ToString() != "") { model.Priority = int.Parse(ds.Tables[0].Rows[0]["Priority"].ToString()); } if (ds.Tables[0].Rows[0]["IsTop"].ToString() != "") { model.IsTop = int.Parse(ds.Tables[0].Rows[0]["IsTop"].ToString()); } #endregion #region 新闻回复信息 StringBuilder strSqlR = new StringBuilder(); strSqlR.Append("select * from T_NewsReply "); strSqlR.Append(" where NewsId=@NewsId"); SqlParameter[] parametersr = { new SqlParameter("@NewsId", SqlDbType.Int, 4) }; parametersr[0].Value = NewsId; DataSet dsR = DbHelperSQL.Query(strSqlR.ToString(), parametersr); if ((dsR.Tables.Count > 0) && (dsR.Tables[0].Rows.Count > 0)) { int i = dsR.Tables[0].Rows.Count; List <Maticsoft.Model.NewsManage.NewsReply> newsReplys = new List <Maticsoft.Model.NewsManage.NewsReply>(); for (int n = 0; n < i; n++) { newsReplys[n] = new Maticsoft.Model.NewsManage.NewsReply(); if (dsR.Tables[0].Rows[0]["Id"].ToString() != "") { newsReplys[n].Id = int.Parse(dsR.Tables[0].Rows[0]["Id"].ToString()); } if (dsR.Tables[0].Rows[0]["NewsId"].ToString() != "") { newsReplys[n].NewsId = int.Parse(dsR.Tables[0].Rows[0]["NewsId"].ToString()); } newsReplys[n].Content = dsR.Tables[0].Rows[0]["Content"].ToString(); if (dsR.Tables[0].Rows[0]["IssueDate"].ToString() != "") { newsReplys[n].IssueDate = DateTime.Parse(dsR.Tables[0].Rows[0]["IssueDate"].ToString()); } } model.NewsReplys = newsReplys; } #endregion return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Maticsoft.Model.NewsManage.News model) { dal.Update(model); }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr = ""; int newid = int.Parse(lblNewsId.Text); string heading = this.txtHeading.Text.Trim(); string focus = this.txtFocus.Text.Trim(); string content = this.FreeTextBox1.Text.Trim(); string classid = this.dropNewsClass.SelectedValue; //bool opened = this.radlistOpened.SelectedValue == "1" ? true : false; bool dormancy = this.chkDormancy.Checked; if (heading == "") { strErr += "���ⲻ��Ϊ��\\n"; } if (content == "") { strErr += "���ݲ���Ϊ��\\n"; } if ((this.dropNewsClass.Items.Count == 0) || (classid.Trim() == "")) { strErr += "û�п���ѡ������\\n"; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } if (Session["UserInfo"] == null) return; LTP.Accounts.Bus.User currentUser = (LTP.Accounts.Bus.User)Session["UserInfo"]; Maticsoft.Model.NewsManage.News news = new Maticsoft.Model.NewsManage.News(); news.NewsId = newid; news.ClassId = int.Parse(classid); news.Heading = heading; news.Focus = focus; news.Content = content; news.Frequency = 0; if (dormancy) { news.Dormancy = "True"; } else { news.Dormancy = "False"; } news.IssueDate = DateTime.Now; news.Priority = 0; news.UserId = currentUser.UserID; if (chkIsTop.Checked) { news.IsTop = 1; } else { news.IsTop = 0; } Maticsoft.BLL.NewsManage.News n = new Maticsoft.BLL.NewsManage.News(); n.Update(news); Response.Redirect("show.aspx?id=" + newid); }
/// <summary> /// 更新一条数据 /// </summary> public void FrequencyAdd(Maticsoft.Model.NewsManage.News model) { dal.FrequencyAdd(model); }