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\": \"对不起,保存过程中发生错误!\"}"); }
private bool DoAdd() { bool result = true; Model.article_content model = new Model.article_content(); BLL.article bll = new BLL.article(); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.call_index = txtCallIndex.Text.Trim(); model.category_id = int.Parse(ddlCategoryId.SelectedValue); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); 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.digg_good = int.Parse(txtDiggGood.Text.Trim()); model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); model.is_msg = 0; model.is_red = 0; model.is_lock = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_red = 1; } if (cblItem.Items[2].Selected == true) { model.is_lock = 1; } if (bll.Add(model) < 1) { result = false; } return(result); }
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 = this.category_id; model.call_index = txtCallIndex.Text.Trim(); model.title = txtTitle.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); //内容摘要提取内容前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.fields = new Dictionary <string, string>(); model.is_sys = 1; //管理员发布 model.user_name = "admin"; //获得当前登录用户名 if (bll.Add(model) > 0) { //开始生成缩略图咯 AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Add.ToString(), "添加友情链接频道内容:" + model.title); //记录日志 result = true; } return(result); }
private bool DoAdd() { bool result = true; Model.article_goods model = new Model.article_goods(); 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.goods_no = txtGoodsNo.Text; model.stock_quantity = int.Parse(txtStockQuantity.Text); model.market_price = decimal.Parse(txtMarketPrice.Text); model.sell_price = decimal.Parse(txtSellPrice.Text); //model.point = int.Parse(txtPoint.Text); //model.link_url = txtLinkUrl.Text.Trim(); model.img_url = focus_photo.Value; model.content = txtContent.Value; //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.digg_good = int.Parse(txtDiggGood.Text.Trim()); // model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); model.add_time = DateTime.Parse(txtTime.Text.ToString()); 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; //} //會員組價格 //List<Model.goods_group_price> priceList = new List<Model.goods_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.goods_group_price { group_id = _groupid, price = _price }); //} //model.goods_group_prices = priceList; //保存相冊 string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_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 { big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } //擴展屬性 BLL.attributes bll2 = new BLL.attributes(); DataSet ds2 = bll2.GetList("channel_id=" + this.channel_id); List <Model.attribute_value> attrls = new List <Model.attribute_value>(); foreach (DataRow dr in ds2.Tables[0].Rows) { int attr_id = int.Parse(dr["id"].ToString()); string attr_title = dr["title"].ToString(); string attr_value = Request.Form["content_" + attr_id]; if (!string.IsNullOrEmpty(attr_value)) { attrls.Add(new Model.attribute_value { attribute_id = attr_id, title = attr_title, content = attr_value }); } } model.attribute_values = attrls; //model.Postid = CheckBoxList1.SelectedValue; //model.Type = int.Parse(cblItem.SelectedValue); model.AddType = 1; model.Status = 0; if (!string.IsNullOrEmpty(ddlquyu.SelectedValue)) { model.quyu = Convert.ToInt32(ddlquyu.SelectedValue); } if (!string.IsNullOrEmpty(ddljiaqian.SelectedValue)) { model.jiaqianQJ = Convert.ToInt32(ddljiaqian.SelectedValue); } if (!string.IsNullOrEmpty(ddlmianji.SelectedValue)) { model.mianji = Convert.ToInt32(ddlmianji.SelectedValue); } if (!string.IsNullOrEmpty(ddlhuxing.SelectedValue)) { model.huxing = Convert.ToInt32(ddlhuxing.SelectedValue); } if (!string.IsNullOrEmpty(ddlfangshi.SelectedValue)) { model.fangshi = Convert.ToInt32(ddlfangshi.SelectedValue); } if (!string.IsNullOrEmpty(ddlditie.SelectedValue)) { model.xianlu = Convert.ToInt32(ddlditie.SelectedValue); } model.yajin = string.IsNullOrEmpty(txtyajin.Text) ? 0 : Convert.ToInt32(txtyajin.Text); model.zuoxiang = txtzuoxiang.Text; model.louceng = txtlouceng.Text; model.xingneng = txtxingneng.Text; model.yongtu = txtyongtu.Text; model.chewei = txtchewei.Text; model.shequ = txtshequ.Text; model.dizhi = txtdizhi.Text; model.gongsi = txtgongsi.Text; model.fuwuxiangju = txtfuwxiangmu.Text; model.dianhua = txtdianhua.Text; model.lianxiren = txtuser.Text; model.user_id = WEBUserCurrent.UserID; model.shangpinType = txtshangpintype.Text; //if (!bll.Update(model)) //{ // result = false; //} if (bll.Add(model) < 1) { result = false; } return(result); }
private bool DoAdd() { bool result = true; Model.article_news model = new Model.article_news(); 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.author = txtAuthor.Text.Trim(); model.from = txtFrom.Text.Trim(); model.add_time = DateTime.Parse(txtTime.Text.ToString()); //自動提取摘要 if (txtZhaiyao.Text.Trim() != string.Empty) { model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 250); } else { model.zhaiyao = Utils.DropHTML(txtContent.Value, 250); } model.link_url = txtLinkUrl.Text.Trim(); //檢查是否有自訂圖片 if (txtImgUrl.Text.Trim() != "") { model.img_url = txtImgUrl.Text; } else { model.img_url = focus_photo.Value; } model.content = txtContent.Value; 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.digg_good = int.Parse(txtDiggGood.Text.Trim()); model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); 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; } //儲存相冊 string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_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 { big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } //擴展屬性 BLL.attributes bll2 = new BLL.attributes(); DataSet ds2 = bll2.GetList("channel_id=" + this.channel_id); List <Model.attribute_value> attrls = new List <Model.attribute_value>(); foreach (DataRow dr in ds2.Tables[0].Rows) { int attr_id = int.Parse(dr["id"].ToString()); string attr_title = dr["title"].ToString(); string attr_value = Request.Form["content_" + attr_id]; if (!string.IsNullOrEmpty(attr_value)) { attrls.Add(new Model.attribute_value { attribute_id = attr_id, title = attr_title, content = attr_value }); } } model.attribute_values = attrls; if (bll.Add(model) < 1) { result = false; } return(result); }
//設置操作 protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { //ChkAdminLevel("channel_" + this.channel_name + "_list", TWEnums.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); switch (e.CommandName) { case "lbtnIsMsg": if (model.is_msg == 1) { bll.UpdateField(id, "is_msg=0"); } else { bll.UpdateField(id, "is_msg=1"); } break; case "lbtnIsTop": if (model.is_tui == 1) { bll.UpdateField(id, "is_tui=0"); } else { bll.UpdateField(id, "is_tui=1"); } break; case "lbtnIsRed": if (model.is_can == 1) { bll.UpdateField(id, "is_can=0"); } else { bll.UpdateField(id, "is_can=1"); } break; case "lbtnIsHot": if (model.is_zhe == 1) { bll.UpdateField(id, "is_zhe=0"); } else { bll.UpdateField(id, "is_zhe=1"); } break; case "lbtnIsSlide": if (model.is_slide == 1) { bll.UpdateField(id, "is_slide=0"); } else { bll.UpdateField(id, "is_slide=1"); } break; case "lbtnCopy": string tempTitle = model.title; model.title = tempTitle + "(複製)"; bll.Add(model); break; } this.RptBind(this.channel_id, this.category_id, "wheresql='tuan' and company=0" + CombSqlTxt(this.keywords, this.property, this.brand_id, this.category_id), "sort_id desc,add_time desc,id desc"); }
private bool DoAdd() { bool result = true; Model.article_download model = new Model.article_download(); 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.content = txtContent.Value; 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.digg_good = int.Parse(txtDiggGood.Text.Trim()); model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); model.is_msg = 0; model.is_red = 0; model.is_lock = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_red = 1; } if (cblItem.Items[2].Selected == true) { model.is_lock = 1; } //保存附件 string hidFileList = Request.Params["hidFileName"]; if (!string.IsNullOrEmpty(hidFileList)) { string[] fileListArr = hidFileList.Split(','); string[] pointArr = Request.Form.GetValues("txtPoint"); List <Model.download_attach> ls = new List <Model.download_attach>(); for (int i = 0; i < fileListArr.Length; i++) { string[] fileArr = fileListArr[i].Split('|'); if (fileArr.Length == 3) { int fileSize = Utils.GetFileSize(fileArr[2]); string fileExt = Utils.GetFileExt(fileArr[2]); int _point = int.Parse(pointArr[i]); ls.Add(new Model.download_attach { id = int.Parse(fileArr[0]), title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt, point = _point }); } } model.download_attachs = ls; } if (bll.Add(model) < 1) { result = false; } return(result); }
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; }
private bool DoAdd() { bool result = true; Model.article_news model = new Model.article_news(); 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.author = txtAuthor.Text.Trim(); model.from = txtFrom.Text.Trim(); //自动提取摘要 if (txtZhaiyao.Text.Trim() != string.Empty) { model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 250); } else { model.zhaiyao = Utils.DropHTML(txtContent.Value, 250); } model.link_url = txtLinkUrl.Text.Trim(); //检查是否有自定义图片 if (txtImgUrl.Text.Trim() != "") { model.img_url = txtImgUrl.Text; } else { model.img_url = focus_photo.Value; } model.content = txtContent.Value; 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.digg_good = int.Parse(txtDiggGood.Text.Trim()); model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); 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; } //保存相册 string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_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 { big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } //扩展属性 BLL.attributes bll2 = new BLL.attributes(); DataSet ds2 = bll2.GetList("channel_id=" + this.channel_id); List<Model.attribute_value> attrls = new List<Model.attribute_value>(); foreach (DataRow dr in ds2.Tables[0].Rows) { int attr_id = int.Parse(dr["id"].ToString()); string attr_title = dr["title"].ToString(); string attr_value = Request.Form["content_" + attr_id]; if (!string.IsNullOrEmpty(attr_value)) { attrls.Add(new Model.attribute_value { attribute_id = attr_id, title = attr_title, content = attr_value }); } } model.attribute_values = attrls; if (bll.Add(model) < 1) { result = false; } return result; }
private bool DoAdd() { bool result = true; Model.article_goods model = new Model.article_goods(); 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.img_url = focus_photo.Value; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.add_time = DateTime.Now;; model.is_msg = 0; model.is_top = 0; model.is_red = 0; model.is_hot = 0; model.is_slide = 0; model.is_lock = 0; model.content = txtContent.Value; //會員組價格 List <Model.goods_group_price> priceList = new List <Model.goods_group_price>(); model.goods_group_prices = priceList; //儲存相冊 string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_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 { big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } //擴展屬性 BLL.attributes bll2 = new BLL.attributes(); DataSet ds2 = bll2.GetList("channel_id=" + this.channel_id); List <Model.attribute_value> attrls = new List <Model.attribute_value>(); foreach (DataRow dr in ds2.Tables[0].Rows) { int attr_id = int.Parse(dr["id"].ToString()); string attr_title = dr["title"].ToString(); string attr_value = Request.Form["content_" + attr_id]; if (!string.IsNullOrEmpty(attr_value)) { attrls.Add(new Model.attribute_value { attribute_id = attr_id, title = attr_title, content = attr_value }); } } model.attribute_values = attrls; model.AddType = 0; model.Status = 1; if (bll.Add(model) < 1) { result = false; } return(result); }
//將excel的資料寫入資料庫 private string InsertGoods(DataTable dt) { string result = ""; BLL.article_category categoryBll = new BLL.article_category(); BLL.article articleBll = new BLL.article(); BLL.goods goodsBll = new BLL.goods(); Model.article articleModel = null; Model.goods goodsModel = null; //判斷列名是否規範 string[] strColumn = { "類別*", "品牌", "商品型號*", "商品名稱", "隊伍", "顏色*", "尺寸*", "數量量*", "市價", "售價", "商品描述", "商品說明", "注意事項", "商品分類1", "商品分類2", "商品分類3", "關鍵字", "上架日期", "下架日期", "每人限購數量*", "前臺排序", "重量", "長", "寬", "高", "紅利" }; int num = 0; for (int i = 0; i < dt.Columns.Count; i++) { foreach (string str in strColumn) { if (str == dt.Columns[i].ColumnName) { num++; } } } if (num == strColumn.Length) { //遍歷主件 DataRow[] drArr = dt.Select("[類別*]='商品主件'"); foreach (DataRow dr in drArr) { if (dr[0].ToString().Trim() != "") { bool updatea = true; DataSet ds = Tea.DBUtility.DbHelperSQL.Query("select * from shop_article where goods_no='" + dr[2].ToString().Trim() + "'"); if (ds.Tables[0].Rows.Count > 0) { articleModel = articleBll.GetModel(int.Parse(ds.Tables[0].Rows[0]["id"].ToString())); } if (articleModel == null) { articleModel = new Model.article(); updatea = false; } articleModel.channel_id = 2; if (string.IsNullOrEmpty(dr[13].ToString())) { articleModel.category_id = 0; } else { articleModel.category_id = int.Parse(dr[13].ToString());// categoryBll.GetID(dr[13].ToString().Split(',')[0]); } //articleModel.more_type = dr[15].ToString(); articleModel.call_index = ""; articleModel.title = dr[3].ToString(); articleModel.link_url = ""; if (string.IsNullOrEmpty(dr[1].ToString())) { //articleModel.brand_id = 0; } else { //articleModel.brand_id = brandBll.GetID(dr[1].ToString()); } if (string.IsNullOrEmpty(dr[4].ToString())) { // articleModel.team_id = 0; } else { //articleModel.team_id = teamBll.GetID(dr[4].ToString()); } articleModel.img_url = ""; articleModel.seo_title = ""; articleModel.seo_keywords = dr[16].ToString(); articleModel.seo_description = ""; articleModel.zhaiyao = ""; articleModel.content = "";// dr[10].ToString(); articleModel.sort_id = Utils.ObjToInt(dr[20], 999); articleModel.click = 0; articleModel.status = 1; articleModel.is_msg = 0; articleModel.is_tui = 0; articleModel.is_can = 0; articleModel.is_zhe = 0; articleModel.is_slide = 0; articleModel.is_sys = 1; //管理員發佈 articleModel.user_name = "admin"; //獲得當前登入用戶名 articleModel.add_time = DateTime.Now; //articleModel.sales_id = 0; int pid = 0; if (updatea) { articleBll.Update(articleModel); pid = articleModel.id; } else { pid = articleBll.Add(articleModel); } //匯入子件 DataRow[] drArr1 = dt.Select("[類別*]='子件' and [商品型號*] like '" + dr[2].ToString() + "%'"); foreach (DataRow dr1 in drArr1) { bool updateg = true; DataSet dsg = Tea.DBUtility.DbHelperSQL.Query("select * from shop_goods where goods_no='" + dr1[2].ToString().Trim() + "'"); if (dsg.Tables[0].Rows.Count > 0) { goodsModel = goodsBll.GetModel(int.Parse(dsg.Tables[0].Rows[0]["id"].ToString())); } if (goodsModel == null) { goodsModel = new Model.goods(); updateg = false; } goodsModel.parent_id = pid; goodsModel.color = dr1[5].ToString(); goodsModel.size = dr1[6].ToString(); goodsModel.goods_no = dr1[2].ToString(); if (dr1[8].ToString().Trim() != "") { goodsModel.market_price = Utils.ObjToDecimal(dr1[8], 0M); } else { goodsModel.market_price = Utils.ObjToDecimal(dr[8], 0M); } if (dr1[9].ToString().Trim() != "") { goodsModel.sell_price = Utils.ObjToDecimal(dr1[9], 0M); } else { goodsModel.sell_price = Utils.ObjToDecimal(dr[9], 0M); } if (dr1[7].ToString().Trim() != "") { goodsModel.stock_quantity = Utils.ObjToInt(dr1[7], 0); } else { goodsModel.stock_quantity = Utils.ObjToInt(dr[7], 0); } goodsModel.alert_quantity = 0; goodsModel.img_url = ""; if (goodsModel.goods_no.Trim().Length > 4) { if (updateg) { goodsBll.Update(goodsModel); } else { goodsBll.Add(goodsModel); } } } } } } else { result = "請檢查excel檔案格式!" + num + strColumn.Length; } return(result); }
protected void btnSubmit_Click(object sender, EventArgs e) { bool result = true; Model.article_download model = new Model.article_download(); BLL.article bll = new BLL.article(); model.channel_id = 9; 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.content = txtContent.Value; 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.digg_good = int.Parse(txtDiggGood.Text.Trim()); model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); model.is_msg = 0; model.is_red = 0; model.is_lock = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_red = 1; } if (cblItem.Items[2].Selected == true) { model.is_lock = 1; } //儲存附件 string hidFileList = Request.Params["hidFileName"]; if (!string.IsNullOrEmpty(hidFileList)) { string[] fileListArr = hidFileList.Split(','); string[] pointArr = Request.Form.GetValues("txtPoint"); List <Model.download_attach> ls = new List <Model.download_attach>(); for (int i = 0; i < fileListArr.Length; i++) { string[] fileArr = fileListArr[i].Split('|'); if (fileArr.Length == 3) { int fileSize = Utils.GetFileSize(fileArr[2]); string fileExt = Utils.GetFileExt(fileArr[2]); int _point = int.Parse(pointArr[i]); ls.Add(new Model.download_attach { id = int.Parse(fileArr[0]), title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt, point = _point }); } } model.download_attachs = ls; } if (bll.Add(model) < 1) { result = false; } if (!result) { this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('儲存過程中發生錯誤');window.location.href='upFile.aspx'</script>"); return; } this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加成功');window.location.href='upFile.aspx'</script>"); }
private bool DoAdd() { bool result = false; Model.article model = new Model.article(); BLL.article bll = new BLL.article(); model.wheresql = "tuan"; model.channel_id = this.channel_id; model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0); model.brand_id = Utils.StrToInt(ddlType.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(); //內容摘要提取內容前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_tui = 0; model.is_zhe = 0; if (cblItem.Items[0].Selected == true) { model.is_tui = 1; } if (cblItem.Items[1].Selected == true) { model.is_zhe = 1; } model.user_name = GetAdminInfo().user_name; //獲得當前登錄用戶名 model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.begin_time = Utils.StrToDateTime(txtBeginTime.Text.Trim()); model.end_time = Utils.StrToDateTime(txtEndTime.Text.Trim()); DateTime _end_time; if (DateTime.TryParse(txtUpdate.Text.Trim(), out _end_time)) { model.update_time = _end_time; } DateTime __end_time; if (DateTime.TryParse(txt_Xia_Date.Text.Trim(), out __end_time)) { model.xia_date = __end_time; } if (cbIsLock.Checked) { model.is_msg = 1; } else { model.is_msg = 0; } //分表 model.sell_price = Utils.StrToDecimal(txtSell_price.Text, 0); model.market_price = Utils.StrToDecimal(txtMarket_price.Text, 0); model.point = Utils.StrToInt(txtPoint.Text, 0); model.goods_no = txtGoods_no.Text; model.update_time = DateTime.Now; model.guige = txtGuige.Text; model.sub_title = txtSub_title.Text; model.guigemore = txtGuigeMore.Value; model.shuoming = txtShuo.Value; model.zhuyi = txtZhuyi.Text.Replace("/s", "|"); System.Text.StringBuilder sb = new StringBuilder(); sb.Append(','); foreach (ListItem li in cbMore.Items) { if (li.Selected) { sb.AppendFormat("{0},", li.Value); } } model.more_type = sb.ToString(); model.tags = txtTag.Text + "$" + txtTag1.Text + "$" + txtTag2.Text; #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 儲存會員組價格============== //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 (Request.Form.GetValues("item_goods_no") == null || Request.Form.GetValues("item_goods_no").Length < 1) { JscriptMsg("請設定商品規格!", string.Empty); return(false); } if (model.brand_id == 3) { if (string.IsNullOrEmpty(txtGuige.Text.Trim()) || txtGuige.Text.Trim().Length < 1) { JscriptMsg("請輸入活動編號!", string.Empty); return(false); } } int aid = bll.Add(model); if (aid > 0) { #region 儲存子件============== BLL.goods bll_goods = new BLL.goods(); string[] goods_no = Request.Form.GetValues("item_goods_no"); string[] color = Request.Form.GetValues("item_color"); string[] imgurl = Request.Form.GetValues("item_imgurl"); string[] market_price = Request.Form.GetValues("item_market_price"); string[] sell_price = Request.Form.GetValues("item_sell_price"); string[] stock_quantity = Request.Form.GetValues("item_stock_quantity"); string[] chang = Request.Form.GetValues("item_chang"); string[] kuan = Request.Form.GetValues("item_kuan"); string[] gao = Request.Form.GetValues("item_gao"); string[] zhong = Request.Form.GetValues("item_zhong"); if (goods_no != null && goods_no.Length > 0) { for (int i = 0; i < goods_no.Length; i++) { Model.goods model_goods = new Model.goods(); model_goods.parent_id = aid; model_goods.img_url = imgurl[i].ToString(); model_goods.market_price = Utils.StrToDecimal(market_price[i].ToString(), 0); model_goods.goods_no = goods_no[i].ToString(); model_goods.sell_price = Utils.StrToDecimal(sell_price[i].ToString(), 0); model_goods.stock_quantity = Utils.StrToInt(stock_quantity[i].ToString(), 0); model_goods.color = color[i].ToString(); model_goods.guige = color[i].ToString(); model_goods.chang = Utils.StrToDecimal(chang[i].ToString(), 0); model_goods.kuan = Utils.StrToDecimal(kuan[i].ToString(), 0); model_goods.gao = Utils.StrToDecimal(gao[i].ToString(), 0); model_goods.zhong = Utils.StrToDecimal(zhong[i].ToString(), 0); int newid = bll_goods.Add(model_goods); if (newid > 0 && i == 0) { bll.UpdateField(aid, "sales_id=" + newid + ""); } } } #endregion AddAdminLog(TWEnums.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); }
private void ExcelFile(HttpContext context) { string _delfile = AXRequest.GetString("DelFilePath"); HttpPostedFile _upfile = context.Request.Files["Filedata"]; bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 int id = 0; if (_upfile == null) { context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); return; } // Common.Log.LogMsg("1", "admin"); StringBuilder sb = new StringBuilder(220000); StringBuilder info = new StringBuilder(220000); // Common.Log.LogMsg("start", "super"); UpLoad upFiles = new UpLoad(); string newpath = ""; string msg = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater, ref newpath); // Common.Log.LogMsg("newpath:" + newpath, "super"); DataTable dt = Common.ExcelHelper.ConvertExcelFileToTable(newpath); BLL.article bll = new BLL.article(); BLL.article_category bbc = new BLL.article_category(); // Common.Log.LogMsg("count:"+dt.Rows.Count.ToString(), "super"); // Common.Log.LogMsg("row:" + dt.Rows[0][0].ToString().Trim(), "super"); for (int i = 1; i < dt.Rows.Count; i++) { int type = 0; string no = ""; if (dt.Rows[i]["Name"].ToString().Trim() == "" && dt.Rows[i]["Barcode"].ToString().Trim() == "") { continue; } if (dt.Rows[i]["Name"].ToString().Trim() == "") { sb.Append("{"); sb.Append("\"id\":\"" + i + "\","); sb.Append("\"code\":\"" + dt.Rows[i]["Barcode"].ToString().Trim() + "\","); sb.Append("\"name\":\"" + dt.Rows[i]["Name"].ToString().Trim() + "\","); sb.Append("\"result\":\"失败\","); sb.Append("\"reason\":\"中文名不能为空\""); sb.Append("},"); continue; } if (dt.Rows[i]["Barcode"].ToString().Trim() == "") { sb.Append("{"); sb.Append("\"id\":\"" + i + "\","); sb.Append("\"code\":\"" + dt.Rows[i]["Barcode"].ToString().Trim() + "\","); sb.Append("\"name\":\"" + dt.Rows[i]["Name"].ToString().Trim() + "\","); sb.Append("\"result\":\"失败\","); sb.Append("\"reason\":\"条形码不能为空\""); sb.Append("},"); continue; } else { if (bll.ExistsBarcode(dt.Rows[i]["Barcode"].ToString().Trim())) { // sb.Append("{"); // sb.Append("\"id\":\"" + i + "\","); //sb.Append("\"code\":\"" + dt.Rows[i]["Barcode"].ToString().Trim() + "\","); //sb.Append("\"name\":\"" + dt.Rows[i]["Name"].ToString().Trim() + "\","); //sb.Append("\"result\":\"失败\","); // sb.Append("\"reason\":\"此商品已存在\""); // sb.Append("},"); // continue; type = 1; } } if (dt.Rows[i]["ProductTypeNo"].ToString().Trim() == "") { sb.Append("{"); sb.Append("\"id\":\"" + i + "\","); sb.Append("\"code\":\"" + dt.Rows[i]["Barcode"].ToString().Trim() + "\","); sb.Append("\"name\":\"" + dt.Rows[i]["Name"].ToString().Trim() + "\","); sb.Append("\"result\":\"失败\","); sb.Append("\"reason\":\"商品类型不能为空\""); sb.Append("},"); continue; } else { try { no = dt.Rows[i]["ProductTypeNo"].ToString().Trim(); if (string.IsNullOrEmpty(no)) { id = 0; } else { id = bbc.GetID(no); } if (id == 0) { sb.Append("{"); sb.Append("\"id\":\"" + i + "\","); sb.Append("\"code\":\"" + dt.Rows[i]["Barcode"].ToString().Trim() + "\","); sb.Append("\"name\":\"" + dt.Rows[i]["Name"].ToString().Trim() + "\","); sb.Append("\"result\":\"失败\","); sb.Append("\"reason\":\"商品类型不存在\""); sb.Append("},"); continue; } } catch (Exception ex) { sb.Append("{"); sb.Append("\"id\":\"" + i + "\","); sb.Append("\"code\":\"" + dt.Rows[i]["Barcode"].ToString().Trim() + "\","); sb.Append("\"name\":\"" + dt.Rows[i]["Name"].ToString().Trim() + "\","); sb.Append("\"result\":\"失败\","); sb.Append("\"reason\":\"商品类型:" + ex.Message + "\""); sb.Append("},"); continue; } } // Common.Log.LogMsg("1", "super"); Model.article model = new Model.article(); Dictionary <string, string> dn = new Dictionary <string, string>(); if (type == 1) { model = bll.GetModelNew(" where Barcode='" + dt.Rows[i]["Barcode"].ToString().Trim() + "'"); dn = model.fields; if (dt.Rows[i]["Quantity"].ToString().Trim() == "") { // dn.Add("stock_quantity", "0"); } else { Decimal d = Convert.ToDecimal(model.fields["stock_quantity"]) + Convert.ToDecimal(dt.Rows[i]["Quantity"].ToString().Trim()); dn["stock_quantity"] = d.ToString(); } if (dt.Rows[i]["PriceMode"].ToString().Trim() == "") { dn["PriceMode"] = "0"; } else { dn["PriceMode"] = dt.Rows[i]["PriceMode"].ToString().Trim(); } if (dt.Rows[i]["PurchasePrice"].ToString().Trim() == "") { dn["PurchasePrice"] = "0"; } else { dn["PurchasePrice"] = dt.Rows[i]["PurchasePrice"].ToString().Trim(); } if (dt.Rows[i]["WholesalePrice"].ToString().Trim() == "") { dn["WholesalePrice"] = "0"; } else { dn["WholesalePrice"] = dt.Rows[i]["WholesalePrice"].ToString().Trim(); } if (dt.Rows[i]["SpecialPrice"].ToString().Trim() == "") { dn["SpecialPrice"] = "0"; } else { dn["SpecialPrice"] = dt.Rows[i]["SpecialPrice"].ToString().Trim(); } if (dt.Rows[i]["DiscountRate"].ToString().Trim() == "") { dn["DiscountRate"] = "0"; } else { dn["DiscountRate"] = dt.Rows[i]["DiscountRate"].ToString().Trim(); } dn["Barcode"] = dt.Rows[i]["Barcode"].ToString().Trim(); dn["goods_no"] = dt.Rows[i]["No"].ToString().Trim(); dn["english_name"] = dt.Rows[i]["NameP"].ToString().Trim(); dn["ProductTypeNo"] = dt.Rows[i]["ProductTypeNo"].ToString().Trim(); dn["sub_title"] = dt.Rows[i]["Name"].ToString().Trim(); } else { model.img_url = "/upload/templates/default.jpg"; model.sort_id = 99; model.click = 0; model.status = 0; model.is_msg = 0; model.is_top = 0; model.is_red = 0; model.is_hot = 0; model.is_slide = 0; if (dt.Rows[i]["Quantity"].ToString().Trim() == "") { dn.Add("stock_quantity", "0"); } else { dn.Add("stock_quantity", dt.Rows[i]["Quantity"].ToString().Trim()); } if (dt.Rows[i]["PriceMode"].ToString().Trim() == "") { dn.Add("PriceMode", "0"); } else { dn.Add("PriceMode", dt.Rows[i]["PriceMode"].ToString().Trim()); } if (dt.Rows[i]["PurchasePrice"].ToString().Trim() == "") { dn.Add("PurchasePrice", "0"); } else { dn.Add("PurchasePrice", dt.Rows[i]["PurchasePrice"].ToString().Trim()); } if (dt.Rows[i]["WholesalePrice"].ToString().Trim() == "") { dn.Add("WholesalePrice", "0"); } else { dn.Add("WholesalePrice", dt.Rows[i]["WholesalePrice"].ToString().Trim()); } if (dt.Rows[i]["SpecialPrice"].ToString().Trim() == "") { dn.Add("SpecialPrice", "0"); } else { dn.Add("SpecialPrice", dt.Rows[i]["SpecialPrice"].ToString().Trim()); } //if (dt.Rows[i]["RetailPrice"].ToString().Trim() == "") //{ // dn.Add("RetailPrice", "0"); //} //else //{ // dn.Add("RetailPrice", dt.Rows[i]["RetailPrice"].ToString().Trim()); //} //if (dt.Rows[i]["TaxRate"].ToString().Trim() == "") //{ // dn.Add("TaxRate", "0"); //} //else //{ // dn.Add("TaxRate", dt.Rows[i]["TaxRate"].ToString().Trim()); //} if (dt.Rows[i]["DiscountRate"].ToString().Trim() == "") { dn.Add("DiscountRate", "0"); } else { dn.Add("DiscountRate", dt.Rows[i]["DiscountRate"].ToString().Trim()); } dn.Add("Barcode", dt.Rows[i]["Barcode"].ToString().Trim()); dn.Add("goods_no", dt.Rows[i]["No"].ToString().Trim()); dn.Add("english_name", dt.Rows[i]["NameP"].ToString().Trim()); dn.Add("ProductTypeNo", dt.Rows[i]["ProductTypeNo"].ToString().Trim()); dn.Add("sub_title", dt.Rows[i]["Name"].ToString().Trim()); model.fields = dn; } model.channel_id = 2; model.category_id = id; model.title = dt.Rows[i]["Name"].ToString(); model.zhaiyao = dt.Rows[i]["Remark"].ToString().Trim(); model.add_time = DateTime.Now; model.is_sys = 1; //管理员发布 model.user_name = "super"; //获得当前登录" + Resources.lang.username+ " // Common.Log.LogMsg("2", "super"); model.fields["sell_price"] = GetPrice(model.fields); List <Model.user_group_price> priceList = new List <Model.user_group_price>(); decimal _price = Convert.ToDecimal(model.fields["sell_price"]); priceList.Add(new Model.user_group_price { group_id = 1, price = _price }); priceList.Add(new Model.user_group_price { group_id = 2, price = _price }); model.group_price = priceList; if (type == 1) { if (!bll.Update(model)) { sb.Append("{"); sb.Append("\"id\":\"" + i + "\","); sb.Append("\"code\":\"" + dt.Rows[i]["Barcode"].ToString().Trim() + "\","); sb.Append("\"name\":\"" + dt.Rows[i]["Name"].ToString().Trim() + "\","); sb.Append("\"result\":\"更新失败\","); sb.Append("\"reason\":\"请检查数据格式\""); sb.Append("},"); continue; } type = 0; } else { if (bll.Add(model) == 0) { sb.Append("{"); sb.Append("\"id\":\"" + i + "\","); sb.Append("\"code\":\"" + dt.Rows[i]["Barcode"].ToString().Trim() + "\","); sb.Append("\"name\":\"" + dt.Rows[i]["Name"].ToString().Trim() + "\","); sb.Append("\"result\":\"新增失败\","); sb.Append("\"reason\":\"请检查数据格式\""); sb.Append("},"); continue; } } } string data = sb.ToString(); if (data.Length > 0) { data = data.Substring(0, data.Length - 1); msg = "{\"status\": 1, \"msg\": \"导入成功!\",\"data\":[" + data + "]}"; } else { msg = "{\"status\": 1, \"msg\": \"部分数据导入失败!\",\"data\":[" + data + "]}"; } // Common.Log.LogMsg(msg, "admin"); ////删除已存在的旧文件 //if (!string.IsNullOrEmpty(_delfile)) //{ // Utils.DeleteUpFile(_delfile); //} //返回成功信息 context.Response.Write(msg); context.Response.End(); }
private bool DoAdd() { bool result = true; Model.article_news model = new Model.article_news(); 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.author = txtAuthor.Text.Trim(); model.from = txtFrom.Text.Trim(); //自动提取摘要 if (txtZhaiyao.Text.Trim() != string.Empty) { model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 250); } else { model.zhaiyao = Utils.DropHTML(txtContent.Value, 250); } model.link_url = txtLinkUrl.Text.Trim(); //检查是否有自定义图片 if (txtImgUrl.Text.Trim() != "") { model.img_url = txtImgUrl.Text; } else { model.img_url = focus_photo.Value; } model.content = txtContent.Value; 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.digg_good = int.Parse(txtDiggGood.Text.Trim()); model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); 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[0].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; //} //保存相册 string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_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 { big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } //如果为外链模型,则不需要发布过程 if (model.category_id == (int)DTEnums.CatergoryID.ad_url) { model.is_publish = 1; } if (bll.Add(model) < 1) { result = false; } return result; }
private bool DoAdd() { bool result = true; Model.article_content model = new Model.article_content(); BLL.article bll = new BLL.article(); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.call_index = txtCallIndex.Text.Trim(); model.category_id = 0; model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); 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.Text.Trim(); model.digg_good = int.Parse(txtDiggGood.Text.Trim()); model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); model.is_msg = 0; model.is_red = 0; model.is_lock = 0; if (bll.Add(model) < 1) { result = false; } return result; }
private bool DoAdd() { bool result = false; Model.article model = new Model.article(); BLL.article bll = new BLL.article(); model.site_id = this.channelModel.site_id; 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.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); model.click = int.Parse(txtClick.Text.Trim()); model.is_msg = 0; model.is_top = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_top = 1; } model.is_sys = 1; //管理员发布 model.user_name = GetAdminInfo().user_name; //获得当前登录用户名 if (cbStatus.Checked == false) { model.status = 2; } else { model.status = GetAdminInfo().is_audit; } 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 { channel_id = this.channel_id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { channel_id = this.channel_id, original_path = imgArr[1], thumb_path = imgArr[2] }); } } } model.albums = 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 { channel_id = this.channel_id, group_id = _groupid, price = _price }); } model.group_price = priceList; #endregion if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加" + this.channelModel.title + "频道内容:" + model.title); //记录日志 result = true; } return(result); }
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_company model = new Model.article_company(); 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.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 = Utils.ToHtml(txtContent.Text); model.digg_good = int.Parse(txtDiggGood.Text.Trim()); model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); model.is_msg = 0; model.is_red = 0; model.is_top = 0; model.is_lock = 0; model.telephone = txtTelephone.Text.Trim(); model.user = txtContact.Text.Trim(); model.address = txtAddress.Text.Trim(); model.remark1 = ""; model.remark2 = 0; model.x_lng = ""; model.y_lat = ""; model.line = Utils.ToHtml(txtLine.Text.Trim()); model.price = decimal.Parse(txtPrice.Text.Trim()); model.sell_price = decimal.Parse(txtSellPrice.Text.Trim()); model.flight_num = txtFlightNum.Text.Trim(); model.seat_price = txtFlightSeat.Text.Trim(); model.begin_date = txtBeginDate.Text.Trim(); model.end_date = txtEndDate.Text.Trim(); model.entry_port = txtEntryPort.Text.Trim(); model.visa_type = txtVisaType.Text.Trim(); model.visa_nation = txtVisaNation.Text.Trim(); model.visa_data = Utils.ToHtml(txtVisaData.Text.Trim()); //if (cblItem.Items[0].Selected == true) //{ // model.is_msg = 1; //} if (cblItem.Items[0].Selected == true) { model.is_red = 1; } //检查是否有自定义图片 if (txtImgUrl.Text.Trim() != "") { model.img_url = txtImgUrl.Text; } else { model.img_url = focus_photo.Value; } //保存相册 string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_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 { big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } if (bll.Add(model) < 1) { result = false; } return result; }
private bool DoAdd() { bool result = false; Model.article model = new Model.article(); BLL.article bll = new BLL.article(); 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(); //内容摘要提取内容前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()); #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(MXEnums.ActionEnum.Add.ToString(), "添加" + levelName + "内容:" + model.title); //记录日志 result = true; } return(result); }
private bool DoAdd() { bool result = true; Model.article_goods model = new Model.article_goods(); 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.goods_no = txtGoodsNo.Text; model.stock_quantity = int.Parse(txtStockQuantity.Text); model.market_price = decimal.Parse(txtMarketPrice.Text); model.sell_price = decimal.Parse(txtSellPrice.Text); model.point = int.Parse(txtPoint.Text); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = focus_photo.Value; model.content = txtContent.Value; 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.digg_good = int.Parse(txtDiggGood.Text.Trim()); model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); 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; } //会员组价格 List <Model.goods_group_price> priceList = new List <Model.goods_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.goods_group_price { group_id = _groupid, price = _price }); } model.goods_group_prices = priceList; //保存相册 string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_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 { big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } //扩展属性 BLL.attributes bll2 = new BLL.attributes(); DataSet ds2 = bll2.GetList("channel_id=" + this.channel_id); List <Model.attribute_value> attrls = new List <Model.attribute_value>(); foreach (DataRow dr in ds2.Tables[0].Rows) { int attr_id = int.Parse(dr["id"].ToString()); string attr_title = dr["title"].ToString(); string attr_value = Request.Form["content_" + attr_id]; if (!string.IsNullOrEmpty(attr_value)) { attrls.Add(new Model.attribute_value { attribute_id = attr_id, title = attr_title, content = attr_value }); } } model.attribute_values = attrls; if (bll.Add(model) < 1) { result = false; } return(result); }
private bool DoAdd() { bool result = true; Model.article_goods model = new Model.article_goods(); 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.goods_no = txtPhone.Text.Trim(); model.stock_quantity = int.Parse(txtStockQuantity.Text); model.market_price = decimal.Parse(txtSellPrice.Text); model.sell_price = decimal.Parse(txtSellPrice.Text); model.point = 00; model.link_url = ""; model.img_url = focus_photo.Value; model.content = txtContent.Text; model.seo_title = ""; model.seo_keywords = ""; model.seo_description = ""; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.click = 0; model.digg_good = 0; model.digg_bad = 0; 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; } //保存相册 string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_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 { big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } model.user_id = 1; if (bll.Add(model) < 1) { result = false; } return result; }
private bool DoAdd() { bool result = true; Model.article_goods model = new Model.article_goods(); BLL.article bll = new BLL.article(); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0); model.goods_no = txtY.Text; model.sell_price = Utils.StrToDecimal(txtMarketPrice.Text, 0); //model.sell_price = decimal.Parse(txtSellPrice.Text); model.point = Utils.StrToInt(txtPoint.Text, 0); model.img_url = focus_photo.Value; model.content = txtContent.Value; model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim(); model.seo_description = txtSeoDescription.Text.Trim(); //model.sort_id = Utils.StrToInt(txtSortId.Text.Trim()); //model.click = Utils.StrToInt(txtClick.Text.Trim()); model.digg_good = Utils.StrToInt(txtDiggGood.Text.Trim(), 0); //model.digg_bad = Utils.StrToInt(txtDiggBad.Text.Trim()); if (string.IsNullOrEmpty(txtTime.Text)) { model.add_time = DateTime.Now; } else { model.add_time = DateTime.Parse(txtTime.Text); } model.is_msg = 0; model.is_top = 0; model.is_red = 0; model.is_hot = 0; model.is_slide = 0; model.is_lock = 0; model.lianxiren = txtuser.Text; model.is_top = Utils.StrToInt(cblItem.SelectedValue, 0); //if (cblItem.Items[0].Selected == true) //{ // model.is_msg = 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; //} //會員組價格 List <Model.goods_group_price> priceList = new List <Model.goods_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.goods_group_price { group_id = _groupid, price = _price }); } model.goods_group_prices = priceList; //儲存相冊 string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_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 { big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } //擴展屬性 BLL.attributes bll2 = new BLL.attributes(); DataSet ds2 = bll2.GetList("channel_id=" + this.channel_id); List <Model.attribute_value> attrls = new List <Model.attribute_value>(); foreach (DataRow dr in ds2.Tables[0].Rows) { int attr_id = Utils.StrToInt(dr["id"].ToString(), 0); string attr_title = dr["title"].ToString(); string attr_value = Request.Form["content_" + attr_id]; if (!string.IsNullOrEmpty(attr_value)) { attrls.Add(new Model.attribute_value { attribute_id = attr_id, title = attr_title, content = attr_value }); } } model.attribute_values = attrls; model.Postid = CheckBoxList1.SelectedValue; model.Type = Utils.StrToInt(cblItem.SelectedValue, 0); model.AddType = 0; //model.Status = 1; #region 宴會廳參數 model.link_url = txtZhuoShu.Text.Trim(); //桌數 model.fuwuxiangju = txtSize.Text; //尺寸 model.stock_quantity = chkKitchen.Checked == true ? 1 : 0; //廚房 model.fangshi = chkStage.Checked == true ? 1 : 0; //舞台 model.quyu = chkSound.Checked == true ? 1 : 0; //音響 model.jiaqianQJ = chkScreen.Checked == true ? 1 : 0; //投螢幕; model.shangpinType = ddlForm.Text.Trim(); //形式 #endregion model.mianji = Utils.StrToInt(txtMianJi.Text, 0); if (!string.IsNullOrEmpty(ddlhuxing.SelectedValue)) { model.huxing = Utils.StrToInt(ddlhuxing.SelectedValue, 0); } if (!string.IsNullOrEmpty(ddlditie.SelectedValue)) { model.xianlu = Utils.StrToInt(ddlditie.SelectedValue, 0); } model.yajin = string.IsNullOrEmpty(txtyajin.Text) ? 0 : Utils.StrToInt(txtyajin.Text, 0); model.zuoxiang = txtzuoxiang.Text; model.louceng = txtlouceng.Text; model.xingneng = txtxingneng.Text; model.yongtu = txtSinglePrice.Text; model.chewei = chkPort.Checked == true ? "有" : "無"; model.shequ = txtshequ.Text; model.dizhi = txtdizhi.Text; model.gongsi = txtgongsi.Text; model.dianhua = txtdianhua.Text; model.Areaid = Utils.StrToInt(ddlAreaid.SelectedValue, 0); //if (!bll.Update(model)) //{ // result = false; //} model.Status = xiajiacheck.Checked == true ? 0 : 1; if (bll.Add(model) < 1) { result = false; } return(result); }
private bool DoAdd() { bool result = true; Model.article_goods model = new Model.article_goods(); 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.goods_no = txtGoodsNo.Text; model.stock_quantity = int.Parse(txtStockQuantity.Text); model.market_price = decimal.Parse(txtMarketPrice.Text); model.sell_price = decimal.Parse(txtSellPrice.Text); model.point = int.Parse(txtPoint.Text); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = focus_photo.Value; model.content = txtContent.Value; 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.digg_good = int.Parse(txtDiggGood.Text.Trim()); model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); 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; } //会员组价格 List<Model.goods_group_price> priceList = new List<Model.goods_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.goods_group_price { group_id = _groupid, price = _price }); } model.goods_group_prices = priceList; //保存相册 string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_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 { big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } //扩展属性 BLL.attributes bll2 = new BLL.attributes(); DataSet ds2 = bll2.GetList("channel_id=" + this.channel_id); List<Model.attribute_value> attrls = new List<Model.attribute_value>(); foreach (DataRow dr in ds2.Tables[0].Rows) { int attr_id = int.Parse(dr["id"].ToString()); string attr_title = dr["title"].ToString(); string attr_value = Request.Form["content_" + attr_id]; if (!string.IsNullOrEmpty(attr_value)) { attrls.Add(new Model.attribute_value { attribute_id = attr_id, title = attr_title, content = attr_value }); } } model.attribute_values = attrls; if (bll.Add(model) < 1) { result = false; } return result; }
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.area_id = Utils.StrToInt(ddlAreaId.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()); //如果不是超级管理员提交为待审核 if (GetAdminInfo().role_type != 1) { model.status = 1; } else { 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.user_id = GetAdminInfo().id; 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[] specSellDateArr = Request.Form.GetValues("hide_spec_sell_date"); 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 && specSellDateArr != 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), sell_date = Utils.StrToDateTime(specSellDateArr[i], DateTime.Now), 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(PLEnums.ActionEnum.Add.ToString(), "添加" + this.channel_name + "频道内容:" + model.title); //记录日志 result = true; } return(result); }
private bool DoAdd() { bool result = false; Model.article model = new Model.article(); BLL.article bll = new BLL.article(); model.wheresql = "more"; model.channel_id = this.channel_id; model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0); model.brand_id = Utils.StrToInt(ddlType.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(); //內容摘要提取內容前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_tui = 0; model.is_zhe = 0; if (cblItem.Items[0].Selected == true) { model.is_tui = 1; } if (cblItem.Items[1].Selected == true) { model.is_zhe = 1; } model.user_name = GetAdminInfo().user_name; //獲得當前登錄用戶名 model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.begin_time = Utils.StrToDateTime(txtBeginTime.Text.Trim()); model.end_time = Utils.StrToDateTime(txtEndTime.Text.Trim()); DateTime _end_time; if (DateTime.TryParse(txtUpdate.Text.Trim(), out _end_time)) { model.update_time = _end_time; } DateTime __end_time; if (DateTime.TryParse(txt_Xia_Date.Text.Trim(), out __end_time)) { model.xia_date = __end_time; } if (cbIsLock.Checked) { model.is_msg = 1; } else { model.is_msg = 0; } //分表 model.sell_price = Utils.StrToDecimal(txtSell_price.Text, 0); model.market_price = Utils.StrToDecimal(txtMarket_price.Text, 0); model.point = Utils.StrToInt(txtPoint.Text, 0); model.goods_no = txtGoods_no.Text; model.update_time = DateTime.Now; model.guige = txtGuige.Text; model.sub_title = txtSub_title.Text; model.guigemore = txtGuigeMore.Value; model.shuoming = txtShuo.Value; System.Text.StringBuilder sb = new StringBuilder(); sb.Append(','); foreach (ListItem li in cbMore.Items) { if (li.Selected) { sb.AppendFormat("{0},", li.Value); } } model.more_type = sb.ToString(); model.tags = txtTag.Text + "$" + txtTag1.Text + "$" + txtTag2.Text; #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 儲存會員組價格============== //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 aid = bll.Add(model); #region 保存组合商品============== BLL.goods_group bll_good_group = new BLL.goods_group(); StringBuilder idList = new StringBuilder(); string[] goodsGroupIdArr = Request.Form.GetValues("goods_group_id"); string[] parentIdArr = Request.Form.GetValues("parent_id"); string[] goodsIdArr = Request.Form.GetValues("goods_id"); string[] goodsTitleArr = Request.Form.GetValues("goods_group_title"); string[] goodsColorArr = Request.Form.GetValues("goods_group_color"); string[] originalPriceArr = Request.Form.GetValues("original_price"); string[] newPriceArr = Request.Form.GetValues("new_price"); if (goodsGroupIdArr != null && parentIdArr != null && goodsIdArr != null && goodsTitleArr != null && goodsColorArr != null && originalPriceArr != null && newPriceArr != null && goodsGroupIdArr.Length > 0 && parentIdArr.Length > 0 && goodsIdArr.Length > 0 && goodsTitleArr.Length > 0 && goodsColorArr.Length > 0 && originalPriceArr.Length > 0 && newPriceArr.Length > 0) { for (int i = 0; i < goodsGroupIdArr.Length; i++) { int groupGoodsId = Utils.StrToInt(goodsGroupIdArr[i], 0); int parentId = Utils.StrToInt(parentIdArr[i], 0); int goodsId = Utils.StrToInt(goodsIdArr[i], 0); Decimal originalPrice = Utils.StrToDecimal(originalPriceArr[i], 0); Decimal newPrice = Utils.StrToDecimal(newPriceArr[i], 0); Model.goods_group model_goods_group = null; bool update = true; if (groupGoodsId == 0) { model_goods_group = new Model.goods_group(); update = false; } else { model_goods_group = bll_good_group.GetModel(groupGoodsId); } model_goods_group.goods_id = goodsId; model_goods_group.parent_id = parentId; model_goods_group.title = goodsTitleArr[i]; model_goods_group.color = goodsColorArr[i]; model_goods_group.new_price = newPrice; model_goods_group.original_price = originalPrice; model_goods_group.main_id = model.id; if (update) { bll_good_group.Update(model_goods_group); idList.Append(model_goods_group.id + ","); } else { int a = bll_good_group.Add(model_goods_group); idList.Append(a + ","); } } } #endregion if (aid > 0) { Model.goods modelgoods = new Model.goods(); modelgoods.goods_no = model.goods_no; modelgoods.img_url = model.img_url; modelgoods.parent_id = aid; modelgoods.market_price = model.market_price; modelgoods.sell_price = model.sell_price; modelgoods.guige = txtGuige.Text; modelgoods.stock_quantity = Utils.StrToInt(txtStock_quantity.Text, 0); modelgoods.chang = Utils.StrToDecimal(txtChang.Text, 0); modelgoods.kuan = Utils.StrToDecimal(txtKuan.Text, 0); modelgoods.gao = Utils.StrToDecimal(txtGao.Text, 0); modelgoods.zhong = Utils.StrToDecimal(txtZhong.Text, 0); int newid = new BLL.goods().Add(modelgoods); if (newid > 0) { bll.UpdateField(aid, "team_id=" + newid + ""); result = true; } AddAdminLog(TWEnums.ActionEnum.Add.ToString(), "添加" + this.channel_name + "頻道內容:" + model.title); //記錄日誌 result = true; } return(result); }
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; }
private bool DoAdd() { bool result = true; Model.article_download model = new Model.article_download(); 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.content = txtContent.Value; 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.digg_good = int.Parse(txtDiggGood.Text.Trim()); model.digg_bad = int.Parse(txtDiggBad.Text.Trim()); model.is_msg = 0; model.is_red = 0; model.is_lock = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_red = 1; } if (cblItem.Items[2].Selected == true) { model.is_lock = 1; } //保存附件 string hidFileList = Request.Params["hidFileName"]; if (!string.IsNullOrEmpty(hidFileList)) { string[] fileListArr = hidFileList.Split(','); string[] pointArr = Request.Form.GetValues("txtPoint"); List<Model.download_attach> ls = new List<Model.download_attach>(); for (int i = 0; i < fileListArr.Length; i++) { string[] fileArr = fileListArr[i].Split('|'); if (fileArr.Length == 3) { int fileSize = Utils.GetFileSize(fileArr[2]); string fileExt = Utils.GetFileExt(fileArr[2]); int _point = int.Parse(pointArr[i]); ls.Add(new Model.download_attach { id = int.Parse(fileArr[0]), title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt, point=_point }); } } model.download_attachs = ls; } if (bll.Add(model) < 1) { result = false; } return result; }
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 = SFUtils.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 = this.wid; //内容摘要提取内容前255个字符 if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim())) { model.zhaiyao = SFUtils.DropHTML(txtContent.Value, 255); } else { model.zhaiyao = SFUtils.DropHTML(txtZhaiyao.Text, 255); } model.content = txtContent.Value; model.sort_id = SFUtils.StrToInt(txtSortId.Text.Trim(), 99); model.click = int.Parse(txtClick.Text.Trim()); model.status = SFUtils.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 = ""; //获得当前登录用户名 model.add_time = SFUtils.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 = SFUtils.StrToInt(attachFileSizeArr[i], 0); string fileExt = SFUtils.GetFileExt(attachFilePathArr[i]); int _point = SFUtils.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(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; }