Пример #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Model.goods_group> GetList(int article_id)
        {
            List <Model.goods_group> modelList = new List <Model.goods_group>();

            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,main_id,parent_id,goods_id,title,color,size,original_price,new_price ");
            strSql.Append(" FROM " + databaseprefix + "goods_group ");
            strSql.Append(" where main_id=" + article_id);
            DataTable dt = DbHelperSQL.Query(strSql.ToString()).Tables[0];

            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Model.goods_group model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.goods_group();
                    if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["main_id"] != null && dt.Rows[n]["main_id"].ToString() != "")
                    {
                        model.main_id = int.Parse(dt.Rows[n]["main_id"].ToString());
                    }
                    if (dt.Rows[n]["parent_id"] != null && dt.Rows[n]["parent_id"].ToString() != "")
                    {
                        model.parent_id = int.Parse(dt.Rows[n]["parent_id"].ToString());
                    }
                    if (dt.Rows[n]["goods_id"] != null && dt.Rows[n]["goods_id"].ToString() != "")
                    {
                        model.goods_id = int.Parse(dt.Rows[n]["goods_id"].ToString());
                    }
                    model.title = dt.Rows[n]["title"].ToString();
                    model.color = dt.Rows[n]["color"].ToString();
                    model.size  = dt.Rows[n]["size"].ToString();
                    if (dt.Rows[n]["original_price"] != null && dt.Rows[n]["original_price"].ToString() != "")
                    {
                        model.original_price = Decimal.Parse(dt.Rows[n]["original_price"].ToString());
                    }
                    if (dt.Rows[n]["new_price"] != null && dt.Rows[n]["new_price"].ToString() != "")
                    {
                        model.new_price = Decimal.Parse(dt.Rows[n]["new_price"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #2
0
        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);



            #region 保存组合商品==============
            BLL.goods_group bll_good_group   = new BLL.goods_group();
            StringBuilder   idList           = new StringBuilder();
            string[]        goodsGroupIdArr  = Request.Form.GetValues("goods_group_id");
            string[]        parentIdArr      = Request.Form.GetValues("parent_id");
            string[]        goodsIdArr       = Request.Form.GetValues("goods_id");
            string[]        goodsTitleArr    = Request.Form.GetValues("goods_group_title");
            string[]        goodsColorArr    = Request.Form.GetValues("goods_group_color");
            string[]        originalPriceArr = Request.Form.GetValues("original_price");
            string[]        newPriceArr      = Request.Form.GetValues("new_price");

            if (goodsGroupIdArr != null && parentIdArr != null && goodsIdArr != null && goodsTitleArr != null && goodsColorArr != null && originalPriceArr != null && newPriceArr != null && goodsGroupIdArr.Length > 0 && parentIdArr.Length > 0 && goodsIdArr.Length > 0 && goodsTitleArr.Length > 0 && goodsColorArr.Length > 0 && originalPriceArr.Length > 0 && newPriceArr.Length > 0)
            {
                for (int i = 0; i < goodsGroupIdArr.Length; i++)
                {
                    int     groupGoodsId  = Utils.StrToInt(goodsGroupIdArr[i], 0);
                    int     parentId      = Utils.StrToInt(parentIdArr[i], 0);
                    int     goodsId       = Utils.StrToInt(goodsIdArr[i], 0);
                    Decimal originalPrice = Utils.StrToDecimal(originalPriceArr[i], 0);
                    Decimal newPrice      = Utils.StrToDecimal(newPriceArr[i], 0);

                    Model.goods_group model_goods_group = null;

                    bool update = true;
                    if (groupGoodsId == 0)
                    {
                        model_goods_group = new Model.goods_group();
                        update            = false;
                    }
                    else
                    {
                        model_goods_group = bll_good_group.GetModel(groupGoodsId);
                    }
                    model_goods_group.goods_id       = goodsId;
                    model_goods_group.parent_id      = parentId;
                    model_goods_group.title          = goodsTitleArr[i];
                    model_goods_group.color          = goodsColorArr[i];
                    model_goods_group.new_price      = newPrice;
                    model_goods_group.original_price = originalPrice;
                    model_goods_group.main_id        = model.id;
                    if (update)
                    {
                        bll_good_group.Update(model_goods_group);
                        idList.Append(model_goods_group.id + ",");
                    }
                    else
                    {
                        int a = bll_good_group.Add(model_goods_group);
                        idList.Append(a + ",");
                    }
                }
            }

            string id_list = Utils.DelLastChar(idList.ToString(), ",");
            if (string.IsNullOrEmpty(id_list))
            {
                id_list = "0";
            }
            if (!string.IsNullOrEmpty(id_list))
            {
                Tea.DBUtility.DbHelperSQL.ExecuteSql("delete from shop_goods_group where main_id=" + model.id + " and id not in(select id from shop_goods_group where id in(" + id_list + "))");
            }
            #endregion
            if (bll.Update(model))
            {
                AddAdminLog(TWEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "頻道內容:" + model.title); //記錄日誌
                result = true;
            }
            return(result);
        }