Ejemplo n.º 1
0
        /// <summary>
        /// 發送手機簡訊
        /// </summary>
        /// <param name="mobiles">手機號碼,以英文“,”逗號分隔開</param>
        /// <param name="content">簡訊內容</param>
        /// <param name="pass">簡訊通道1驗證碼通道2廣告通道</param>
        /// <param name="msg">返回提示訊息</param>
        /// <returns>bool</returns>
        public bool Send(string mobiles, DateTime date, int num, string where, string title, out string msg)
        {
            //檢查手機號碼,如果超過2000則分批發送
            int    sucCount = 0;            //成功送出數量
            string errorMsg = string.Empty; //錯誤消息

            string[] oldMobileArr = mobiles.Split(',');
            int      batch        = oldMobileArr.Length; //2000條為一批,求出分多少批

            for (int i = 0; i < batch; i++)
            {
                StringBuilder sb        = new StringBuilder();
                int           sendCount = 0; //發送數量


                string mobile = oldMobileArr[i].Trim();

                sendCount++;
                try
                {
                    Model.quan model = new Model.quan();
                    model.quan_username = mobile;
                    model.quan_user     = 1;
                    model.quan_code     = ljd.function.RndNumRNG(10);
                    model.quan_end_date = date;
                    model.quan_add_date = System.DateTime.Now;
                    model.quan_lock     = 0;
                    model.quan_num      = num;
                    model.quan_where    = where;
                    model.quan_name     = title;
                    Add(model);
                    sucCount += sendCount; //成功數量
                }
                catch
                {
                    //沒有動作
                }
            }

            //返回狀態
            if (sucCount > 0)
            {
                msg = "成功送出" + sucCount + "條,失敗" + (oldMobileArr.Length - sucCount) + "條";
                return(true);
            }
            msg = errorMsg;
            return(false);
        }
Ejemplo n.º 2
0
        //將excel的資料寫入資料庫
        private string InsertGoods(DataTable dt)
        {
            string result = "";

            BLL.quan   bll   = new BLL.quan();
            Model.quan model = null;

            //判斷列名是否規範
            string[] strColumn = { "名稱", "券號", "金額", "數量", "開始時間", "結束時間", "適用商品" };
            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)
            {
                //遍歷主件

                foreach (DataRow dr in dt.Rows)
                {
                    if (dr[0].ToString().Trim() != "" && dr[1].ToString().Trim() != "" && dr[2].ToString().Trim() != "" && dr[3].ToString().Trim() != "")
                    {
                        bool updatea = true;
                        try
                        {
                            model = bll.GetModel(dr[1].ToString());
                        }
                        catch (Exception eee) { }
                        if (model == null)
                        {
                            model   = new Model.quan();
                            updatea = false;
                        }

                        model.quan_code       = dr[1].ToString();
                        model.quan_title      = dr[0].ToString();
                        model.quan_name       = dr[0].ToString();
                        model.quan_num        = Utils.StrToDecimal(dr[2].ToString(), 0);
                        model.quan_sort       = Utils.StrToInt(dr[3].ToString(), 0);
                        model.quan_add_date   = System.DateTime.Now;
                        model.quan_begin_date = Utils.StrToDateTime(dr[4].ToString());
                        model.quan_end_date   = Utils.StrToDateTime(dr[5].ToString());
                        model.quan_des        = getcode(dr[6].ToString());
                        model.quan_where      = "lin";
                        int pid = 0;
                        if (updatea)
                        {
                            bll.Update(model);
                        }
                        else
                        {
                            pid = bll.Add(model);
                        }
                    }
                }
            }
            else
            {
                result = "請檢查excel檔案格式!" + num + strColumn.Length;
            }
            return(result);
        }
Ejemplo n.º 3
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;
            }
        }