예제 #1
0
        //發送折扣券
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevelEdit("sys_settings", "Edit");
            //ChkAdminLevel("user_sms", TWEnums.ActionEnum.Add.ToString()); //檢查權限
            //檢查折扣券內容
            if (amount.Text.Trim() == "")
            {
                JscriptMsg("請輸入金額!", "");
                return;
            }
            if (txtEndTime.Text.Trim() == "")
            {
                JscriptMsg("請輸入到期時間!", "");
                return;
            }
            //開始發送折扣券
            string msg    = string.Empty;
            bool   result = false;

            Tea.Model.quan model  = null;
            bool           update = true;

            if (id > 0)
            {
                model = bll_quan.GetModel(id);
            }
            if (model == null)
            {
                model  = new Model.quan();
                update = false;
            }

            model.quan_title      = txtTitle.Text;
            model.quan_add_date   = System.DateTime.Now;
            model.quan_begin_date = Utils.StrToDateTime(txtBeginTime.Text, System.DateTime.Now);
            model.quan_end_date   = Utils.StrToDateTime(txtEndTime.Text, System.DateTime.Now);
            model.quan_where      = "lin";
            model.quan_num        = Utils.StrToDecimal(amount.Text, 0);
            #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");

            if (goodsGroupIdArr != null && parentIdArr != null && goodsIdArr != null && goodsGroupIdArr.Length > 0 && parentIdArr.Length > 0 && goodsIdArr.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);
                    idList.Append(goodsId + ",");
                }
            }
            model.quan_des = idList.ToString() + "0";

            #endregion

            model.quan_sort = Utils.StrToInt(txtJin.Text, 0);

            if (update)
            {
                bll_quan.Update(model);
            }
            else
            {
                model.quan_code = ljd.function.getUUIDString(12);
                bll_quan.Add(model);
            }
            if (result)
            {
                AddAdminLog(TWEnums.ActionEnum.Add.ToString(), "折扣券"); //記錄日誌
                JscriptMsg("設定優惠券", "lin_list.aspx");
                return;
            }
            else
            {
                JscriptMsg("設定優惠券", "lin_list.aspx");
                return;
            }
        }
예제 #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);
        }