/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id", 0); BLL.article abll = new BLL.article(); if (id > 0) { model = abll.GetModel(id); if (model == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } else { abll.UpdateField(model.id, "click=click+1"); } } DataTable pre_dt = get_article_list("bangongfuwu", model.category_id, 1, "id<" + model.id, "sort_id asc"); if (pre_dt.Rows.Count > 0) { preid = int.Parse(pre_dt.Rows[0]["id"].ToString()); } DataTable next_dt = get_article_list("bangongfuwu", model.category_id, 1, "id>" + model.id, "sort_id asc"); if (next_dt.Rows.Count > 0) { nextid = int.Parse(next_dt.Rows[0]["id"].ToString()); } }
//设置操作 protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value); BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(id); }
/// <summary> /// 取幻灯片信息 /// </summary> /// <param name="wid"></param> /// <param name="topNum">取前几条数据,若为-1,则取全部的数据</param> public IList <Model.article> GetHDPByWid(int wid, int topNum) { IList <Model.article> hdpList = new List <Model.article>(); StringBuilder strSql = new StringBuilder(); strSql.Append("select "); if (topNum >= 0) { strSql.Append(" top " + topNum + " "); } strSql.Append("id,title,link_url,img_url,content,sort_id from dt_article where channel_id=3 and category_id=1 "); strSql.Append(" and wId=@wId order by sort_id asc"); SqlParameter[] parameters = { new SqlParameter("@wId", SqlDbType.Int, 4) }; parameters[0].Value = wid; SqlDataReader sr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters); Model.article hdp = new Model.article(); while (sr.Read()) { hdp = new Model.article(); hdp.id = MyCommFun.Obj2Int(sr["id"]); hdp.title = MyCommFun.ObjToStr(sr["title"]); hdp.link_url = MyCommFun.ObjToStr(sr["link_url"]); hdp.img_url = MyCommFun.ObjToStr(sr["img_url"]); hdp.content = MyCommFun.ObjToStr(sr["content"]); hdp.sort_id = MyCommFun.Obj2Int(sr["sort_id"]); hdpList.Add(hdp); } sr.Close(); return(hdpList); }
/// <summary> /// 获得单页文章列表:优点:(1)使用function标签与foreach结合,可以从模版页面控制记录数量;(2)不需要实现注册到模版里 /// </summary> /// <returns></returns> public IList <Model.article> getDanyeList() { Tag tag = this.Document.CurrentRenderingTag; var attribute = tag.Attributes["rows"]; IList <Model.article> artlist = new List <Model.article>(); int rows = -1;//若为-1,则不做限制条件 if (attribute != null && MyCommFun.isNumber(attribute.Value.GetValue())) { rows = MyCommFun.Obj2Int(attribute.Value.GetValue()); } artlist = tDal.GetDanYeByWid(wid, rows); if (artlist != null && artlist.Count > 0) { Model.article cat = new Model.article(); for (int i = 0; i < artlist.Count; i++) { cat = artlist[i]; if (cat.link_url == null || cat.link_url.Trim() == "") { //如果link_url为空,则直接调用本系统的信息 cat.link_url = MyCommFun.urlAddOpenid("content.aspx?wid=" + wid + "&aid=" + cat.id.ToString(), openid); //"http://localhost:820/content.aspx?wid=5&aid=112"; } else { cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid); } } } return(artlist); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.article GetModel(string channel_name, int article_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,channel_id,category_id,call_index,title,link_url,img_url,seo_title,seo_keywords,seo_description,zhaiyao,content,sort_id,click,status,is_msg,is_top,is_red,is_hot,is_slide,is_sys,user_name,add_time,update_time"); strSql.Append(" from " + databaseprefix + DTKeys.TABLE_CHANNEL_ARTICLE + channel_name); strSql.Append(" where id=@id"); strSql.Append(" limit 1"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32, 4) }; parameters[0].Value = article_id; Model.article model = new Model.article(); DataSet ds = DbHelperMySql.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
private void send_complaint_click(HttpContext context) { Model.article model = new Model.article(); BLL.article bll = new BLL.article(); //姓名 var name = DTRequest.GetString("name"); //电话 var tel = DTRequest.GetString("tel"); //email var email = DTRequest.GetString("email"); //投诉建议 var message = DTRequest.GetString("message"); model.channel_id = 10; model.category_id = 48; model.title = message; model.status = 0; model.fields = new Dictionary <string, string>(); model.fields.Add("name", name); model.fields.Add("tel", tel); model.fields.Add("email", email); model.zhaiyao = message; model.content = message; if (bll.Add(model) > 0) { context.Response.Write("{\"status\": 1, \"msg\": \"恭喜您,投诉建议成功!\"}"); return; } context.Response.Write("{\"status\": 0, \"msg\": \"对不起,保存过程中发生错误!\"}"); }
/// <summary> /// 获得幻灯片列表二:优点:(1)使用function标签与foreach结合,可以从模版页面控制记录数量;(2)不需要实现注册到模版里 /// </summary> /// <returns></returns> public IList <Model.article> getHdp() { Tag tag = this.Document.CurrentRenderingTag; var attribute = tag.Attributes["rows"]; IList <Model.article> artlist = new List <Model.article>(); int rows = -1;//若为-1,则不做限制条件 if (attribute != null && MyCommFun.isNumber(attribute.Value.GetValue())) { rows = MyCommFun.Obj2Int(attribute.Value.GetValue()); } artlist = tDal.GetHDPByWid(wid, rows); if (artlist != null && artlist.Count > 0) { Model.article cat = new Model.article(); for (int i = 0; i < artlist.Count; i++) { cat = artlist[i]; if (cat.link_url == null || cat.link_url.Trim() == "") { //如果link_url为空,则直接调用本系统的信息 cat.link_url = "javascript:;"; } else { cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid); } } } return(artlist); }
//资讯模块 private void digg_article_add(HttpContext context) { string channel_type = DTRequest.GetFormString("channel_type"); string digg_type = DTRequest.GetFormString("digg_type"); int id = DTRequest.GetFormInt("id"); BLL.article bll = new BLL.article(); if (!bll.Exists(id)) { context.Response.Write("{msg:0, msgbox:\"信息不存在或已删除!\"}"); return; } if (digg_type == "good") { bll.UpdateField(id, "digg_good=digg_good+1"); } else { bll.UpdateField(id, "digg_act=digg_act+1"); } Model.article model = bll.GetModel(id); context.Response.Write("{msg:1, digggood:" + model.digg_good + ", diggact:" + model.digg_act + ", msgbox:\"成功顶或踩了一下!\"}"); Utils.WriteCookie(DTKeys.COOKIE_DIGG_KEY, channel_type + id.ToString(), id.ToString(), 8640); return; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.teacher GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,no,name,quota,email,add_time,students,resquota,direction,major,is_aca,is_pro,pro_quota,pro_resquota "); strSql.Append(" from " + databaseprefix + "teacher"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.article model = new Model.article(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
private bool DoEdit(int _id) { bool result = false; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_id); model.call_index = txtCallIndex.Text.Trim(); model.title = txtTitle.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); model.fields = new Dictionary <string, string>(); //内容摘要提取内容前255个字符 if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim())) { model.zhaiyao = Vincent._DTcms.Utils.DropHTML(txtContent.Value, 255); } else { model.zhaiyao = Vincent._DTcms.Utils.DropHTML(txtZhaiyao.Text, 255); } model.content = txtContent.Value; model.update_time = DateTime.Now; if (bll.Update(model)) { AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Edit.ToString(), "修改友情链接频道内容:" + model.title); //记录日志 result = true; } return(result); }
//设置操作 protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { ChkAdminLevel("channel_" + this.channel_name + "_list", DTEnums.ActionEnum.Edit.ToString()); //检查权限 int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value); BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(this.channel_id, id); switch (e.CommandName) { case "lbtnIsMsg": if (model.is_msg == 1) { bll.UpdateField(this.channel_id, id, "is_msg=0"); } else { bll.UpdateField(this.channel_id, id, "is_msg=1"); } break; case "lbtnIsTop": if (model.is_top == 1) { bll.UpdateField(this.channel_id, id, "is_top=0"); } else { bll.UpdateField(this.channel_id, id, "is_top=1"); } break; } this.RptBind(this.channel_id, this.category_id, "id>0" + CombSqlTxt(this.keywords, this.property), "sort_id asc,add_time desc,id desc"); }
/// <summary> /// 是否存在该记录 /// </summary> public bool Exists(string column_name) { //检查是否与文章字段相同 Model.article artModel = new Model.article(); //利用反射获得属性的所有公共属性 Type modelType = artModel.GetType(); PropertyInfo[] proInfo = modelType.GetProperties(); foreach (PropertyInfo pi in proInfo) { if (pi.Name.ToLower() == column_name.ToLower()) { return(true); } } //检查是否与扩展字段表列相同 StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) from " + databaseprefix + "article_attribute_field"); strSql.Append(" where name=@name "); SqlParameter[] parameters = { new SqlParameter("@name", SqlDbType.NVarChar, 100) }; parameters[0].Value = column_name; if (DbHelperSQL.Exists(strSql.ToString(), parameters)) { return(true); } return(false); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.student GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,no,name,school,score,re_score,add_time,teacher_id,status,is_aca,attach "); strSql.Append(" from " + databaseprefix + "student"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.article model = new Model.article(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
private bool DoEdit(int _id) { bool result = true; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_id); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.category_id = int.Parse(ddlCategoryId.SelectedValue); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.author = txtAuthor.Text.Trim(); model.form = txtForm.Text.Trim(); model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 250); model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim(); model.seo_description = txtSeoDescription.Text.Trim(); model.sort_id = int.Parse(txtSortId.Text.Trim()); model.click = int.Parse(txtClick.Text.Trim()); model.content = txtContent.Value; model.is_msg = 0; model.is_top = 0; model.is_red = 0; model.is_hot = 0; model.is_slide = 0; model.is_lock = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_top = 1; } if (cblItem.Items[2].Selected == true) { model.is_red = 1; } if (cblItem.Items[3].Selected == true) { model.is_hot = 1; } if (cblItem.Items[4].Selected == true) { model.is_slide = 1; } if (cblItem.Items[5].Selected == true) { model.is_lock = 1; } if (!bll.Update(model)) { result = false; } return(result); }
//设置操作 protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { ChkAdminLevel("channel_" + this.channel_name + "_list", DTEnums.ActionEnum.Edit.ToString()); //检查权限 int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value); BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(id); this.RptBind(this.channel_id, this.category_id, "id>0" + CombSqlTxt(this.keywords, this.property), "sort_id asc,add_time desc,id desc"); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("channel_" + this.channel_name + "_recycle", DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; //成功数量 int errorCount = 0; //失败数量 BLL.article bll = new BLL.article(); Repeater rptList = this.rptList1; //获取站点信息 Model.channel_site site = new BLL.channel_site().GetSiteModel(this.channel_id); //循环删除 for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { Model.article model = bll.GetModel(id); if (null != model) { if (bll.Delete(id)) { sucCount++; //是否开启百度推送 if (site.bdsend == 1 && !string.IsNullOrEmpty(site.bdtoken)) { string url = get_url_rewrite(channel_name, "detail", model.call_index, model.id); if (!string.IsNullOrEmpty(url)) { if (string.IsNullOrEmpty(site.domain)) { url = siteConfig.weburl + url; } else { url = site.domain + url; } SeoHelper.BaiduDel(url, site.bdtoken); } } } else { errorCount++; } } else { errorCount++; } } } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "删除" + this.channel_name + "频道内容成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("recycle_list.aspx", "channel_id={0}&category_id={1}&keywords={2}&property={3}", this.channel_id.ToString(), this.category_id.ToString(), this.keywords, this.property)); }
private void ShowInfo(int _id) { BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_id); ddlCategoryId.SelectedValue = model.category_id.ToString(); txtCallIndex.Text = model.call_index; txtTitle.Text = model.title; txtLinkUrl.Text = model.link_url; //不是相册图片就绑定 string filename = model.img_url.Substring(model.img_url.LastIndexOf("/") + 1); if (!filename.StartsWith("thumb_")) { txtImgUrl.Text = model.img_url; } txtSeoTitle.Text = model.seo_title; txtSeoKeywords.Text = model.seo_keywords; txtSeoDescription.Text = model.seo_description; txtZhaiyao.Text = model.zhaiyao; txtContent.Value = model.content; txtSortId.Text = model.sort_id.ToString(); txtClick.Text = model.click.ToString(); rblStatus.SelectedValue = model.status.ToString(); txtAddTime.Text = model.add_time.ToString("yyyy-MM-dd HH:mm:ss"); if (model.is_msg == 1) { cblItem.Items[0].Selected = true; } if (model.is_top == 1) { cblItem.Items[1].Selected = true; } if (model.is_red == 1) { cblItem.Items[2].Selected = true; } if (model.is_hot == 1) { cblItem.Items[3].Selected = true; } if (model.is_slide == 1) { cblItem.Items[4].Selected = true; } //绑定图片相册 if (filename.StartsWith("thumb_")) { hidFocusPhoto.Value = model.img_url; //封面图片 } rptAlbumList.DataSource = model.albums; rptAlbumList.DataBind(); //绑定内容附件 rptAttachList.DataSource = model.attach; rptAttachList.DataBind(); }
private void ShowInfo(int article_id) { article_model = bll.GetModel(article_id, start_time, end_time); //绑定商品规格 List <Model.article_goods_spec> goodsSpecList = new BLL.article_goods_spec().GetList(article_model.id, ""); hide_goods_spec_list.Value = JsonHelper.ObjectToJSON(goodsSpecList); rptGroupPrice.DataSource = article_model.goods; rptGroupPrice.DataBind(); }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { BLL.article bll = new BLL.article(); model = bll.GetModel("about"); if (model == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } }
private void ShowInfo(int _id) { BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_id); txtCallIndex.Text = model.call_index; txtTitle.Text = model.title; txtLinkUrl.Text = model.link_url; txtZhaiyao.Text = model.zhaiyao; txtContent.Value = model.content; }
/// <summary> /// 获得购物车列表 /// </summary> public static IList <Model.cart_items> GetList(int group_id) { IDictionary <string, int> dic = GetCart(); if (dic != null) { IList <Model.cart_items> iList = new List <Model.cart_items>(); foreach (var item in dic) { BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(Convert.ToInt32(item.Key)); if (model == null || !model.fields.ContainsKey("sell_price")) { continue; } Model.cart_items modelt = new Model.cart_items(); modelt.id = model.id; modelt.title = model.title; modelt.img_url = model.img_url; if (model.fields.ContainsKey("point")) { modelt.point = Utils.StrToInt(model.fields["point"], 0); } modelt.price = Utils.StrToDecimal(model.fields["WholesalePrice"], 0); modelt.user_price = Utils.StrToDecimal(model.fields["sell_price"], 0); if (model.fields.ContainsKey("stock_quantity")) { modelt.stock_quantity = Utils.StrToInt(model.fields["stock_quantity"], 0); } if (model.fields.ContainsKey("english_name")) { modelt.english_name = model.fields["english_name"].ToString(); } if (model.fields.ContainsKey("Barcode")) { modelt.Barcode = model.fields["Barcode"].ToString(); } ////会员价格 //if (model.group_price != null) //{ // Model.user_group_price gmodel = model.group_price.Find(p => p.group_id == group_id); // if (gmodel != null) // { // modelt.user_price = gmodel.price; // } //} modelt.quantity = item.Value; iList.Add(modelt); } return(iList); } return(null); }
public void ArticleDetailPage() { DAL.article artDal = new DAL.article(); int aid = MyCommFun.RequestInt("aid"); Model.article article = artDal.GetModel(aid); if (article != null) { this.Document.SetValue("model", article); } }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { var dbContext = new Agp2pDataContext(); id = DTRequest.GetQueryInt("id"); category_id = DTRequest.GetQueryInt("category_id"); page = DTRequest.GetQueryString("page"); BLL.article bll = new BLL.article(); if (0 < id) //如果ID获取到,将使用ID { if (!bll.Exists(id)) { //HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); HttpContext.Current.Response.Redirect(linkurl("404")); return; } model = bll.GetModel(id); } else if (!string.IsNullOrEmpty(page)) //否则检查设置的别名 { if (!bll.Exists(page)) { HttpContext.Current.Response.Redirect(linkurl("404")); return; } model = bll.GetModel(page); } else { return; } model.click += 1; bll.Update(model); categoryTitle = dbContext.dt_article_category.Single(c => c.id == model.category_id).title; article_attr = dbContext.dt_article_attribute_value.FirstOrDefault(u => u.article_id == model.id); if (article_attr == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } //跳转URL if (model.link_url != null) { model.link_url = model.link_url.Trim(); } if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } }
private void GetModel(int id) { BLL.article bll = new BLL.article(); model = bll.GetModel(id); if (model != null) { RepNewsRed(model.category_id); BindPrev(model.category_id, model.id); BindNext(model.category_id, model.id); } }
public void ArticleDetailPage() { DAL.article artDal = new DAL.article(); int aid = MyCommFun.RequestInt("aid"); Model.article article = artDal.GetModel(aid); if (article != null) { this.Document.SetValue("model", article); this.Document.SetValue("fxTitle", article.title); this.Document.SetValue("fxDesc", article.zhaiyao); this.Document.SetValue("fxPic", MyCommFun.ImgAddHttp(article.img_url)); } }
protected void Page_Load(object sender, EventArgs e) { id = MXRequest.GetQueryInt("id"); wid = MXRequest.GetQueryInt("wid"); openid = MyCommFun.RequestOpenid(); if (!IsPostBack) { BLL.article aBll = new BLL.article(); if (id > 0) { aModel = aBll.GetModel(id); } } }
protected Model.channel channelModel = new Model.channel(); //频道的实体 /// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); call_index = Utils.SafeXXS(DTRequest.GetQueryString("call_index")); BLL.article bll = new BLL.article(); if (id > 0) //如果ID获取到,将使用ID { if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(linkurl("error")); return; } model = bll.GetModel(id); } else if (!string.IsNullOrEmpty(call_index)) //否则检查设置的别名 { if (!bll.Exists(call_index)) { HttpContext.Current.Response.Redirect(linkurl("error")); return; } model = bll.GetModel(call_index); //赋值文章ID id = model.id; } else { HttpContext.Current.Response.Redirect(linkurl("error")); return; } //判断是否是链接 if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); return; } //判断SEO标题 if (string.IsNullOrEmpty(model.seo_title) || "" == model.seo_title) { model.seo_title = model.title; } //获取频道内容 channelModel = new BLL.channel().GetModel(model.channel_id); //获取类别内容 categoryModel = new BLL.article_category().GetModel(model.category_id); }
/// <summary> /// 获取微信推送实体 /// </summary> public Model.article GetWXModel(int id) { DataTable dt = dal.GetList(1, "id=" + id, "id desc").Tables[0]; if (dt.Rows.Count == 0) { return(null); } Model.article model = new Model.article(); model.id = int.Parse(dt.Rows[0]["id"].ToString()); model.title = dt.Rows[0]["title"].ToString(); model.img_url = dt.Rows[0]["img_url"].ToString(); model.zhaiyao = dt.Rows[0]["zhaiyao"].ToString(); model.content = dt.Rows[0]["content"].ToString(); return(model); }
private void ShowInfo(int _id) { BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_id); ddlCategoryId.SelectedValue = model.category_id.ToString(); txtTitle.Text = model.title; txtAuthor.Text = model.author; txtForm.Text = model.form; txtZhaiyao.Text = model.zhaiyao; txtImgUrl.Text = model.img_url; txtLinkUrl.Text = model.link_url; if (model.is_msg == 1) { cblItem.Items[0].Selected = true; } if (model.is_top == 1) { cblItem.Items[1].Selected = true; } if (model.is_red == 1) { cblItem.Items[2].Selected = true; } if (model.is_hot == 1) { cblItem.Items[3].Selected = true; } if (model.is_slide == 1) { cblItem.Items[4].Selected = true; } if (model.is_lock == 1) { cblItem.Items[5].Selected = true; } txtSortId.Text = model.sort_id.ToString(); txtClick.Text = model.click.ToString(); txtDiggGood.Text = model.digg_good.ToString(); txtDiggAct.Text = model.digg_act.ToString(); txtContent.Value = model.content; txtSeoTitle.Text = model.seo_title; txtSeoKeywords.Text = model.seo_keywords; txtSeoDescription.Text = model.seo_description; }
/// <summary> /// 获取扩展字段的值 /// </summary> /// <param name="call_index">调用别名</param> /// <param name="field_name">扩展字段名</param> /// <returns>String</returns> protected string get_article_field(string call_index, string field_name) { if (string.IsNullOrEmpty(call_index)) { return(string.Empty); } BLL.article bll = new BLL.article(); if (!bll.Exists(call_index)) { return(string.Empty); } Model.article model = bll.GetModel(call_index); if (model != null && model.fields.ContainsKey(field_name)) { return(model.fields[field_name]); } return(string.Empty); }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); BLL.article bll = new BLL.article(); if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")); return; } model = bll.GetModel(id); //浏览数+1 bll.UpdateField(id, "click=click+1"); //跳转URL if (model.link_url != null) model.link_url = model.link_url.Trim(); if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { help_id = DTRequest.GetQueryInt("help_id"); BLL.article bll = new BLL.article(); model = bll.GetModel("about"); if (model == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } if (help_id > 0) { model_bk = bll.GetModel(help_id); if (model_bk == null) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } } }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); page = DTRequest.GetQueryString("page"); BLL.article bll = new BLL.article(); if (id > 0) //如果ID获取到,将使用ID { if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除!"))); return; } model = bll.GetModel(id); } else if (!string.IsNullOrEmpty(page)) //否则检查设置的别名 { if (!bll.Exists(page)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除!"))); return; } model = bll.GetModel(page); } else { return; } //跳转URL if (model.link_url != null) { model.link_url = model.link_url.Trim(); } if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); page = DTRequest.GetQueryString("page"); BLL.article bll = new BLL.article(); if (id > 0) //如果ID获取到,将使用ID { if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } model = bll.GetModel(id); } else if (!string.IsNullOrEmpty(page)) //否则检查设置的别名 { if (!bll.Exists(page)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!"))); return; } model = bll.GetModel(page); } else { return; } //跳转URL if (model.link_url != null) model.link_url = model.link_url.Trim(); if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } //销量 DataTable dt_order_good_count = new BLL.orders().get_order_good_count(id).Tables[0]; if (dt_order_good_count != null && dt_order_good_count.Rows.Count > 0) { order_sum = Convert.ToDecimal(dt_order_good_count.Rows[0]["quantity"]); } Model.article_category model_category = new BLL.article_category().GetModel(model.category_id); #region //规格表 BLL.standard_price bll_standard_price = new BLL.standard_price(); DataTable dt_standard_price = bll_standard_price.GetList("good_id=" + id).Tables[0]; if (dt_standard_price != null && dt_standard_price.Rows.Count > 0) { BLL.standard bll_standard = new BLL.standard(); if (model_category != null) { DataTable dt_old_standard = bll_standard.GetList("'" + model_category.class_list + "' like '%,'+convert(nvarchar(10),category_id)+',%'").Tables[0]; dt_standard.Columns.Add("id", typeof(int)); dt_standard.Columns.Add("title", typeof(string)); dt_standard.Columns.Add("value", typeof(string)); dt_standard.PrimaryKey = new DataColumn[] { dt_standard.Columns["id"] }; foreach (DataRow dr in dt_old_standard.Rows) { //if(Convert.ToInt32(dr[""])) DataRow new_dr = dt_standard.NewRow(); new_dr["id"] = dr["id"]; new_dr["title"] = dr["title"]; DataTable dt_standard_value = new BLL.standard_value().GetList("standard_id=" + dr["id"].ToString()).Tables[0]; if (dt_standard_value != null || dt_standard_value.Rows.Count > 0) { string str_value = ""; foreach (DataRow dr_value in dt_standard_value.Rows) { str_value += dr_value["id"].ToString() + "|" + dr_value["value"].ToString() + ","; } new_dr["value"] = str_value.TrimEnd(','); dt_standard.Rows.Add(new_dr); } } } } #endregion //单位表 BLL.unit bll_unit = new BLL.unit(); dt_unit = bll_unit.GetList("good_id=" + id).Tables[0]; //套餐() BLL.meal_good bll_meal_good = new BLL.meal_good(); BLL.meal bll_meal = new BLL.meal(); dt_meal = bll_meal.GetMealByGood(id, "jiejuefangan").Tables[0]; dt_meal.TableName = "dt_meal"; if (dt_meal != null && dt_meal.Rows.Count > 0) { //套餐商品 DataTable old_dt_meal_good = bll_meal_good.GetList("meal_id=" + dt_meal.Rows[0]["id"].ToString()).Tables[0]; dt_meal_good = new DataTable(); dt_meal_good.Columns.Add("meal_id"); dt_meal_good.Columns.Add("good_standard_price"); dt_meal_good.Columns.Add("title"); dt_meal_good.Columns.Add("all_title"); dt_meal_good.Columns.Add("img_url"); dt_meal_good.Columns.Add("good_id"); dt_meal_good.Columns.Add("price"); string str_meal_good_ids = ","; if (old_dt_meal_good != null && old_dt_meal_good.Rows.Count > 0) { foreach (DataRow dr in old_dt_meal_good.Rows) { if (str_meal_good_ids.IndexOf("," + dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",") > -1) { continue; } str_meal_good_ids += dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ","; Model.article modelt = bll.GetModel(Convert.ToInt32(dr["good_id"])); if (modelt != null) { Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"])); string str_standard_price = ""; string str_unit = ""; if (model_standard_price != null) { for (int i = 0; i < model_standard_price.standards.Split(',').Length; i++) { if (!string.IsNullOrEmpty(model_standard_price.standards.Split(',')[i])) { str_standard_price += model_standard_price.standards.Split(',')[i]; if (i < model_standard_price.standard_values.Split(',').Length) { str_standard_price += ":" + model_standard_price.standard_values.Split(',')[i]; } } } } Model.unit model_unit = bll_unit.GetModel(Convert.ToDecimal(dr["unit_id"])); if (model_unit != null) { str_unit += "单位:" + model_unit.title + (string.IsNullOrEmpty(model_unit.content) ? "" : model_unit.content); } DataRow new_dr = dt_meal_good.NewRow(); new_dr["meal_id"] = dr["meal_id"]; new_dr["title"] = Utils.CutString(modelt.title, 10); new_dr["good_standard_price"] = dr["good_id"].ToString() + dr["standard_price_id"].ToString(); new_dr["all_title"] = modelt.title + " " + str_standard_price + str_unit; new_dr["img_url"] = modelt.img_url; new_dr["price"] = dr["sell_price"]; new_dr["good_id"] = dr["good_id"]; dt_meal_good.Rows.Add(new_dr); } } dt_meal_good.TableName = "dt_meal_good"; } } //属性表 BLL.property_good bll_property_good = new BLL.property_good(); BLL.property bll_property = new BLL.property(); BLL.property_value bll_property_value = new BLL.property_value(); DataTable dt_old_property = bll_property_good.GetList("good_id=" + id).Tables[0]; dt_property.Columns.Add("id"); dt_property.Columns.Add("title"); dt_property.Columns.Add("value"); dt_property.PrimaryKey = new DataColumn[] { dt_property.Columns["id"] }; foreach (DataRow dr in dt_old_property.Rows) { Model.property model_property = bll_property.GetModel(Convert.ToInt32(dr["property_id"])); Model.property_value model_property_value = bll_property_value.GetModel(Convert.ToDecimal(dr["property_value_id"])); if (model != null && model_property_value!=null) { if (dt_property.Rows.Find(dr["property_id"]) != null) { dt_property.Rows.Find(dr["property_id"])["value"] = dt_property.Rows.Find(dr["property_id"])["value"].ToString() + "," + model_property_value.value; } else { DataRow new_dr = dt_property.NewRow(); new_dr["id"] = dr["property_id"]; new_dr["title"] = model_property.title; new_dr["value"] = model_property_value.value; dt_property.Rows.Add(new_dr); } } } //标签 BLL.tag_good bll_tag_good = new BLL.tag_good(); DataTable dt_tag_good = bll_tag_good.GetList("good_id=" + id).Tables[0]; dt_tag.Columns.Add("title"); foreach (DataRow dr in dt_tag_good.Rows) { Model.tag model_tag = new BLL.tag().GetModel(Convert.ToInt32(dr["tag_id"])); if (model_tag != null) { DataRow new_dr = dt_tag.NewRow(); new_dr["title"] = model_tag.title; dt_tag.Rows.Add(new_dr); } } //推荐搭配 dt_red = bll_meal.GetMealByGood(id, "tuijiandapei").Tables[0]; dt_red.TableName = "dt_red"; if (dt_red != null && dt_red.Rows.Count > 0) { DataTable old_dt_red_good = bll_meal_good.GetList("meal_id=" + dt_red.Rows[0]["id"].ToString()).Tables[0]; dt_red_good = new DataTable(); dt_red_good.Columns.Add("meal_id"); dt_red_good.Columns.Add("good_standard_price"); dt_red_good.Columns.Add("title"); dt_red_good.Columns.Add("all_title"); dt_red_good.Columns.Add("good_id"); dt_red_good.Columns.Add("img_url"); dt_red_good.Columns.Add("price"); string str_red_good_ids = ","; if (old_dt_red_good != null && old_dt_red_good.Rows.Count > 0) { foreach (DataRow dr in old_dt_red_good.Rows) { if (str_red_good_ids.IndexOf("," + dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",") > -1) { continue; } str_red_good_ids += dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ","; Model.article modelt = bll.GetModel(Convert.ToInt32(dr["good_id"])); if (modelt != null) { Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"])); string str_standard_price = ""; string str_unit = ""; if (model_standard_price != null) { for (int i = 0; i < model_standard_price.standards.Split(',').Length; i++) { if (!string.IsNullOrEmpty(model_standard_price.standards.Split(',')[i])) { str_standard_price += model_standard_price.standards.Split(',')[i]; if (i < model_standard_price.standard_values.Split(',').Length) { str_standard_price += ":" + model_standard_price.standard_values.Split(',')[i]; } } } } Model.unit model_unit = bll_unit.GetModel(Convert.ToDecimal(dr["unit_id"])); if (model_unit != null) { str_unit += "单位:" + model_unit.title + (string.IsNullOrEmpty(model_unit.content) ? "" : model_unit.content); } DataRow new_dr = dt_red_good.NewRow(); new_dr["meal_id"] = dr["meal_id"]; new_dr["title"] = Utils.CutString(modelt.title, 10); new_dr["good_standard_price"] = dr["good_id"].ToString() + dr["standard_price_id"].ToString(); new_dr["all_title"] = modelt.title + " " + str_standard_price + str_unit; new_dr["img_url"] = modelt.img_url; new_dr["price"] = dr["sell_price"]; new_dr["good_id"] = dr["good_id"]; dt_red_good.Rows.Add(new_dr); } } dt_red_good.TableName = "dt_red_good"; } } //类别相关 if (model_category != null) { if (new BLL.article_category().GetModel(model_category.parent_id) != null) { parent_category_title = new BLL.article_category().GetModel(model_category.parent_id).title; dt_category = new BLL.article_category().GetList(model_category.parent_id, "goods"); } dt_other_goods = bll.get_order_buy_good(5, model_category.id).Tables[0]; } }
private bool DoAdd() { Model.wx_userweixin weixin = GetWeiXinCode(); bool result = false; Model.article model = new Model.article(); BLL.article bll = new BLL.article(); model.channel_id = this.channel_id; model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0); model.call_index = txtCallIndex.Text.Trim(); model.title = txtTitle.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text; model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim(); model.seo_description = txtSeoDescription.Text.Trim(); model.wid = weixin.id; //内容摘要提取内容前255个字符 if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim())) { model.zhaiyao = Utils.DropHTML(txtContent.Value, 255); } else { model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 255); } model.content = txtContent.Value; model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); model.click = int.Parse(txtClick.Text.Trim()); model.status = Utils.StrToInt(rblStatus.SelectedValue, 0); model.is_msg = 0; model.is_top = 0; model.is_red = 0; model.is_hot = 0; model.is_slide = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_top = 1; } if (cblItem.Items[2].Selected == true) { model.is_red = 1; } if (cblItem.Items[3].Selected == true) { model.is_hot = 1; } if (cblItem.Items[4].Selected == true) { model.is_slide = 1; } model.is_sys = 1; //管理员发布 model.user_name = "admin"; //获得当前登录用户名 model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.fields = SetFieldValues(this.channel_id); //扩展字段赋值 #region 保存相册==================== //检查是否有自定义图片 if (txtImgUrl.Text.Trim() == "") { model.img_url = hidFocusPhoto.Value; } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null && albumArr.Length > 0) { List<Model.article_albums> ls = new List<Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { original_path = imgArr[1], thumb_path = imgArr[2] }); } } } model.albums = ls; } #endregion #region 保存附件==================== //保存附件 string[] attachFileNameArr = Request.Form.GetValues("hid_attach_filename"); string[] attachFilePathArr = Request.Form.GetValues("hid_attach_filepath"); string[] attachFileSizeArr = Request.Form.GetValues("hid_attach_filesize"); string[] attachPointArr = Request.Form.GetValues("txt_attach_point"); if (attachFileNameArr != null && attachFilePathArr != null && attachFileSizeArr != null && attachPointArr != null && attachFileNameArr.Length > 0 && attachFilePathArr.Length > 0 && attachFileSizeArr.Length > 0 && attachPointArr.Length > 0) { List<Model.article_attach> ls = new List<Model.article_attach>(); for (int i = 0; i < attachFileNameArr.Length; i++) { int fileSize = Utils.StrToInt(attachFileSizeArr[i], 0); string fileExt = Utils.GetFileExt(attachFilePathArr[i]); int _point = Utils.StrToInt(attachPointArr[i], 0); ls.Add(new Model.article_attach { file_name = attachFileNameArr[i], file_path = attachFilePathArr[i], file_size = fileSize, file_ext = fileExt, point = _point }); } model.attach = ls; } #endregion #region 保存会员组价格============== List<Model.user_group_price> priceList = new List<Model.user_group_price>(); for (int i = 0; i < rptPrice.Items.Count; i++) { int _groupid = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hideGroupId")).Value); decimal _price = Convert.ToDecimal(((TextBox)rptPrice.Items[i].FindControl("txtGroupPrice")).Text.Trim()); priceList.Add(new Model.user_group_price { group_id = _groupid, price = _price }); } model.group_price = priceList; #endregion if (bll.Add(model) > 0) { //开始生成缩略图咯 AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "微网站添加" + this.channel_name + "频道内容:" + model.title); //记录日志 result = true; } return result; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.article GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,channel_id,category_id,call_index,title,link_url,img_url,seo_title,seo_keywords,seo_description,tags,zhaiyao,content,sort_id,click,status,is_msg,is_top,is_red,is_hot,is_slide,is_sys,user_name,add_time,update_time"); strSql.Append(" from " + databaseprefix + "article"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Model.article model = new Model.article(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 将对象转换为实体 /// </summary> private Model.article DataRowToModel(DataRow row) { Model.article model = new Model.article(); if (row != null) { #region 主表信息====================== if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["channel_id"] != null && row["channel_id"].ToString() != "") { model.channel_id = int.Parse(row["channel_id"].ToString()); } if (row["category_id"] != null && row["category_id"].ToString() != "") { model.category_id = int.Parse(row["category_id"].ToString()); } if (row["call_index"] != null) { model.call_index = row["call_index"].ToString(); } if (row["title"] != null) { model.title = row["title"].ToString(); } if (row["link_url"] != null) { model.link_url = row["link_url"].ToString(); } if (row["img_url"] != null) { model.img_url = row["img_url"].ToString(); } if (row["seo_title"] != null) { model.seo_title = row["seo_title"].ToString(); } if (row["seo_keywords"] != null) { model.seo_keywords = row["seo_keywords"].ToString(); } if (row["seo_description"] != null) { model.seo_description = row["seo_description"].ToString(); } if (row["tags"] != null) { model.tags = row["tags"].ToString(); } if (row["zhaiyao"] != null) { model.zhaiyao = row["zhaiyao"].ToString(); } if (row["content"] != null) { model.content = row["content"].ToString(); } if (row["sort_id"] != null && row["sort_id"].ToString() != "") { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (row["click"] != null && row["click"].ToString() != "") { model.click = int.Parse(row["click"].ToString()); } if (row["status"] != null && row["status"].ToString() != "") { model.status = int.Parse(row["status"].ToString()); } if (row["is_msg"] != null && row["is_msg"].ToString() != "") { model.is_msg = int.Parse(row["is_msg"].ToString()); } if (row["is_top"] != null && row["is_top"].ToString() != "") { model.is_top = int.Parse(row["is_top"].ToString()); } if (row["is_red"] != null && row["is_red"].ToString() != "") { model.is_red = int.Parse(row["is_red"].ToString()); } if (row["is_hot"] != null && row["is_hot"].ToString() != "") { model.is_hot = int.Parse(row["is_hot"].ToString()); } if (row["is_slide"] != null && row["is_slide"].ToString() != "") { model.is_slide = int.Parse(row["is_slide"].ToString()); } if (row["is_sys"] != null && row["is_sys"].ToString() != "") { model.is_sys = int.Parse(row["is_sys"].ToString()); } if (row["user_name"] != null) { model.user_name = row["user_name"].ToString(); } if (row["add_time"] != null && row["add_time"].ToString() != "") { model.add_time = DateTime.Parse(row["add_time"].ToString()); } if (row["update_time"] != null && row["update_time"].ToString() != "") { model.update_time = DateTime.Parse(row["update_time"].ToString()); } #endregion //扩展字段信息 model.fields = new article_attribute_field(databaseprefix).GetFields(model.channel_id, model.id, string.Empty); //相册信息 model.albums = new article_albums(databaseprefix).GetList(model.id); //附件信息 model.attach = new article_attach(databaseprefix).GetList(model.id); //商品价格 model.goods = new article_goods(databaseprefix).GetList(model.id); } return model; }
private bool DoAdd() { bool result = false; Model.article model = new Model.article(); BLL.article bll = new BLL.article(); model.channel_id = this.channel_id; model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0); model.call_index = txtCallIndex.Text.Trim(); model.title = txtTitle.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text; model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim(); model.seo_description = txtSeoDescription.Text.Trim(); model.is_put = 1; if (isPut.Items[0].Selected) { model.is_put = 0; } //内容摘要提取内容前255个字符 if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim())) { model.zhaiyao = Utils.DropHTML(txtContent.Value, 255); } else { model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 255); } model.content = txtContent.Value; model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); model.click = int.Parse(txtClick.Text.Trim()); model.status = Utils.StrToInt(rblStatus.SelectedValue, 0); model.is_msg = 0; model.is_top = 0; model.is_red = 0; model.is_hot = 0; model.is_slide = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_top = 1; } if (cblItem.Items[2].Selected == true) { model.is_red = 1; } if (cblItem.Items[3].Selected == true) { model.is_hot = 1; } if (cblItem.Items[4].Selected == true) { model.is_slide = 1; } model.is_sys = 1; //管理员发布 model.user_name = "admin"; //获得当前登录用户名 model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.fields = SetFieldValues(this.channel_id); //扩展字段赋值 #region 保存相册==================== //检查是否有自定义图片 if (txtImgUrl.Text.Trim() == "") { model.img_url = hidFocusPhoto.Value; } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null && albumArr.Length > 0) { List<Model.article_albums> ls = new List<Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { original_path = imgArr[1], thumb_path = imgArr[2] }); } } } model.albums = ls; } #endregion #region 保存附件==================== //保存附件 string[] attachFileNameArr = Request.Form.GetValues("hid_attach_filename"); string[] attachFilePathArr = Request.Form.GetValues("hid_attach_filepath"); string[] attachFileSizeArr = Request.Form.GetValues("hid_attach_filesize"); string[] attachPointArr = Request.Form.GetValues("txt_attach_point"); if (attachFileNameArr != null && attachFilePathArr != null && attachFileSizeArr != null && attachPointArr != null && attachFileNameArr.Length > 0 && attachFilePathArr.Length > 0 && attachFileSizeArr.Length > 0 && attachPointArr.Length > 0) { List<Model.article_attach> ls = new List<Model.article_attach>(); for (int i = 0; i < attachFileNameArr.Length; i++) { int fileSize = Utils.StrToInt(attachFileSizeArr[i], 0); string fileExt = Utils.GetFileExt(attachFilePathArr[i]); int _point = Utils.StrToInt(attachPointArr[i], 0); ls.Add(new Model.article_attach { file_name = attachFileNameArr[i], file_path = attachFilePathArr[i], file_size = fileSize, file_ext = fileExt, point = _point }); } model.attach = ls; } #endregion #region 保存会员组价格============== List<Model.user_group_price> priceList = new List<Model.user_group_price>(); for (int i = 0; i < rptPrice.Items.Count; i++) { int _groupid = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hideGroupId")).Value); decimal _price = Convert.ToDecimal(((TextBox)rptPrice.Items[i].FindControl("txtGroupPrice")).Text.Trim()); priceList.Add(new Model.user_group_price { group_id = _groupid, price = _price }); } model.group_price = priceList; #endregion int _id = bll.Add(model); if (_id > 0) { #region 商品相关 if (channel_name == "goods") { #region 规格相关 //规格 string standard_ids = DTRequest.GetFormString("ck_standard"); string standard_value_ids = DTRequest.GetFormString("ck_standard_value"); //string good_nos = DTRequest.GetFormString("good_no"); string str_standards = ""; BLL.standard bll_standard = new BLL.standard(); string[] str_standard_arr = standard_ids.Split(','); foreach (string str in str_standard_arr) { if (!string.IsNullOrEmpty(str)) { Model.standard model_standard = bll_standard.GetModel(Convert.ToInt32(str)); if (model_standard != null) { str_standards += model_standard.title + ","; } } } BLL.standard_price bll_price = new BLL.standard_price(); BLL.standard_value bll_value = new BLL.standard_value(); string[] str_standard_value_arr = standard_value_ids.Split(','); foreach (string str in str_standard_value_arr) { if (!string.IsNullOrEmpty(str)) { string str_title = ""; string[] str_arr = str.Split('_'); foreach (string s in str_arr) { if (!string.IsNullOrEmpty(s)) { Model.standard_value model_value = bll_value.GetModel(Convert.ToInt32(s)); if (model_value != null) { str_title += model_value.value + ","; } } } Model.standard_price model_price = new Model.standard_price(); model_price.good_no = DTRequest.GetFormString("good_no_" + str); model_price.good_id = _id; model_price.standard_ids = standard_ids; model_price.standards = str_standards.Substring(0, str_standards.Length - 1); model_price.standard_value_ids = str.Replace('_', ','); model_price.standard_values = str_title.Substring(0, str_title.Length - 1); model_price.stock_quantity = DTRequest.GetFormInt("stock_quantity_" + str, 0); model_price.market_price = DTRequest.GetFormDecimal("market_price_" + str, 0); model_price.sell_price = DTRequest.GetFormDecimal("sell_price_" + str, 0); model_price.action_price = DTRequest.GetFormDecimal("action_price_" + str, 0); model_price.user_price = 0; model_price.add_time = DateTime.Now; decimal _standard_price_id = bll_price.Add(model_price); if (_standard_price_id <= 0) { JscriptMsg("规格价格添加失败!", "", "Error"); return false; } //规格会员组价格 BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price(); BLL.user_groups bll_user_group = new BLL.user_groups(); DataTable dt_user_group = bll_user_group.GetList(0, "", "grade asc,id desc").Tables[0]; foreach (DataRow dr_user_group in dt_user_group.Rows) { Model.standard_group_price model_standard_group_price = new Model.standard_group_price(); model_standard_group_price.good_id = _id; model_standard_group_price.group_id = Convert.ToInt32(dr_user_group["id"]); model_standard_group_price.standard_price_id = _standard_price_id; model_standard_group_price.group_price = DTRequest.GetFormDecimal("user_price_" + dr_user_group["id"] + "_" + str, 0); model_standard_group_price.add_time = DateTime.Now; if (bll_standard_group_price.Add(model_standard_group_price) <= 0) { JscriptMsg("规格会员价格添加失败!", "", "Error"); return false; } } } } #endregion //单位 string str_unit = DTRequest.GetFormString("ck_unit"); if (!string.IsNullOrEmpty(str_unit)) { BLL.unit bll_unit = new BLL.unit(); string[] arr_unit = str_unit.Split(','); foreach (string s_unit in arr_unit) { if (!string.IsNullOrEmpty(s_unit)) { string[] unit = s_unit.Split('_'); Model.unit model_unit = new Model.unit(); model_unit.good_id = _id; model_unit.title = unit[0]; model_unit.quantity = Convert.ToInt32(unit[1]); model_unit.rate = Convert.ToDecimal(unit[2]); model_unit.content = unit[3]; model_unit.add_time = DateTime.Now; if (bll_unit.Add(model_unit) <= 0) { JscriptMsg("单位添加失败!", "", "Error"); return false; } } } } //别名 BLL.alias_good bll_alias_good = new BLL.alias_good(); for (int i = 0; i < ck_alias.Items.Count; i++) { if (ck_alias.Items[i].Selected) { Model.alias_good model_alias_good = new Model.alias_good(); model_alias_good.alias_id = Convert.ToInt32(ck_alias.Items[i].Value); model_alias_good.good_id = _id; bll_alias_good.Add(model_alias_good); } } //属性 BLL.property_value bll_property_value = new BLL.property_value(); BLL.property_good bll_property_good = new BLL.property_good(); string str_property_value = DTRequest.GetFormString("ck_property_value"); if (!string.IsNullOrEmpty(str_property_value)) { string[] arr_property_value = str_property_value.Split(','); foreach (string str_1 in arr_property_value) { Model.property_good model_property_good = new Model.property_good(); model_property_good.good_id = _id; model_property_good.property_value_id = Convert.ToInt32(str_1); Model.property_value model_property_value = bll_property_value.GetModel(Convert.ToInt32(str_1)); if (model_property_value != null) { model_property_good.property_id = model_property_value.property_id; } bll_property_good.Add(model_property_good); } } //标签 BLL.tag_good bll_tag_good = new BLL.tag_good(); for (int i = 0; i < ck_tag.Items.Count; i++) { if (ck_tag.Items[i].Selected) { Model.tag_good model_tag_good = new Model.tag_good(); model_tag_good.tag_id = Convert.ToInt32(ck_tag.Items[i].Value); model_tag_good.good_id = _id; bll_tag_good.Add(model_tag_good); } } } #endregion AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加" + this.channel_name + "频道内容:" + model.title); //记录日志 result = true; } return result; }
private bool DoAdd() { bool result = true; Model.article model = new Model.article(); BLL.article bll = new BLL.article(); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.category_id = int.Parse(ddlCategoryId.SelectedValue); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.author = txtAuthor.Text.Trim(); model.form = txtForm.Text.Trim(); //自动提取摘要 if (txtZhaiyao.Text.Trim() != string.Empty) { model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 250); } else { model.zhaiyao = Utils.DropHTML(txtContent.Value, 250); } model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim(); model.seo_description = txtSeoDescription.Text.Trim(); model.sort_id = int.Parse(txtSortId.Text.Trim()); model.click = int.Parse(txtClick.Text.Trim()); model.content = txtContent.Value; model.is_msg = 0; model.is_top = 0; model.is_red = 0; model.is_hot = 0; model.is_slide = 0; model.is_lock = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_top = 1; } if (cblItem.Items[2].Selected == true) { model.is_red = 1; } if (cblItem.Items[3].Selected == true) { model.is_hot = 1; } if (cblItem.Items[4].Selected == true) { model.is_slide = 1; } if (cblItem.Items[5].Selected == true) { model.is_lock = 1; } if (bll.Add(model) < 1) { result = false; } return result; }
/// <summary> /// 获得幻灯片列表二:优点:(1)使用function标签与foreach结合,可以从模版页面控制记录数量;(2)不需要实现注册到模版里 /// </summary> /// <returns></returns> public IList<Model.article> getHdp() { Tag tag = this.Document.CurrentRenderingTag; var attribute = tag.Attributes["rows"]; IList<Model.article> artlist = new List<Model.article>(); int rows = -1;//若为-1,则不做限制条件 if (attribute != null && MyCommFun.isNumber(attribute.Value.GetValue())) { rows = MyCommFun.Obj2Int(attribute.Value.GetValue()); } artlist = tDal.GetHDPByWid(wid, rows); if (artlist != null && artlist.Count > 0) { Model.article cat = new Model.article(); for (int i = 0; i < artlist.Count; i++) { cat = artlist[i]; if (cat.link_url == null || cat.link_url.Trim() == "") { //如果link_url为空,则直接调用本系统的信息 cat.link_url = "javascript:;"; } else { cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid); } } } return artlist; }
/// <summary> /// 取幻灯片信息 /// </summary> /// <param name="wid"></param> /// <param name="topNum">取前几条数据,若为-1,则取全部的数据</param> public IList<Model.article> GetHDPByWid(int wid, int topNum) { IList<Model.article> hdpList = new List<Model.article>(); StringBuilder strSql = new StringBuilder(); strSql.Append("select "); if (topNum >= 0) { strSql.Append(" top " + topNum + " "); } strSql.Append("id,title,link_url,img_url,content,sort_id from dt_article where channel_id=3 and category_id=1 "); strSql.Append(" and wId=@wId order by sort_id asc"); SqlParameter[] parameters = { new SqlParameter("@wId", SqlDbType.Int,4) }; parameters[0].Value = wid; SqlDataReader sr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters); Model.article hdp = new Model.article(); while (sr.Read()) { hdp = new Model.article(); hdp.id = MyCommFun.Obj2Int(sr["id"]); hdp.title = MyCommFun.ObjToStr(sr["title"]); hdp.link_url = MyCommFun.ObjToStr(sr["link_url"]); hdp.img_url = MyCommFun.ObjToStr(sr["img_url"]); hdp.content = MyCommFun.ObjToStr(sr["content"]); hdp.sort_id = MyCommFun.Obj2Int(sr["sort_id"]); hdpList.Add(hdp); } sr.Close(); return hdpList; }
private bool DoAdd() { bool result = false; string check_good = DTRequest.GetFormString("ck_good"); if (string.IsNullOrEmpty(check_good)) { JscriptMsg("请选择商品!", "", "Error"); return false; } BLL.meal bll = new BLL.meal(); Model.meal model = new Model.meal(); model.title = txt_title.Text.Trim(); model.category_id = Convert.ToInt32(ddlCategoryId.SelectedValue); model.img_url = txtImgUrl.Text.Trim(); model.add_time = DateTime.Now; model.index_url = txtIndexUrl.Text.Trim(); model.sort_id = int.Parse(txtSortId.Text.ToString()); BLL.standard_price bll_standard_price = new BLL.standard_price(); int _meal_id = bll.Add(model); if (_meal_id > 0) { BLL.meal_good bll_meal_good = new BLL.meal_good(); string[] arr_str = check_good.Split(','); BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price(); for (int i = 0; i < arr_str.Length; i++) { Model.article model_good = new Model.article(); model_good = new BLL.article().GetModel(Convert.ToInt32(arr_str[i].Split('_')[0])); if (model_good != null) { if (!string.IsNullOrEmpty(arr_str[i])) { DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + arr_str[i].Split('_')[0] + " and standard_price_id=" + arr_str[i].Split('_')[1]).Tables[0]; if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0) { //有会员规格价格 商品ID_规格价格ID_单位ID_数量 默认sell_price 规格价格standard_price(有规格未登入) 组别价格standard_group_price(不管有没有规格已登入) foreach (DataRow dr_group_price in dt_standard_group_price.Rows) { Model.meal_good model_meal_good = new Model.meal_good(); model_meal_good.good_id = Convert.ToInt32(arr_str[i].Split('_')[0]); model_meal_good.group_id = Convert.ToInt32(dr_group_price["group_id"]); model_meal_good.meal_id = _meal_id; model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]); model_meal_good.unit_id = Convert.ToInt32(arr_str[i].Split('_')[2]); model_meal_good.quantity = Convert.ToInt32(arr_str[i].Split('_')[3]); model_meal_good.sell_price = Convert.ToDecimal(model_good.fields["sell_price"]); model_meal_good.standard_price = Convert.ToDecimal(model_good.fields["sell_price"]); Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1])); if (model_standard_price != null) { //有库存价格 model_meal_good.standard_price = model_standard_price.sell_price; model_meal_good.action_price = model_standard_price.action_price; } model_meal_good.standard_group_price = Convert.ToDecimal(dr_group_price["group_price"]); model_meal_good.add_time = DateTime.Now; bll_meal_good.Add(model_meal_good); } } else { if (model_good.group_price.Count > 0) { foreach (Model.user_group_price model_user_group in model_good.group_price) { Model.meal_good model_meal_good = new Model.meal_good(); model_meal_good.good_id = Convert.ToInt32(arr_str[i].Split('_')[0]); model_meal_good.group_id = model_user_group.group_id; model_meal_good.meal_id = _meal_id; model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]); model_meal_good.unit_id = Convert.ToInt32(arr_str[i].Split('_')[2]); model_meal_good.quantity = Convert.ToInt32(arr_str[i].Split('_')[3]); model_meal_good.sell_price = Convert.ToDecimal(model_good.fields["sell_price"]); model_meal_good.standard_price = Convert.ToDecimal(model_good.fields["sell_price"]); Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1])); if (model_standard_price != null) { //有库存价格 model_meal_good.standard_price = model_standard_price.sell_price; model_meal_good.action_price = model_standard_price.action_price; } model_meal_good.standard_group_price = Convert.ToDecimal(model_user_group.price); model_meal_good.add_time = DateTime.Now; bll_meal_good.Add(model_meal_good); } } else { Model.meal_good model_meal_good = new Model.meal_good(); model_meal_good.good_id = Convert.ToInt32(arr_str[i].Split('_')[0]); model_meal_good.group_id = 0; model_meal_good.meal_id = _meal_id; model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]); model_meal_good.unit_id = Convert.ToInt32(arr_str[i].Split('_')[2]); model_meal_good.quantity = Convert.ToInt32(arr_str[i].Split('_')[3]); model_meal_good.sell_price = Convert.ToDecimal(model_good.fields["sell_price"]); model_meal_good.standard_price = Convert.ToDecimal(model_good.fields["sell_price"]); Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1])); if (model_standard_price != null) { //有库存价格 model_meal_good.standard_price = model_standard_price.sell_price; model_meal_good.action_price = model_standard_price.action_price; } model_meal_good.standard_group_price = Convert.ToDecimal(model_good.fields["sell_price"]); model_meal_good.add_time = DateTime.Now; bll_meal_good.Add(model_meal_good); } } } } } //AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加用户:" + model.user_name); //记录日志 result = true; } return result; }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public Model.article GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,channel_id,category_id,title,author,form,zhaiyao,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,digg_good,digg_act,is_msg,is_top,is_red,is_hot,is_slide,is_lock,add_time from dt_article "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Model.article model = new Model.article(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["channel_id"].ToString() != "") { model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString()); } if (ds.Tables[0].Rows[0]["category_id"].ToString() != "") { model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString()); } model.title = ds.Tables[0].Rows[0]["title"].ToString(); model.author = ds.Tables[0].Rows[0]["author"].ToString(); model.form = ds.Tables[0].Rows[0]["form"].ToString(); model.zhaiyao = ds.Tables[0].Rows[0]["zhaiyao"].ToString(); model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString(); model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString(); model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString(); model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString(); model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString(); model.content = ds.Tables[0].Rows[0]["content"].ToString(); if (ds.Tables[0].Rows[0]["sort_id"].ToString() != "") { model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString()); } if (ds.Tables[0].Rows[0]["click"].ToString() != "") { model.click = int.Parse(ds.Tables[0].Rows[0]["click"].ToString()); } if (ds.Tables[0].Rows[0]["digg_good"] != null && ds.Tables[0].Rows[0]["digg_good"].ToString() != "") { model.digg_good = int.Parse(ds.Tables[0].Rows[0]["digg_good"].ToString()); } if (ds.Tables[0].Rows[0]["digg_act"] != null && ds.Tables[0].Rows[0]["digg_act"].ToString() != "") { model.digg_act = int.Parse(ds.Tables[0].Rows[0]["digg_act"].ToString()); } if (ds.Tables[0].Rows[0]["is_msg"].ToString() != "") { model.is_msg = int.Parse(ds.Tables[0].Rows[0]["is_msg"].ToString()); } if (ds.Tables[0].Rows[0]["is_top"].ToString() != "") { model.is_top = int.Parse(ds.Tables[0].Rows[0]["is_top"].ToString()); } if (ds.Tables[0].Rows[0]["is_red"].ToString() != "") { model.is_red = int.Parse(ds.Tables[0].Rows[0]["is_red"].ToString()); } if (ds.Tables[0].Rows[0]["is_hot"].ToString() != "") { model.is_hot = int.Parse(ds.Tables[0].Rows[0]["is_hot"].ToString()); } if (ds.Tables[0].Rows[0]["is_slide"].ToString() != "") { model.is_slide = int.Parse(ds.Tables[0].Rows[0]["is_slide"].ToString()); } if (ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } if (ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } return model; } else { return null; } }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public Model.article GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,channel_id,category_id,call_index,title,link_url,img_url,seo_title,seo_keywords,seo_description,zhaiyao,content,sort_id,click,status,groupids_view,vote_id,is_top,is_red,is_hot,is_slide,is_sys,is_msg,user_name,add_time,update_time,wid"); strSql.Append(" from " + databaseprefix + "article "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Model.article model = new Model.article(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { #region ������Ϣ====================== if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["channel_id"].ToString() != "") { model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString()); } if (ds.Tables[0].Rows[0]["category_id"].ToString() != "") { model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString()); } model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString(); model.title = ds.Tables[0].Rows[0]["title"].ToString(); model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString(); model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString(); model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString(); model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString(); model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString(); model.zhaiyao = ds.Tables[0].Rows[0]["zhaiyao"].ToString(); model.content = ds.Tables[0].Rows[0]["content"].ToString(); if (ds.Tables[0].Rows[0]["sort_id"].ToString() != "") { model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString()); } if (ds.Tables[0].Rows[0]["click"].ToString() != "") { model.click = int.Parse(ds.Tables[0].Rows[0]["click"].ToString()); } if (ds.Tables[0].Rows[0]["status"].ToString() != "") { model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString()); } model.groupids_view = ds.Tables[0].Rows[0]["groupids_view"].ToString(); if (ds.Tables[0].Rows[0]["vote_id"].ToString() != "") { model.vote_id = int.Parse(ds.Tables[0].Rows[0]["vote_id"].ToString()); } if (ds.Tables[0].Rows[0]["is_top"].ToString() != "") { model.is_top = int.Parse(ds.Tables[0].Rows[0]["is_top"].ToString()); } if (ds.Tables[0].Rows[0]["is_red"].ToString() != "") { model.is_red = int.Parse(ds.Tables[0].Rows[0]["is_red"].ToString()); } if (ds.Tables[0].Rows[0]["is_hot"].ToString() != "") { model.is_hot = int.Parse(ds.Tables[0].Rows[0]["is_hot"].ToString()); } if (ds.Tables[0].Rows[0]["is_slide"].ToString() != "") { model.is_slide = int.Parse(ds.Tables[0].Rows[0]["is_slide"].ToString()); } if (ds.Tables[0].Rows[0]["is_sys"].ToString() != "") { model.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString()); } if (ds.Tables[0].Rows[0]["is_msg"].ToString() != "") { model.is_msg = int.Parse(ds.Tables[0].Rows[0]["is_msg"].ToString()); } model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString(); if (ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } if (ds.Tables[0].Rows[0]["update_time"].ToString() != "") { model.update_time = DateTime.Parse(ds.Tables[0].Rows[0]["update_time"].ToString()); } if (ds.Tables[0].Rows[0]["wid"].ToString() != "") { model.wid =int.Parse(ds.Tables[0].Rows[0]["wid"].ToString()); } #endregion #region ��չ�ֶ���Ϣ================== //��ѯ��Ƶ������չ�ֶ����� DataTable dt = new article_attribute_field(databaseprefix).GetList(model.channel_id, "").Tables[0]; if (dt.Rows.Count > 0) { StringBuilder sb = new StringBuilder(); foreach(DataRow dr in dt.Rows) { sb.Append(dr["name"].ToString() + ","); } StringBuilder strSql2 = new StringBuilder(); strSql2.Append("select top 1 " + Utils.DelLastComma(sb.ToString()) + " from " + databaseprefix + "article_attribute_value "); strSql2.Append(" where article_id=@article_id "); SqlParameter[] parameters2 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters2[0].Value = id; DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2); if (ds2.Tables[0].Rows.Count > 0) { Dictionary<string, string> dic = new Dictionary<string, string>(); foreach (DataRow dr in dt.Rows) { if (ds2.Tables[0].Rows[0][dr["name"].ToString()] != null) { dic.Add(dr["name"].ToString(), ds2.Tables[0].Rows[0][dr["name"].ToString()].ToString()); } else { dic.Add(dr["name"].ToString(), ""); } } model.fields = dic; } } #endregion //�����Ϣ model.albums = new article_albums(databaseprefix).GetList(id); //������Ϣ model.attach = new article_attach(databaseprefix).GetList(id); //�û���۸� model.group_price = GetGroupPrice(id); return model; } else { return null; } }
private bool DoAdd() { bool result = false; Model.article model = new Model.article(); BLL.article bll = new BLL.article(); model.channel_id = this.channel_id; model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0); model.call_index = txtCallIndex.Text.Trim(); model.title = txtTitle.Text.Trim(); model.tags = txtTags.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text; model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim(); model.seo_description = txtSeoDescription.Text.Trim(); //内容摘要提取内容前255个字符 if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim())) { model.zhaiyao = Utils.DropHTML(txtContent.Value, 255); } else { model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 255); } //是否将编辑器远程图片保存到本地 if (siteConfig.fileremote == 1) { model.content = AutoRemoteImageSave(txtContent.Value); } else { model.content = txtContent.Value; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); model.click = int.Parse(txtClick.Text.Trim()); model.status = Utils.StrToInt(rblStatus.SelectedValue, 0); model.is_msg = 0; model.is_top = 0; model.is_red = 0; model.is_hot = 0; model.is_slide = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_top = 1; } if (cblItem.Items[2].Selected == true) { model.is_red = 1; } if (cblItem.Items[3].Selected == true) { model.is_hot = 1; } if (cblItem.Items[4].Selected == true) { model.is_slide = 1; } model.is_sys = 1; //管理员发布 model.user_name = GetAdminInfo().user_name; //获得当前登录用户名 model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.fields = SetFieldValues(this.channel_id); //扩展字段赋值 #region 保存规格==================== //保存商品规格 string goodsSpecJsonStr = hide_goods_spec_list.Value; List<Model.article_goods_spec> specList = (List<Model.article_goods_spec>)JsonHelper.JSONToObject<List<Model.article_goods_spec>>(goodsSpecJsonStr); if (specList != null) { model.specs = specList; } //保存商品信息 string[] specGoodsIdArr = Request.Form.GetValues("hide_goods_id"); string[] specGoodsNoArr = Request.Form.GetValues("spec_goods_no"); string[] specMarketPriceArr = Request.Form.GetValues("spec_market_price"); string[] specSellPriceArr = Request.Form.GetValues("spec_sell_price"); string[] specStockQuantityArr = Request.Form.GetValues("spec_stock_quantity"); string[] specSpecIdsArr = Request.Form.GetValues("hide_spec_ids"); string[] specTextArr = Request.Form.GetValues("hide_spec_text"); string[] specGroupPriceArr = Request.Form.GetValues("hide_group_price"); if (specGoodsIdArr != null && specGoodsNoArr != null && specMarketPriceArr != null && specSellPriceArr != null && specStockQuantityArr != null && specSpecIdsArr != null && specTextArr != null && specGroupPriceArr != null && specGoodsIdArr.Length > 0 && specGoodsNoArr.Length > 0 && specMarketPriceArr.Length > 0 && specSellPriceArr.Length > 0 && specStockQuantityArr.Length > 0 && specSpecIdsArr.Length > 0 && specTextArr.Length > 0 && specGroupPriceArr.Length > 0) { List<Model.article_goods> goodsList = new List<Model.article_goods>(); for (int i = 0; i < specGoodsNoArr.Length; i++) { List<Model.user_group_price> groupList = new List<Model.user_group_price>(); if (!string.IsNullOrEmpty(specGroupPriceArr[i])) { groupList = (List<Model.user_group_price>)JsonHelper.JSONToObject<List<Model.user_group_price>>(specGroupPriceArr[i]); } goodsList.Add(new Model.article_goods { goods_no = specGoodsNoArr[i], spec_ids = specSpecIdsArr[i], spec_text = specTextArr[i], stock_quantity = Utils.StrToInt(specStockQuantityArr[i], 0), market_price = Utils.StrToDecimal(specMarketPriceArr[i], 0), sell_price = Utils.StrToDecimal(specSellPriceArr[i], 0), group_prices = groupList }); } model.goods = goodsList; } #endregion #region 保存相册==================== //检查是否有自定义图片 if (txtImgUrl.Text.Trim() == "") { model.img_url = hidFocusPhoto.Value; } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null && albumArr.Length > 0) { List<Model.article_albums> ls = new List<Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { original_path = imgArr[1], thumb_path = imgArr[2] }); } } } model.albums = ls; } #endregion #region 保存附件==================== //保存附件 string[] attachFileNameArr = Request.Form.GetValues("hid_attach_filename"); string[] attachFilePathArr = Request.Form.GetValues("hid_attach_filepath"); string[] attachFileSizeArr = Request.Form.GetValues("hid_attach_filesize"); string[] attachPointArr = Request.Form.GetValues("txt_attach_point"); if (attachFileNameArr != null && attachFilePathArr != null && attachFileSizeArr != null && attachPointArr != null && attachFileNameArr.Length > 0 && attachFilePathArr.Length > 0 && attachFileSizeArr.Length > 0 && attachPointArr.Length > 0) { List<Model.article_attach> ls = new List<Model.article_attach>(); for (int i = 0; i < attachFileNameArr.Length; i++) { int fileSize = Utils.StrToInt(attachFileSizeArr[i], 0); string fileExt = Utils.GetFileExt(attachFilePathArr[i]); int _point = Utils.StrToInt(attachPointArr[i], 0); ls.Add(new Model.article_attach { file_name = attachFileNameArr[i], file_path = attachFilePathArr[i], file_size = fileSize, file_ext = fileExt, point = _point }); } model.attach = ls; } #endregion if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加" + this.channel_name + "频道内容:" + model.title); //记录日志 result = true; } return result; }