private bool DoEdit(int _id) { bool result = true; BLL.article bll = new BLL.article(); Model.article_goods model = bll.GetGoodsModel(_id); 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(txtSellPrice.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.Text; //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; } //保存相册 if (model.albums != null) model.albums.Clear(); string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_photo_remark"); if (albumArr != null) { List<Model.article_albums> ls = new List<Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = int.Parse(imgArr[0]); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } if (!bll.Update(model)) { result = false; } return result; }
private bool DoEdit(int _id) { bool result = true; BLL.article bll = new BLL.article(); Model.article_goods model = bll.GetGoodsModel(_id); 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 hidPriceId = 0; if (!string.IsNullOrEmpty(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value)) { hidPriceId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value); } int hidGroupId = 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 { id = hidPriceId, article_id = _id, group_id = hidGroupId, price = _price }); } model.goods_group_prices = priceList; //保存相册 if (model.albums != null) model.albums.Clear(); string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_photo_remark"); if (albumArr != null) { List<Model.article_albums> ls = new List<Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = int.Parse(imgArr[0]); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, 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_id = Request.Form["value_" + attr_id]; string attr_value_content = Request.Form["content_" + attr_id]; if (!string.IsNullOrEmpty(attr_value_id) && !string.IsNullOrEmpty(attr_value_content)) { attrls.Add(new Model.attribute_value { id = Convert.ToInt32(attr_value_id), article_id = _id, attribute_id = attr_id, title = attr_title, content = attr_value_content }); } } model.attribute_values = attrls; if (!bll.Update(model)) { 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 DoEdit(int _id) { bool result = false; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_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(); //内容摘要提取内容前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.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.update_time = DateTime.Now; #region 保存相册==================== //检查是否有自定义图片 if (txtImgUrl.Text.Trim() == "") { model.img_url = hidFocusPhoto.Value; } if (model.albums != null) { model.albums.Clear(); } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null) { List <Model.article_albums> ls = new List <Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = Utils.StrToInt(imgArr[0], 0); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2] }); } } } model.albums = ls; } #endregion #region 保存附件==================== if (model.attach != null) { model.attach.Clear(); } string[] attachIdArr = Request.Form.GetValues("hid_attach_id"); 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 (attachIdArr != null && attachFileNameArr != null && attachFilePathArr != null && attachFileSizeArr != null && attachPointArr != null && attachIdArr.Length > 0 && 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 attachId = Utils.StrToInt(attachIdArr[i], 0); 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 { id = attachId, article_id = _id, file_name = attachFileNameArr[i], file_path = attachFilePathArr[i], file_size = fileSize, file_ext = fileExt, point = _point, }); } model.attach = ls; } #endregion if (bll.Update(model)) { AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改" + levelName + "内容:" + model.title); //记录日志 result = true; } return(result); }
private bool DoEdit(int _id) { bool result = false; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_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.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.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.update_time = DateTime.Now; 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; model.goods = new List<Model.article_goods>(); } //保存商品信息 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 { id = Utils.StrToInt(specGoodsIdArr[i], 0), article_id = model.id, 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; } if (model.albums != null) { model.albums.Clear(); } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null) { List<Model.article_albums> ls = new List<Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = Utils.StrToInt(imgArr[0], 0); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2] }); } } } model.albums = ls; } #endregion #region 保存附件==================== if (model.attach != null) { model.attach.Clear(); } string[] attachIdArr = Request.Form.GetValues("hid_attach_id"); 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 (attachIdArr != null && attachFileNameArr != null && attachFilePathArr != null && attachFileSizeArr != null && attachPointArr != null && attachIdArr.Length > 0 && 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 attachId = Utils.StrToInt(attachIdArr[i], 0); 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 { id = attachId, article_id = _id, file_name = attachFileNameArr[i], file_path = attachFilePathArr[i], file_size = fileSize, file_ext = fileExt, point = _point, }); } model.attach = ls; } #endregion if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "频道内容:" + model.title); //记录日志 result = true; } return result; }
//批量发布 protected void lbtnPublish_Click(object sender, EventArgs e) { try { ChkAdminLevel(channel_id, DTEnums.ActionEnum.Publish.ToString()); //检查权限 BLL.article bll = new BLL.article(); Repeater rptList = new Repeater(); rptList = this.rptList1; Model.article_news model_new = null; for (int i = 0; i < rptList.Items.Count; i++) { int _id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { model_new = bll.GetNewsModel(_id); Publish publish_new = new Publish(); //开始发布 string serverFileName = publish_new.Publish_News(model_new.title, model_new.content, model_new.from, model_new.add_time.ToShortDateString()); //修改URL字段 if (!string.IsNullOrEmpty(serverFileName)) { model_new.link_url = serverFileName; model_new.is_publish = 1; bll.Update(model_new); } //bll.UpdateField(_id, "link_url='" + serverFileName + "'"); //bll.UpdateNewsField(_id, "is_publish=1"); } } JscriptMsg("批量发布成功啦!", Utils.CombUrlTxt("list.aspx", "channel_id={0}&category_id={1}&keywords={2}&property={3}", this.channel_id.ToString(), this.category_id.ToString(), this.keywords, this.property), "Success"); } catch { JscriptMsg("发布过程中遇到错误,请联系管理员!", Utils.CombUrlTxt("list.aspx", "channel_id={0}&category_id={1}&keywords={2}&property={3}", this.channel_id.ToString(), this.category_id.ToString(), this.keywords, this.property), "Error"); } }
private bool DoEdit(int _id) { bool result = true; BLL.article bll = new BLL.article(); Model.article_content model = bll.GetContentModel(_id); 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.Update(model)) { result = false; } return result; }
private bool DoEdit(int _id) { bool result = true; BLL.article bll = new BLL.article(); Model.article_news model = bll.GetNewsModel(_id); 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.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 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; } //保存相册 if (model.albums != null) model.albums.Clear(); string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_photo_remark"); if (albumArr != null) { List<Model.article_albums> ls = new List<Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = int.Parse(imgArr[0]); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, 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_id = Request.Form["value_" + attr_id]; string attr_value_content = Request.Form["content_" + attr_id]; if (!string.IsNullOrEmpty(attr_value_id) && !string.IsNullOrEmpty(attr_value_content)) { attrls.Add(new Model.attribute_value { id = Convert.ToInt32(attr_value_id), article_id = _id, attribute_id = attr_id, title = attr_title, content = attr_value_content }); } } model.attribute_values = attrls; if (!bll.Update(model)) { result = false; } return result; }
private bool DoEdit(int _id) { bool result = false; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_id); 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.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.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; } if (model.albums != null) { model.albums.Clear(); } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null) { List <Model.article_albums> ls = new List <Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = Utils.StrToInt(imgArr[0], 0); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _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 hidPriceId = 0; // if (!string.IsNullOrEmpty(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value)) // { // hidPriceId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value); // } // int hidGroupId = 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 { id = hidPriceId, article_id = _id, group_id = hidGroupId, price = _price }); //} //model.group_price = priceList; //#endregion Model.goods modelgoods = new BLL.goods().GetModel(model.team_id); modelgoods.goods_no = model.goods_no; modelgoods.img_url = model.img_url; 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); new BLL.goods().Update(modelgoods); if (bll.Update(model)) { AddAdminLog(TWEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "頻道內容:" + model.title); //記錄日誌 result = true; } return(result); }
private bool DoEdit(int _id) { bool result = false; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_id); model.channel_id = this.channel_id; 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); } //是否将编辑器远程图片保存到本地 if (siteConfig.fileremote == 1) { model.content = AutoRemoteImageSave(txtContent.Value); } else { model.content = txtContent.Value; } model.category_id = Utils.StrToInt(ddlParentId.SelectedValue, 0); 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.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.update_time = DateTime.Now; model.fields = SetFieldValues(this.channel_id); //扩展字段赋值 #region 保存相册==================== //检查是否有自定义图片 if (txtImgUrl.Text.Trim() == "") { model.img_url = hidFocusPhoto.Value; } if (model.albums != null) { model.albums.Clear(); } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null) { List <Model.article_albums> ls = new List <Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = Utils.StrToInt(imgArr[0], 0); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2] }); } } } model.albums = ls; } #endregion #region 保存附件==================== if (model.attach != null) { model.attach.Clear(); } string[] attachIdArr = Request.Form.GetValues("hid_attach_id"); 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 (attachIdArr != null && attachFileNameArr != null && attachFilePathArr != null && attachFileSizeArr != null && attachPointArr != null && attachIdArr.Length > 0 && 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 attachId = Utils.StrToInt(attachIdArr[i], 0); 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 { id = attachId, article_id = _id, 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 hidPriceId = 0; if (!string.IsNullOrEmpty(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value)) { hidPriceId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value); } int hidGroupId = 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 { id = hidPriceId, article_id = _id, group_id = hidGroupId, price = _price }); } model.group_price = priceList; #endregion if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "频道内容:" + model.title); //记录日志 result = true; } return(result); }
private bool DoEdit(int _id) { bool result = false; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_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.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.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.update_time = DateTime.Now; 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; model.goods = new List <Model.article_goods>(); } //保存商品信息 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 { id = Utils.StrToInt(specGoodsIdArr[i], 0), article_id = model.id, 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; } if (model.albums != null) { model.albums.Clear(); } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null) { List <Model.article_albums> ls = new List <Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = Utils.StrToInt(imgArr[0], 0); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2] }); } } } model.albums = ls; } #endregion #region 保存附件==================== if (model.attach != null) { model.attach.Clear(); } string[] attachIdArr = Request.Form.GetValues("hid_attach_id"); 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 (attachIdArr != null && attachFileNameArr != null && attachFilePathArr != null && attachFileSizeArr != null && attachPointArr != null && attachIdArr.Length > 0 && 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 attachId = Utils.StrToInt(attachIdArr[i], 0); 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 { id = attachId, article_id = _id, file_name = attachFileNameArr[i], file_path = attachFilePathArr[i], file_size = fileSize, file_ext = fileExt, point = _point, }); } model.attach = ls; } #endregion if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "频道内容:" + model.title); //记录日志 result = true; } 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); }
private bool DoEdit(int _id) { bool result = false; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_id); 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.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.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; } if (model.albums != null) { model.albums.Clear(); } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null) { List <Model.article_albums> ls = new List <Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = Utils.StrToInt(imgArr[0], 0); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _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 hidPriceId = 0; // if (!string.IsNullOrEmpty(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value)) // { // hidPriceId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value); // } // int hidGroupId = 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 { id = hidPriceId, article_id = _id, group_id = hidGroupId, 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); } #region 儲存子件============== BLL.goods bll_goods = new BLL.goods(); StringBuilder idList = new StringBuilder(); string[] itemid = Request.Form.GetValues("item_id"); 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 = null; int id = int.Parse(itemid[i].ToString()); bool update = true; if (id == 0) { model_goods = new Model.goods(); update = false; } else { model_goods = bll_goods.GetModel(id); } model_goods.parent_id = model.id; 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); if (update) { bll_goods.Update(model_goods); idList.Append(model_goods.id + ","); } else { int a = bll_goods.Add(model_goods); idList.Append(a + ","); } } } string id_list = Utils.DelLastChar(idList.ToString(), ","); if (!string.IsNullOrEmpty(id_list)) { Tea.DBUtility.DbHelperSQL.ExecuteSql("delete from shop_goods where parent_id=" + model.id + " and id not in(select id from shop_goods where id in(" + id_list + "))"); } #endregion if (bll.Update(model)) { AddAdminLog(TWEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "頻道內容:" + model.title); //記錄日誌 result = true; } return(result); }
private bool DoEdit(int _id) { bool result = true; BLL.article bll = new BLL.article(); Model.article_download model = bll.GetDownloadModel(_id); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.category_id = int.Parse(ddlCategoryId.SelectedValue); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.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; } //保存附件 if (model.download_attachs != null) { model.download_attachs.Clear(); } string hidFileList = Request.Params["hidFileName"]; string[] pointArr = Request.Form.GetValues("txtPoint"); if (!string.IsNullOrEmpty(hidFileList)) { string[] fileListArr = hidFileList.Split(','); 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 attach_id = int.Parse(fileArr[0]); int fileSize = Utils.GetFileSize(fileArr[2]); string fileExt = Utils.GetFileExt(fileArr[2]); int _point = int.Parse(pointArr[i]); //删除旧文件 if (attach_id > 0) { new BLL.download_attach().DeleteFile(attach_id, fileArr[2]); } ls.Add(new Model.download_attach { id = attach_id, article_id = _id, title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt, point = _point }); } } model.download_attachs = ls; } if (!bll.Update(model)) { result = false; } return result; }
private bool DoEdit(int _id) { bool result = true; BLL.article bll = new BLL.article(); Model.article_news model = bll.GetNewsModel(_id); 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.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 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; } //保存相册 if (model.albums != null) { model.albums.Clear(); } string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_photo_remark"); if (albumArr != null) { List <Model.article_albums> ls = new List <Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = int.Parse(imgArr[0]); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, 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_id = Request.Form["value_" + attr_id]; string attr_value_content = Request.Form["content_" + attr_id]; if (!string.IsNullOrEmpty(attr_value_id) && !string.IsNullOrEmpty(attr_value_content)) { attrls.Add(new Model.attribute_value { id = Convert.ToInt32(attr_value_id), article_id = _id, attribute_id = attr_id, title = attr_title, content = attr_value_content }); } } model.attribute_values = attrls; if (!bll.Update(model)) { result = false; } return(result); }
private bool DoEdit(int _id) { bool result = true; BLL.article bll = new BLL.article(); Model.article_news model = bll.GetNewsModel(_id); 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.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 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_top = 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 (model.albums != null) model.albums.Clear(); string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_photo_remark"); if (albumArr != null) { List<Model.article_albums> ls = new List<Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = int.Parse(imgArr[0]); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, 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.Update(model)) { result = false; } return result; }
private bool DoEdit(int _id) { bool result = false; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(this.channel_id, _id); 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; } if (cbStatus.Checked == false) { model.status = 2; } else { model.status = GetAdminInfo().is_audit; } model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.update_time = DateTime.Now; model.fields = SetFieldValues(this.channel_id); //扩展字段赋值 #region 保存相册==================== //检查是否有自定义图片 if (txtImgUrl.Text.Trim() == "") { model.img_url = hidFocusPhoto.Value; } if (model.albums != null) { model.albums.Clear(); } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null) { List <Model.article_albums> ls = new List <Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = Utils.StrToInt(imgArr[0], 0); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, channel_id = this.channel_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, channel_id = this.channel_id, article_id = _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 hidPriceId = 0; if (!string.IsNullOrEmpty(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value)) { hidPriceId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value); } int hidGroupId = 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 { id = hidPriceId, channel_id = this.channel_id, article_id = _id, group_id = hidGroupId, price = _price }); } model.group_price = priceList; #endregion if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改" + this.channelModel.title + "频道内容:" + model.title); //记录日志 result = true; } return(result); }
private bool DoEdit(int _id) { bool result = true; BLL.article bll = new BLL.article(); Model.article_company model = bll.GetCompanyModel(_id); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.category_id = int.Parse(ddlCategoryId.SelectedValue); model.link_url = txtLinkUrl.Text.Trim(); //检查是否有自定义图片 if (txtImgUrl.Text.Trim() != "") { model.img_url = txtImgUrl.Text; } else { model.img_url = focus_photo.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.content = Utils.ToTxt(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_lock = 0; model.is_top = 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 (cblItem.Items[2].Selected == true) //{ // model.is_lock = 1; //} //if (cblItem.Items[3].Selected == true) //{ // model.is_top = 1; //} //保存相册 if (model.albums != null) model.albums.Clear(); string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_photo_remark"); if (albumArr != null) { List<Model.article_albums> ls = new List<Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = int.Parse(imgArr[0]); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, big_img = imgArr[1], small_img = imgArr[2] }); } } } model.albums = ls; } if (!bll.Update(model)) { result = false; } return result; }
private bool DoEdit(int _id) { bool result = true; BLL.article bll = new BLL.article(); Model.article_goods model = bll.GetGoodsModel(_id); 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.stock_quantity = Utils.StrToInt(txtStockQuantity.Text); model.sell_price = Utils.StrToDecimal(txtMarketPrice.Text, 0); //model.sell_price = decimal.Parse(txtSellPrice.Text); model.point = Utils.StrToInt(txtPoint.Text, 0); //model.link_url = txtLinkUrl.Text.Trim(); model.img_url = DTRequest.GetFormString("focus_photo"); 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()); model.add_time = Utils.StrToDateTime(txtTime.Text.ToString(), 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.lianxiren = txtuser.Text; //model.shangpinType = txtshangpintype.Text; //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 hidPriceId = 0; if (!string.IsNullOrEmpty(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value)) { hidPriceId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value); } int hidGroupId = 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 { id = hidPriceId, article_id = _id, group_id = hidGroupId, price = _price }); } model.goods_group_prices = priceList; //儲存相冊 if (model.albums != null) { model.albums.Clear(); } string[] albumArr = Request.Form.GetValues("hide_photo_name"); string[] remarkArr = Request.Form.GetValues("hide_photo_remark"); if (albumArr != null) { List <Model.article_albums> ls = new List <Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = Utils.StrToInt(imgArr[0], 0); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, 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_id = Request.Form["value_" + attr_id]; string attr_value_content = Request.Form["content_" + attr_id]; if (!string.IsNullOrEmpty(attr_value_id) && !string.IsNullOrEmpty(attr_value_content)) { attrls.Add(new Model.attribute_value { id = Convert.ToInt32(attr_value_id), article_id = _id, attribute_id = attr_id, title = attr_title, content = attr_value_content }); } } model.attribute_values = attrls; model.Postid = CheckBoxList1.SelectedValue; model.Type = Utils.StrToInt(cblItem.SelectedValue, 0); //if (!string.IsNullOrEmpty(ddlquyu.SelectedValue)) //{ // model.quyu = Convert.ToInt32(ddlquyu.SelectedValue); //} //if (!string.IsNullOrEmpty(ddljiaqian.SelectedValue)) //{ // model.jiaqianQJ = Convert.ToInt32(ddljiaqian.SelectedValue); //} model.mianji = Utils.StrToInt(txtMianJi.Text, 0); if (!string.IsNullOrEmpty(ddlhuxing.SelectedValue)) { model.huxing = Utils.StrToInt(ddlhuxing.SelectedValue, 0); } //if (!string.IsNullOrEmpty(ddlfangshi.SelectedValue)) //{ // model.fangshi = Convert.ToInt32(ddlfangshi.SelectedValue); //} 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.fuwuxiangju = txtfuwxiangmu.Text; model.dianhua = txtdianhua.Text; model.Areaid = Utils.StrToInt(ddlAreaid.SelectedValue, 0); model.Status = 1; model.xiajialiyou = xiajiatext.Value; #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 if (!bll.Update(model)) { result = false; } return(result); }
/// <summary> /// 取消发布 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lbtnEditPublish_Click(object sender, EventArgs e) { BLL.article bll = new BLL.article(); //Repeater rptList = new Repeater(); //rptList = this.rptList1; Model.article_news model_new = null; LinkButton lnkbtn = (LinkButton)sender; int _id = Convert.ToInt32(((HiddenField)lnkbtn.FindControl("hidId")).Value); model_new = bll.GetNewsModel(_id); if (model_new != null) { string temp_url = model_new.link_url; model_new.link_url = ""; model_new.is_publish = 0; if (bll.Update(model_new)) { Utils.DeleteFile(temp_url); //删除文件 } JscriptMsg("取消发布成功啦!", Utils.CombUrlTxt("list.aspx", "channel_id={0}&category_id={1}&keywords={2}&property={3}", this.channel_id.ToString(), this.category_id.ToString(), this.keywords, this.property), "Success"); } else { JscriptMsg("实体获取失败,请联系管理员!", Utils.CombUrlTxt("list.aspx", "channel_id={0}&category_id={1}&keywords={2}&property={3}", this.channel_id.ToString(), this.category_id.ToString(), this.keywords, this.property), "Error"); } }
private bool DoEdit(int _id) { bool result = false; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_id); decimal sell_price = 0; decimal standard_price = 0; decimal standard_group_price = 0; decimal action_price = 0; 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(); //内容摘要提取内容前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; model.is_put = 1; if (isPut.Items[0].Selected) { model.is_put = 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.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.update_time = DateTime.Now; model.fields = SetFieldValues(this.channel_id); //扩展字段赋值 sell_price = Convert.ToDecimal(model.fields["sell_price"]); #region 保存相册==================== //检查是否有自定义图片 if (txtImgUrl.Text.Trim() == "") { model.img_url = hidFocusPhoto.Value; } if (model.albums != null) { model.albums.Clear(); } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null) { List<Model.article_albums> ls = new List<Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = Utils.StrToInt(imgArr[0], 0); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2] }); } } } model.albums = ls; } #endregion #region 保存附件==================== if (model.attach != null) { model.attach.Clear(); } string[] attachIdArr = Request.Form.GetValues("hid_attach_id"); 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 (attachIdArr != null && attachFileNameArr != null && attachFilePathArr != null && attachFileSizeArr != null && attachPointArr != null && attachIdArr.Length > 0 && 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 attachId = Utils.StrToInt(attachIdArr[i], 0); 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 { id = attachId, article_id = _id, 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 hidPriceId = 0; if (!string.IsNullOrEmpty(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value)) { hidPriceId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value); } int hidGroupId = 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 { id = hidPriceId, article_id = _id, group_id = hidGroupId, price = _price }); } model.group_price = priceList; #endregion if (bll.Update(model)) { #region 商品相关 if (channel_name == "goods") { //规格价格 BLL.standard_price bll_price = new BLL.standard_price(); DataTable dt = bll_price.GetList(0, "good_id=" + _id, "id asc").Tables[0]; if (dt != null && dt.Rows.Count > 0) { if (!bll_price.Delete("good_id=" + _id)) { JscriptMsg("价格信息清除失败!", "", "Error"); return false; } } string standard_ids = DTRequest.GetFormString("ck_standard"); string standard_value_ids = DTRequest.GetFormString("ck_standard_value"); 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_value bll_value = new BLL.standard_value(); string[] str_standard_value_arr = standard_value_ids.Split(','); BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price(); DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + _id).Tables[0]; if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0) { if (!bll_standard_group_price.Delete(_id)) { JscriptMsg("清除商品规格会员价格失败!", "", "Error"); return false; } } 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_id = _id; model_price.standard_ids = standard_ids; model_price.good_no = DTRequest.GetFormString("good_no_" + str); 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=sell_price=standard_price = DTRequest.GetFormDecimal("sell_price_" + str, 0); model_price.action_price=action_price = DTRequest.GetFormDecimal("action_price_" + str, 0); model_price.user_price = DTRequest.GetFormDecimal("user_price_" + str, 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.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=standard_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; } } } } //BLL.meal_good bll_meal_good = new BLL.meal_good(); //if (!bll_meal_good.UpdateMealGoodPrice(_id, sell_price, standard_price, standard_group_price, action_price)) //{ // JscriptMsg("套餐商品价格更新失败!", "", "Error"); // return false; //} //单位 BLL.unit bll_unit = new BLL.unit(); bll_unit.Delete(_id); string str_unit = DTRequest.GetFormString("ck_unit"); if (!string.IsNullOrEmpty(str_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(); //删除 bll_alias_good.Delete(_id); 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(); bll_property_good.Delete(_id); 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(); bll_tag_good.Delete(_id); 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.Edit.ToString(), "修改" + this.channel_name + "频道内容:" + model.title); //记录日志 result = true; } return result; }
private bool DoEdit(int _id) { bool result = false; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_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.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.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.update_time = DateTime.Now; model.fields = SetFieldValues(this.channel_id); //扩展字段赋值 #region 保存相册==================== //检查是否有自定义图片 if (txtImgUrl.Text.Trim() == "") { model.img_url = hidFocusPhoto.Value; } if (model.albums != null) { model.albums.Clear(); } string[] albumArr = Request.Form.GetValues("hid_photo_name"); string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); if (albumArr != null) { List<Model.article_albums> ls = new List<Model.article_albums>(); for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); int img_id = Utils.StrToInt(imgArr[0], 0); if (imgArr.Length == 3) { if (!string.IsNullOrEmpty(remarkArr[i])) { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] }); } else { ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2] }); } } } model.albums = ls; } #endregion #region 保存附件==================== if (model.attach != null) { model.attach.Clear(); } string[] attachIdArr = Request.Form.GetValues("hid_attach_id"); 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 (attachIdArr != null && attachFileNameArr != null && attachFilePathArr != null && attachFileSizeArr != null && attachPointArr != null && attachIdArr.Length > 0 && 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 attachId = Utils.StrToInt(attachIdArr[i], 0); 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 { id = attachId, article_id = _id, 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 hidPriceId = 0; if (!string.IsNullOrEmpty(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value)) { hidPriceId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value); } int hidGroupId = 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 { id = hidPriceId, article_id = _id, group_id = hidGroupId, price = _price }); } model.group_price = priceList; #endregion if (bll.Update(model)) { AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "微网站修改" + this.channel_name + "频道内容:" + model.title); //记录日志 result = true; } return result; }
private bool DoEdit(int _id) { bool result = true; BLL.article bll = new BLL.article(); Model.article model = bll.GetModel(_id); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.category_id = int.Parse(ddlCategoryId.SelectedValue); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.author = txtAuthor.Text.Trim(); model.form = txtForm.Text.Trim(); model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 250); model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim(); model.seo_description = txtSeoDescription.Text.Trim(); model.sort_id = int.Parse(txtSortId.Text.Trim()); model.click = int.Parse(txtClick.Text.Trim()); model.content = txtContent.Value; model.is_msg = 0; model.is_top = 0; model.is_red = 0; model.is_hot = 0; model.is_slide = 0; model.is_lock = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_top = 1; } if (cblItem.Items[2].Selected == true) { model.is_red = 1; } if (cblItem.Items[3].Selected == true) { model.is_hot = 1; } if (cblItem.Items[4].Selected == true) { model.is_slide = 1; } if (cblItem.Items[5].Selected == true) { model.is_lock = 1; } if (!bll.Update(model)) { result = false; } return result; }