Beispiel #1
0
        //批次刪除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevelEdit("sys_goods", "Edit");
            ////ChkAdminLevel("delete_sales", TWEnums.ActionEnum.Delete.ToString()); //檢查權限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.sales bll = new BLL.sales();
            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)
                {
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(TWEnums.ActionEnum.Delete.ToString(), "刪除銷售活動成功" + sucCount + "條,失敗" + errorCount + "條"); //記錄日誌
            JscriptMsg("刪除成功" + sucCount + "條,失敗" + errorCount + "條!", Utils.CombUrlTxt("sales_list.aspx", "keywords={0}", this.keywords));
        }
Beispiel #2
0
        private void ShowInfo(int _id)
        {
            BLL.sales   bll   = new BLL.sales();
            Model.sales model = bll.GetModel(_id);

            txtTitle.Text    = model.title;
            txtSubTitle.Text = model.sub_title;
            txtImgUrl.Text   = model.img_url;

            ddlType.SelectedValue = model.type;


            txtStartTime.Text = model.start_time.ToString("yyyy-M-d");
            if (model.end_time != null)
            {
                txtEndTime.Text = model.end_time.GetValueOrDefault().ToString("yyyy-M-d");
            }
            txtSortId.Text   = model.sort_id.ToString();
            cbStatus.Checked = (model.status == 1);
            txtZhaiyao.Text  = model.summary;
            txtContent.Value = model.content;


            rptGroup.DataSource = Tea.DBUtility.DbHelperSQL.Query("select * from view_goods where yu_lock=" + id + "");
            rptGroup.DataBind();
        }
Beispiel #3
0
        private void RptBind(string _strWhere, string _orderby)
        {
            this.page        = TWRequest.GetQueryInt("page", 1);
            txtKeywords.Text = this.keywords;
            BLL.sales bll = new BLL.sales();
            this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount);
            this.rptList.DataBind();

            //綁定頁碼
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("sales_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__");

            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
Beispiel #4
0
 //儲存排序
 protected void btnSave_Click(object sender, EventArgs e)
 {
     ////ChkAdminLevel("order_sales", TWEnums.ActionEnum.Edit.ToString()); //檢查權限
     BLL.sales bll = new BLL.sales();
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
         int sortId;
         if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId))
         {
             sortId = 99;
         }
         bll.UpdateField(id, "sort_id=" + sortId.ToString());
     }
     AddAdminLog(TWEnums.ActionEnum.Edit.ToString(), "儲存銷售活動排序"); //記錄日誌
     JscriptMsg("儲存排序成功!", Utils.CombUrlTxt("sales_list.aspx", "keywords={0}", this.keywords));
 }
Beispiel #5
0
        private bool DoAdd()
        {
            Model.sales model = new Model.sales();
            BLL.sales   bll   = new BLL.sales();

            string type = ddlType.SelectedValue.Trim();

            model.title     = txtTitle.Text.Trim();
            model.sub_title = txtSubTitle.Text.Trim();
            model.img_url   = txtImgUrl.Text;

            model.type = type;


            model.start_time = Utils.StrToDateTime(txtStartTime.Text.Trim());
            DateTime _end_time;

            if (DateTime.TryParse(txtEndTime.Text.Trim(), out _end_time))
            {
                model.end_time = _end_time;
            }
            if (cbStatus.Checked)
            {
                model.status = 1;
            }
            else
            {
                model.status = 0;
            }
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            //內容摘要提取內容前255個字元
            if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim()))
            {
                model.summary = Utils.DropHTML(txtContent.Value, 255);
            }
            else
            {
                model.summary = Utils.DropHTML(txtZhaiyao.Text, 255);
            }
            model.content = txtContent.Value;


            int a = bll.Add(model);


            #region 促銷組合==============
            string[] parentid = Request.Form.GetValues("goods_id");
            string[] newprice = Request.Form.GetValues("new_price");
            if (parentid != null && parentid.Length > 0 && newprice != null && newprice.Length > 0)
            {
                for (int i = 0; i < parentid.Length; i++)
                {
                    new Tea.BLL.goods().UpdateField(int.Parse(parentid[i].ToString()), "yu_lock=" + a + ",yu_num=" + newprice[i].ToString() + "");
                }
            }
            #endregion


            if (a > 0)
            {
                AddAdminLog(TWEnums.ActionEnum.Add.ToString(), "添加銷售活動:" + model.title); //記錄日誌
                return(true);
            }
            return(false);
        }
Beispiel #6
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.sales   bll   = new BLL.sales();
            Model.sales model = bll.GetModel(_id);

            string type = ddlType.SelectedValue.Trim();

            model.title     = txtTitle.Text.Trim();
            model.sub_title = txtSubTitle.Text.Trim();
            model.img_url   = txtImgUrl.Text;

            model.type = type;

            model.start_time = Utils.StrToDateTime(txtStartTime.Text.Trim());
            DateTime _end_time;

            if (DateTime.TryParse(txtEndTime.Text.Trim(), out _end_time))
            {
                model.end_time = _end_time;
            }
            if (cbStatus.Checked)
            {
                model.status = 1;
            }
            else
            {
                model.status = 0;
            }
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            //內容摘要提取內容前255個字元
            if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim()))
            {
                model.summary = Utils.DropHTML(txtContent.Value, 255);
            }
            else
            {
                model.summary = Utils.DropHTML(txtZhaiyao.Text, 255);
            }
            model.content = txtContent.Value;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            foreach (ListItem li in cblItem.Items)
            {
                if (li.Selected)
                {
                    sb.AppendFormat("{0},", li.Value);
                }
            }


            #region 促銷組合==============
            StringBuilder idListA  = new StringBuilder();
            string[]      parentid = Request.Form.GetValues("goods_id");
            string[]      newprice = Request.Form.GetValues("new_price");
            if (parentid != null && parentid.Length > 0 && newprice != null && newprice.Length > 0)
            {
                for (int i = 0; i < parentid.Length; i++)
                {
                    new Tea.BLL.goods().UpdateField(int.Parse(parentid[i].ToString()), "yu_lock=" + id + ",yu_num=" + newprice[i].ToString() + "");
                    idListA.Append(parentid[i].ToString() + ",");
                }
            }
            string id_listA = Utils.DelLastChar(idListA.ToString(), ",");
            if (!string.IsNullOrEmpty(id_listA))
            {
                Tea.DBUtility.DbHelperSQL.ExecuteSql("update shop_goods set yu_lock=0,yu_num=0  where  yu_lock=" + model.id + " and id not in(select id from shop_goods where id in(" + id_listA + "))");
            }
            else
            {
                Tea.DBUtility.DbHelperSQL.ExecuteSql("update shop_goods set yu_lock=0,yu_num=0 where yu_lock=" + model.id + "");
            }
            #endregion


            if (bll.Update(model))
            {
                AddAdminLog(TWEnums.ActionEnum.Edit.ToString(), "修改銷售活動:" + model.title); //記錄日誌
                result = true;
            }

            return(result);
        }
Beispiel #7
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.sales   bll   = new BLL.sales();
            Model.sales model = bll.GetModel(_id);

            string type = ddlType.SelectedValue.Trim();

            model.title     = txtTitle.Text.Trim();
            model.sub_title = txtSubTitle.Text.Trim();
            model.img_url   = txtImgUrl.Text;
            model.company   = Utils.StrToInt(company.SelectedValue, 1);
            model.type      = type;

            model.start_time = Utils.StrToDateTime(txtStartTime.Text.Trim());
            DateTime _end_time;

            if (DateTime.TryParse(txtEndTime.Text.Trim(), out _end_time))
            {
                model.end_time = _end_time;
            }
            if (cbStatus.Checked)
            {
                model.status = 1;
            }
            else
            {
                model.status = 0;
            }
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            //內容摘要提取內容前255個字元
            if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim()))
            {
                model.summary = Utils.DropHTML(txtContent.Value, 255);
            }
            else
            {
                model.summary = Utils.DropHTML(txtZhaiyao.Text, 255);
            }
            model.content = txtContent.Value;



            #region 促銷組合==============
            StringBuilder idListA  = new StringBuilder();
            string[]      parentid = Request.Form.GetValues("goods_id");
            if (parentid != null && parentid.Length > 0)
            {
                for (int i = 0; i < parentid.Length; i++)
                {
                    new Tea.BLL.goods().UpdateField(int.Parse(parentid[i].ToString()), "yu_lock=" + id + "");
                    idListA.Append(parentid[i].ToString() + ",");
                }
            }
            string id_listA = Utils.DelLastChar(idListA.ToString(), ",");
            if (!string.IsNullOrEmpty(id_listA))
            {
                Tea.DBUtility.DbHelperSQL.ExecuteSql("update shop_goods set yu_lock=0  where  yu_lock=" + model.id + " and id not in(select id from shop_goods where id in(" + id_listA + "))");
            }
            else
            {
                Tea.DBUtility.DbHelperSQL.ExecuteSql("update shop_goods set yu_lock=0 where yu_lock=" + model.id + "");
            }
            #endregion


            #region 減折==============
            StringBuilder idList1   = new StringBuilder();
            string[]      item1id   = Request.Form.GetValues("item1_id");
            string[]      zhe1moeny = Request.Form.GetValues("zhe1_moeny");
            string[]      zhe1num   = Request.Form.GetValues("zhe1_num");
            if (zhe1moeny != null && zhe1moeny.Length > 0 && zhe1num != null && zhe1num.Length > 0)
            {
                for (int i = 0; i < zhe1moeny.Length; i++)
                {
                    try
                    {
                        Model.goods_sales model_list = null;
                        int  id     = int.Parse(item1id[i].ToString());
                        bool update = true;
                        if (id == 0)
                        {
                            model_list = new Model.goods_sales();
                            update     = false;
                        }
                        else
                        {
                            model_list = bll_list.GetModel(id);
                        }
                        model_list.main_id   = model.id;
                        model_list.parent_id = int.Parse(zhe1moeny[i].ToString());
                        model_list.goods_id  = int.Parse(zhe1num[i].ToString());

                        if (update)
                        {
                            bll_list.Update(model_list);
                            idList1.Append(model_list.id + ",");
                        }
                        else
                        {
                            int a = bll_list.Add(model_list);
                            idList1.Append(a + ",");
                        }
                    }
                    catch (Exception eee) { }
                }
            }
            string id_list1 = Utils.DelLastChar(idList1.ToString(), ",");
            if (!string.IsNullOrEmpty(id_list1))
            {
                Tea.DBUtility.DbHelperSQL.ExecuteSql("delete from shop_goods_sales where main_id=" + model.id + " and id not in(select id from shop_goods_sales where id in(" + id_list1 + "))");
            }
            else
            {
                Tea.DBUtility.DbHelperSQL.ExecuteSql("delete from shop_goods_sales where main_id=" + model.id + "");
            }
            #endregion


            if (bll.Update(model))
            {
                AddAdminLog(TWEnums.ActionEnum.Edit.ToString(), "修改銷售活動:" + model.title); //記錄日誌
                result = true;
            }

            return(result);
        }