private bool DoEdit(int _id) { bool result = false; string standard_values = DTRequest.GetFormString("ck_standard_value"); BLL.standard bll = new BLL.standard(); Model.standard model = bll.GetModel(_id); model.title = txt_standard_title.Text.Trim(); model.category_id = Convert.ToInt32(ddlCategoryId.SelectedValue); List <Model.standard_value> lst = new List <Model.standard_value>(); string[] standard_value_arr = standard_values.Split(','); Model.standard_value model_value; foreach (string str in standard_value_arr) { model_value = new Model.standard_value(); model_value.value = str.Split('|')[1]; model_value.add_time = DateTime.Now; lst.Add(model_value); } model.standard_values = lst; if (bll.Update(model)) { //AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改用户信息:" + model.user_name); //记录日志 result = true; } return(result); }
private void ShowInfo(int _id) { BLL.standard bll = new BLL.standard(); Model.standard model = bll.GetModel(_id); ddlCategoryId.SelectedValue = model.category_id.ToString(); txt_standard_title.Text = model.title; foreach (Model.standard_value model_value in model.standard_values) { str_standard_value += "<span onclick=\"ck_standard_value(this)\"> " + model_value.value + "<input type=\"checkbox\" name=\"ck_standard_value\" checked=\"checked\" value=\"0|" + model_value.value + "\" style=\"display:none;\" /> </span>"; } }
private bool DoEdit(int _id) { bool result = false; string standard_values = DTRequest.GetFormString("ck_standard_value"); BLL.standard bll = new BLL.standard(); Model.standard model = bll.GetModel(_id); model.title = txt_standard_title.Text.Trim(); model.category_id = Convert.ToInt32(ddlCategoryId.SelectedValue); List<Model.standard_value> lst = new List<Model.standard_value>(); string[] standard_value_arr = standard_values.Split(','); Model.standard_value model_value; foreach (string str in standard_value_arr) { model_value = new Model.standard_value(); model_value.value = str.Split('|')[1]; model_value.add_time = DateTime.Now; lst.Add(model_value); } model.standard_values = lst; if (bll.Update(model)) { //AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改用户信息:" + model.user_name); //记录日志 result = true; } return result; }
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 void add_order(HttpContext context) { int address_id = DTRequest.GetQueryInt("address"); int freight_id = DTRequest.GetQueryInt("freight"); string car_ids = DTRequest.GetQueryString("car_ids"); Model.users model = new BasePage().GetUserInfo(); if (model == null) { context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,请重新登录!\"}"); return; } //统计购物车 BLL.express bll_express = new BLL.express(); Model.express model_express = bll_express.GetModel(freight_id); if (model_express == null) { context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,该配送方式不存在或已删除!\"}"); return; } BLL.address bll_address = new BLL.address(); Model.address model_address = bll_address.GetModel(address_id); if (model_address == null) { context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,该收货信息不存在或已删除!\"}"); return; } IList<Model.cart_items> iList = DTcms.Web.UI.ShopCart.GetList(model.group_id); if (iList == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,购物车为空,无法结算!\"}"); return; } //保存订单======================================================================= Model.orders model_order = new Model.orders(); model_order.order_no = "B" + Utils.GetOrderNumber(); //订单号B开头为商品订单 model_order.user_id = model.id; model_order.user_name = model.user_name; model_order.payment_id = 0; model_order.express_id = model_express.id; model_order.accept_name = model_address.consignee; model_order.post_code = model_address.zipcode; model_order.telphone = model_address.consignee_phone; model_order.mobile = model_address.consignee_mobile; model_order.address = new BLL.province().GetModel(model_address.province).ProvinceName + "|" + new BLL.city().GetModel(model_address.city).CityName + "|" + new BLL.district().GetModel(model_address.distract).DistrictName + "|" + model_address.content; model_order.message = ""; model_order.express_status = 1; model_order.express_fee = model_express.express_fee; //物流费用 //如果是先款后货的话 //购物积分,可为负数 model_order.add_time = DateTime.Now; //商品详细列表 decimal real_amount = 0; decimal payable_amount = 0; int total_point = 0; List<Model.order_goods> gls = new List<Model.order_goods>(); BLL.standard bll_standard = new BLL.standard(); foreach (Model.cart_items item in iList) { string[] arr_car_id = car_ids.Split('_'); foreach (string str in arr_car_id) { if ((item.id + "-" + item.standard + "-" + item.unit_id).Trim() == str) { //{ //40-1|红色,2|黑色_10-1|红色,2|黑色 商品ID-规格ID|规格值ID,规格ID|规格值ID-单位ID // string[] arr_good_standard=str.Split('-'); // string str_standard = ""; // foreach (string str1 in arr_good_standard) // { // BLL.standard bll_standard = new BLL.standard(); // Model.standard model_standard = bll_standard.GetModel(Convert.ToInt32(str1.Split('|')[0])); // if (model_standard != null) // { // str_standard += model_standard.title + ":" + str1.Split('|')[1]; // } // } string str_standard = ""; //190-14|41-4650 string standard_title_id = ""; string standard_value_id = ""; Model.article model_good = new BLL.article().GetModel(item.id); if (model_good == null) { return; } string good_no = model_good.fields["goods_no"]; //规格 if (!string.IsNullOrEmpty(item.standard)) { string[] arr_standard = item.standard.Split(','); for (int i = 0; i < arr_standard.Length; i++) { Model.standard model_standard = bll_standard.GetModel(Convert.ToInt32(arr_standard[i].Split('|')[0])); Model.standard_value model_standard_value = new BLL.standard_value().GetModel(Convert.ToInt32(arr_standard[i].Split('|')[1])); if (model_standard != null && model_standard_value != null) { str_standard += model_standard.title + ":" + arr_standard[i].Split('|')[1] + ","; standard_title_id += model_standard.id + ","; standard_value_id += model_standard_value.id + ","; } } } if (!string.IsNullOrEmpty(standard_title_id) && !string.IsNullOrEmpty(standard_value_id)) { DataTable dt_standard_value = new BLL.standard_price().GetList("good_id='" + item.id + "' and standard_ids='" + standard_title_id.Substring(0, standard_title_id.Length - 1) + "' and standard_value_ids='" + standard_value_id.Substring(0, standard_value_id.Length - 1) + "'").Tables[0]; if (dt_standard_value != null && dt_standard_value.Rows.Count == 1) { good_no = dt_standard_value.Rows[0]["good_no"].ToString(); } } real_amount += item.user_price * item.quantity; payable_amount += item.price * item.quantity; total_point += item.point * item.quantity; BLL.unit bll_unit = new BLL.unit(); Model.unit model_unit = bll_unit.GetModel(item.unit_id); string str_unit = ""; if (model_unit != null) { str_unit = model_unit.title; if (!string.IsNullOrEmpty(model_unit.content)) { str_unit += "(" + model_unit.content + ")"; } } gls.Add(new Model.order_goods { goods_id = item.id, good_no = good_no, goods_title = item.title, goods_price = item.price, real_price = item.user_price, quantity = item.quantity, point = item.point, standard = (string.IsNullOrEmpty(str_standard) ? "" : str_standard.Substring(0, str_standard.Length - 1)), unit_id = item.unit_id, unit = str_unit }); } } } model_order.payable_amount = payable_amount; model_order.real_amount = real_amount; model.point = total_point; //订单总金额=实付商品金额+运费+支付手续费 model_order.order_amount = model_order.real_amount + model_order.express_fee + model_order.payment_fee; model_order.order_goods = gls; int result = new BLL.orders().Add(model_order); if (result < 1) { context.Response.Write("{\"status\":0, \"msg\":\"订单保存过程中发生错误,请重新提交!\"}"); return; } else { string[] arr_car_id = car_ids.Split('_'); foreach (string str in arr_car_id) { //清空购物车 DTcms.Web.UI.ShopCart.Clear(str); } context.Response.Write("{\"status\":1, \"msg\":\"提交订单成功!\",\"order_no\":\"" + model_order.order_no + "\",\"order_money\":\"" + model_order.order_amount + "\",\"user_money\":\"" + model.amount + "\",\"order_id\":\"" + result + "\"}"); return; } }