示例#1
0
        /// <summary>
        /// 獲得購物車列表
        /// </summary>
        public static IList <Model.cart_items> GetList(int group_id)
        {
            BLL.goods            bllgoods  = new BLL.goods();
            BLL.article          bll       = new BLL.article();
            BLL.user_group_price bll_group = new BLL.user_group_price();
            Tea.Model.users      _users    = new Tea.Web.UI.UserPage().GetUserInfo();

            IDictionary <string, int> dic = GetCart();

            if (dic != null)
            {
                int hong = 0, lv = 0;

                IList <Model.cart_items> i_List = new List <Model.cart_items>();
                string[] CartKey = new string[2];
                foreach (var item in dic)
                {
                    CartKey = item.Key.Split('_');
                    Model.cart_items modelt = new Model.cart_items();
                    if (CartKey.Length > 1)
                    {
                        Model.article model      = bll.GetModel(Convert.ToInt32(CartKey[0]));
                        Model.goods   modelgoods = bllgoods.GetModel(Convert.ToInt32(CartKey[1]));

                        if (model == null || modelgoods == null)
                        {
                            continue;
                        }
                        if (model.status != 0)
                        {
                            continue;
                        }
                        if (model.add_time > System.DateTime.Now || modelgoods.stock_quantity < 1)
                        {
                            continue;
                        }
                        if (model.xia_date != null && model.xia_date.Value.AddDays(1) < System.DateTime.Now)
                        {
                            continue;
                        }
                        modelt.ps          = model.call_index;
                        modelt.id          = model.id;
                        modelt.key         = item.Key;
                        modelt.title       = model.title;
                        modelt.sub_title   = model.sub_title;
                        modelt.img_url     = model.img_url;
                        modelt.goods_color = modelgoods.color;
                        modelt.goods_size  = modelgoods.size;
                        modelt.zhong       = modelgoods.zhong;
                        modelt.chang       = modelgoods.chang;
                        modelt.kuan        = modelgoods.kuan;
                        modelt.gao         = modelgoods.gao;
                        modelt.point       = model.point;
                        modelt.price       = modelgoods.market_price;
                        modelt.user_price  = modelgoods.sell_price;
                        if (modelgoods.yu_lock > 0)
                        {
                            Tea.Model.sales models = new Tea.BLL.sales().GetModel(modelgoods.yu_lock);
                            if (models != null && models.type == "2" && models.status == 1 && models.start_time < System.DateTime.Now && (models.end_time == null || models.end_time > System.DateTime.Now))
                            {
                                modelt.user_price = modelgoods.yu_num;
                            }
                        }
                        modelt.goodsid        = modelgoods.id;
                        modelt.goods_code     = modelgoods.goods_no;
                        modelt.stock_quantity = modelgoods.stock_quantity;
                        modelt.quantity       = item.Value;
                        modelt.sales_id       = modelgoods.yu_lock;
                        modelt.by             = model.wheresql;
                        modelt.hdcode         = model.guige;
                        if (model.is_msg == 0)
                        {
                            modelt.sales_name = "no";
                        }
                        modelt.psmoney = model.brand_id.ToString();
                        if (group_id > 0)
                        {
                            if (model.brand_id == 1)
                            {
                                if (_users != null && _users.group_id == 2)
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel != null)
                                    {
                                        modelt.user_price = userPriceModel.price;
                                    }
                                }
                            }
                            i_List.Add(modelt);
                        }
                        else
                        {
                            if (model.brand_id == 1 && group_id == -3)
                            {
                                if (_users != null && _users.group_id == 2)
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel != null)
                                    {
                                        modelt.user_price = userPriceModel.price;
                                        modelt.by         = "vip";
                                        i_List.Add(modelt);
                                    }
                                }
                            }

                            if (model.brand_id == 3 && group_id == -2)
                            {
                                i_List.Add(modelt);
                            }
                            if (model.brand_id != 3 && group_id == -1 && model.wheresql != "jiajia")
                            {
                                if (_users.group_id == 1)
                                {
                                    i_List.Add(modelt);
                                }
                                else
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel == null)
                                    {
                                        i_List.Add(modelt);
                                    }
                                }
                            }
                            try
                            {
                                if (model.wheresql == "jiajia" && group_id == -1 && Convert.ToInt32(CartKey[2]) == 1)
                                {
                                    i_List.Add(modelt);
                                }
                                if (model.wheresql == "jiajia" && group_id == -2 && Convert.ToInt32(CartKey[2]) == 2)
                                {
                                    i_List.Add(modelt);
                                }
                                if (model.wheresql == "jiajia" && group_id == -3 && Convert.ToInt32(CartKey[2]) == 3)
                                {
                                    i_List.Add(modelt);
                                }
                            }
                            catch (Exception eee)
                            {
                            }
                        }
                    }
                }
                return(i_List);
            }
            return(null);
        }
示例#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;
            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);
        }
示例#3
0
        //將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);
        }
示例#4
0
        /// <summary>
        /// 獲得購物車列表
        /// </summary>
        public static IList <Model.cart_items> GetList(int group_id, int uid)
        {
            BLL.goods            bllgoods  = new BLL.goods();
            BLL.article          bll       = new BLL.article();
            BLL.user_group_price bll_group = new BLL.user_group_price();
            Tea.Model.users      _users    = new BLL.users().GetModel(uid);

            IDictionary <string, int> dic = GetCart();

            if (dic != null)
            {
                int hong = 0, lv = 0;

                IList <Model.cart_items> i_List = new List <Model.cart_items>();
                string[] CartKey = new string[2];
                foreach (var item in dic)
                {
                    CartKey = item.Key.Split('_');
                    Model.cart_items modelt = new Model.cart_items();
                    if (CartKey.Length > 1)
                    {
                        Model.article model      = bll.GetModel(Convert.ToInt32(CartKey[0]));
                        Model.goods   modelgoods = bllgoods.GetModel(Convert.ToInt32(CartKey[1]));

                        if (model == null || modelgoods == null)
                        {
                            continue;
                        }
                        modelt.ps             = model.call_index;
                        modelt.id             = model.id;
                        modelt.key            = item.Key;
                        modelt.title          = model.title;
                        modelt.sub_title      = model.sub_title;
                        modelt.img_url        = model.img_url;
                        modelt.goods_color    = modelgoods.color;
                        modelt.goods_size     = modelgoods.size;
                        modelt.zhong          = modelgoods.zhong;
                        modelt.chang          = modelgoods.chang;
                        modelt.kuan           = modelgoods.kuan;
                        modelt.gao            = modelgoods.gao;
                        modelt.point          = model.point;
                        modelt.price          = modelgoods.market_price;
                        modelt.user_price     = modelgoods.sell_price;
                        modelt.goodsid        = modelgoods.id;
                        modelt.goods_code     = modelgoods.goods_no;
                        modelt.stock_quantity = modelgoods.stock_quantity;
                        modelt.quantity       = item.Value;
                        modelt.sales_id       = modelgoods.yu_lock;
                        modelt.by             = model.wheresql;
                        modelt.psmoney        = model.brand_id.ToString();
                        if (group_id > 0)
                        {
                            if (model.brand_id == 1)
                            {
                                if (_users != null && _users.group_id == 2)
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel != null)
                                    {
                                        modelt.user_price = userPriceModel.price;
                                    }
                                }
                            }
                            i_List.Add(modelt);
                        }
                        else
                        {
                            if (model.brand_id == 1 && group_id == -3)
                            {
                                if (_users != null && _users.group_id == 2)
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel != null)
                                    {
                                        modelt.user_price = userPriceModel.price;
                                        modelt.by         = "vip";
                                        i_List.Add(modelt);
                                    }
                                }
                            }

                            if (model.brand_id == 3 && group_id == -2)
                            {
                                i_List.Add(modelt);
                            }
                            if (model.brand_id != 3 && group_id == -1)
                            {
                                if (_users.group_id == 1)
                                {
                                    i_List.Add(modelt);
                                }
                                else
                                {
                                    Model.user_group_price userPriceModel = bll_group.GetModel(modelt.goodsid, _users.id);
                                    if (userPriceModel == null)
                                    {
                                        i_List.Add(modelt);
                                    }
                                }
                            }
                        }
                    }
                }
                return(i_List);
            }
            return(null);
        }