Exemplo n.º 1
0
        public List<PromotionBannerQuery> GetPromotionBannerList(PromotionBannerQuery query, out int totalCount)
        {
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.AppendFormat(@" ");
                if (query.brand_name != string.Empty)
                {
                    VendorBrandQuery vb_query = new VendorBrandQuery();
                    vb_query.Brand_Name = query.brand_name;
                    string sql_getID = _vendorBrandDao.GetBrand_idByBrand_name(vb_query);
                    DataTable dt = _accessMySql.getDataTable(sql_getID);
                    string id = string.Empty;
                    if (dt.Rows.Count > 0 && dt != null)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            id += dt.Rows[i][0].ToString() + ",";

                        }
                        id = id.Substring(0, id.LastIndexOf(','));
                        strSql.AppendFormat(" AND pbr.brand_id in({0})", id);
                    }
                    else
                    {
                        strSql.AppendFormat(" AND pbr.brand_id in({0})", -1);
                    }
                }
                return _promotionBannerDao.GetPromotionBannerList(query, strSql.ToString(), out totalCount);
            }
            catch (Exception ex)
            {
                throw new Exception("PromotionBannerMgr-->GetPromotionBannerList-->" + ex.Message, ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 品牌營業額統計匯出
        /// </summary>
        /// <returns></returns>
        public void GetNewOrderRevenueExprot()
        {
            string json = string.Empty;
            try
            {
                OrderDetailQuery query = new OrderDetailQuery();

                #region 前置查詢條件
                if (!string.IsNullOrEmpty(Request.Params["Brand_Id"]))/*品牌編號*/
                {
                    query.Brand_Id_In = Request.Params["Brand_Id"];

                }
                if (!string.IsNullOrEmpty(Request.Params["product_manage"]) && Request.Params["product_manage"] != "null")//管理人員 
                {//獲取管理人
                    query.product_manage = int.Parse(Request.Params["product_manage"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["dateOne"]))
                {
                    query.time_start = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateOne"]).ToString("yyyy/MM/dd 00:00:00"));
                }
                if (!string.IsNullOrEmpty(Request.Params["dateTwo"]))
                {
                    query.time_end = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateTwo"]).ToString("yyyy/MM/dd 23:59:59"));
                }
                long start = query.time_start;//開始時間
                long end = query.time_end;//結束時間
                if (!string.IsNullOrEmpty(Request.Params["Channel_Id"]) && Request.Params["Channel_Id"] != "null")//賣場
                {
                    query.channel = int.Parse(Request.Params["Channel_Id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["slave_status"]) && Request.Params["slave_status"]!="null")//訂單狀態
                {
                    query.Status = int.Parse(Request.Params["slave_status"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["order_payment"]) && Request.Params["order_payment"] != "null")//付款方式
                {
                    query.order_payment = int.Parse(Request.Params["order_payment"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["selecttype"]))//關鍵字查詢類型
                {
                    query.select_type = int.Parse(Request.Params["selecttype"]);
                    if (!string.IsNullOrEmpty(Request.Params["searchcon"]))//關鍵字查詢內容
                    {
                        query.select_con = Request.Params["searchcon"];
                    }
                }


                #endregion
                VendorBrandQuery Vendorbrandquery = new VendorBrandQuery();
                Dictionary<uint, VendorBrandQuery> brands = new Dictionary<uint, VendorBrandQuery>();///字典----儲存供應商編號,供應商名稱和錧別,錧別編號的信息
                Dictionary<uint, Dictionary<string, Dictionary<string, uint>>> brandDailyTotal = new Dictionary<uint, Dictionary<string, Dictionary<string, uint>>>();///字典,儲存錧別,每天的計算和每天的購物金
                ///////////////brand_id//////////daysum,dayduct/////日期///值
                List<VendorBrandQuery> aDB_Brand_Select = new List<VendorBrandQuery>();
                _vbrand = new VendorBrandMgr(mySqlConnectionString);
                aDB_Brand_Select = _vbrand.GetBandList(Vendorbrandquery);//把錧別和供應商信息保存到字典里
                for (int i = 0; i < aDB_Brand_Select.Count; i++)
                {
                    if (!brands.Keys.Contains(aDB_Brand_Select[i].Brand_Id))
                    {
                        brands.Add(aDB_Brand_Select[i].Brand_Id, aDB_Brand_Select[i]);
                    }
                }

                bool CrossMonth = CommonFunction.GetNetTime(start).Month == CommonFunction.GetNetTime(end).Month ? false : true;
                string timelong = "";
                while (start <= end)//時間格式化,用來保存每天的小計
                {
                    timelong += CommonFunction.GetNetTime(start).ToString("yyyy/MM/dd") + ",";
                    start += 86400;
                }
                timelong = timelong.Substring(0, timelong.LastIndexOf(","));
                string[] times = timelong.Split(',');
                Dictionary<string, uint> timetro = new Dictionary<string, uint>();
                for (int i = 0; i < times.Count(); i++)//字典加上日期時間
                {
                    timetro.Add(times[i], 0);
                }
                Dictionary<string, Dictionary<string, uint>> daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();//保存每個商品每日的小計和購物金
                daysum_deduct.Add("daysum", timetro);//每日小計
                daysum_deduct.Add("daydeduct", timetro);//每日小計


                _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                List<OrderDetailQuery> ordertailList = new List<OrderDetailQuery>();
                DataTable _dt = new DataTable();
                ordertailList = _orderDetailMgr.GetOrderDetailList(query);//通過查詢條件獲取的數據
                string[] quanxuan = query.Brand_Id_In.Split(',');
                foreach (uint item in brands.Keys)
                {
                    if (!brandDailyTotal.Keys.Contains(item))
                    {
                        daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();
                        timetro = new Dictionary<string, uint>();
                        for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                        {
                            timetro.Add(times[a], 0);
                        }
                        daysum_deduct.Add("daysum", timetro);//每日小計
                        timetro = new Dictionary<string, uint>();

                        for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                        {
                            timetro.Add(times[a], 0);
                        }
                        daysum_deduct.Add("daydeduct", timetro);//購物金
                        brandDailyTotal.Add(item, daysum_deduct);
                    }
                }
                
                //if (ordertailList.Count > 0)
                //{
                    for (int i = 0; i < ordertailList.Count; i++)
                    {
                        ordertailList[i].subtotal = ordertailList[i].Single_Money * ordertailList[i].Buy_Num;
                        ordertailList[i].cost = (ordertailList[i].Event_Cost != 0 && ordertailList[i].Single_Cost != ordertailList[i].Single_Money) ? ordertailList[i].Event_Cost : ordertailList[i].Single_Cost;
                        if (!brands.Keys.Contains(ordertailList[i].Brand_Id))
                        {
                            VendorBrandQuery brand = new VendorBrandQuery();
                            brand.Vendor_Id = ordertailList[i].Vendor_Id;
                            brand.Brand_Name = ordertailList[i].Brand_Name;
                            brand.Brand_Id = ordertailList[i].Brand_Id;
                            brand.vendor_name_simple = ordertailList[i].Vendor_Name_Simple;
                            brands.Add(ordertailList[i].Brand_Id, brand);
                        }
                        if (!brandDailyTotal.Keys.Contains(ordertailList[i].Brand_Id))
                        {
                            daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();
                            timetro = new Dictionary<string, uint>();
                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daysum", timetro);//每日小計
                            timetro = new Dictionary<string, uint>();

                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daydeduct", timetro);//購物金

                            brandDailyTotal.Add(ordertailList[i].Brand_Id, daysum_deduct);
                        }
                        string time = CommonFunction.GetNetTime(ordertailList[i].Order_Createdate).ToString("yyyy/MM/dd");
                        brandDailyTotal[ordertailList[i].Brand_Id]["daysum"][time] += ordertailList[i].subtotal;//每個商品的小計
                        brandDailyTotal[ordertailList[i].Brand_Id]["daydeduct"][time] += ordertailList[i].Deduct_Bonus;//每個商品的購物金小計
                    }
                    Dictionary<string, uint> daysum_allbrand = new Dictionary<string, uint>();//所有品牌的每日小計
                    Dictionary<string, uint> deductsum_allbrand = new Dictionary<string, uint>();//所有品牌的每日購物金
                    foreach (uint key in brandDailyTotal.Keys)
                    {
                        foreach (string time in brandDailyTotal[key]["daysum"].Keys)//循環每個品牌的每日小計,計算到所有品牌的每日小計
                        {
                            if (!daysum_allbrand.Keys.Contains(time))
                            {
                                daysum_allbrand.Add(time, brandDailyTotal[key]["daysum"][time]);
                            }
                            else
                            {
                                daysum_allbrand[time] += brandDailyTotal[key]["daysum"][time];
                            }
                        }
                        foreach (string time in brandDailyTotal[key]["daydeduct"].Keys)//循環每個品牌的每日購物金小計,計算到所有品牌的每日小計
                        {
                            if (!deductsum_allbrand.Keys.Contains(time))
                            {
                                deductsum_allbrand.Add(time, brandDailyTotal[key]["daydeduct"][time]);
                            }
                            else
                            {
                                deductsum_allbrand[time] += brandDailyTotal[key]["daydeduct"][time];
                            }
                        }

                    }

                    //
                    _dt.Columns.Add("品牌名稱", typeof(String));
                    _dt.Columns.Add("供應商名稱", typeof(String));


                    string ym_last = "";
                    foreach (string it in timetro.Keys)
                    {
                        string ym = it.Substring(0, 7);
                        if (string.IsNullOrEmpty(ym_last))
                            ym_last = ym;
                        if (!ym_last.Equals(ym))
                        {
                            _dt.Columns.Add(ym_last.Split('/')[1] + "月小計", typeof(String));
                            _dt.Columns.Add("購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String));
                            _dt.Columns.Add("扣除購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String));
                            ym_last = ym;
                        }
                        _dt.Columns.Add(it, typeof(String));
                        _dt.Columns.Add("購物金(" + it + ")", typeof(String));
                        _dt.Columns.Add("扣除購物金(" + it + ")", typeof(String));
                    }
                    if (CrossMonth)
                    {
                        _dt.Columns.Add(ym_last.Split('/')[1] + "月小計", typeof(String));
                        _dt.Columns.Add("購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String));
                        _dt.Columns.Add("扣除購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String));
                    }
                    _dt.Columns.Add("品牌總計", typeof(String));
                    _dt.Columns.Add(" 購物金總計", typeof(String));
                    _dt.Columns.Add(" 扣除購物金總計", typeof(String));

                    DataRow addrow = _dt.NewRow();//添加一行
                    addrow[0] = " ";
                    addrow[1] = "每日小計";
                    int r = 2;
                    ym_last = "";
                    uint sum_monthly = 0;//每月小計
                    uint deduct_monthly = 0;//每月購物金小計
                    uint sum_year = 0;//總計
                    uint deduct_year = 0;//購物金總計
                    foreach (string it in daysum_allbrand.Keys)
                    {
                        string ym = it.Substring(0, 7);
                        if (string.IsNullOrEmpty(ym_last))
                            ym_last = ym;
                        if (!ym_last.Equals(ym))
                        {
                            addrow[r] = sum_monthly;
                            r++;
                            addrow[r] = deduct_monthly;
                            r++;
                            addrow[r] = sum_monthly - deduct_monthly;
                            r++;
                            ym_last = ym;
                            sum_monthly = 0;
                            deduct_monthly = 0;
                        }
                        sum_monthly += daysum_allbrand[it];
                        deduct_monthly += deductsum_allbrand[it];
                        sum_year += daysum_allbrand[it];
                        deduct_year += deductsum_allbrand[it];
                        addrow[r] = daysum_allbrand[it];
                        r++;
                        addrow[r] = deductsum_allbrand[it];
                        r++;
                        addrow[r] = daysum_allbrand[it] - deductsum_allbrand[it];
                        r++;

                    }
                    if (CrossMonth)
                    {
                        addrow[r] = sum_monthly;
                        r++;
                        addrow[r] = deduct_monthly;
                        r++;
                        addrow[r] = sum_monthly - deduct_monthly;
                        r++;
                    }
                    addrow[r] = sum_year;
                    r++;
                    addrow[r] = deduct_year;
                    r++;
                    addrow[r] = sum_year - deduct_year;
                    _dt.Rows.Add(addrow);

                    foreach (uint it in brandDailyTotal.Keys)
                    {
                        ym_last = "";
                        sum_monthly = 0;
                        deduct_monthly = 0;
                        sum_year = 0;
                        deduct_year = 0;
                        r = 0;
                        addrow = _dt.NewRow();
                        if (brands.Keys.Contains(it))
                        {
                            addrow[r] = brands[it].Brand_Name;
                            r++;
                            addrow[r] = brands[it].vendor_name_simple;
                            r++;
                        }
                        else
                        {
                            addrow[r] = " ";
                            r++;
                            addrow[r] = " ";
                            r++;
                        }
                        foreach (string ite in brandDailyTotal[it]["daysum"].Keys)
                        {
                            string ym = ite.Substring(0, 7);
                            if (string.IsNullOrEmpty(ym_last))
                                ym_last = ym;
                            if (!ym_last.Equals(ym))
                            {
                                addrow[r] = sum_monthly;
                                r++;
                                addrow[r] = deduct_monthly;
                                r++;
                                addrow[r] = sum_monthly - deduct_monthly;
                                r++;
                                ym_last = ym;
                                sum_monthly = 0;
                                deduct_monthly = 0;
                            }
                            sum_monthly += brandDailyTotal[it]["daysum"][ite];
                            sum_year += brandDailyTotal[it]["daysum"][ite];
                            deduct_monthly += brandDailyTotal[it]["daydeduct"][ite];
                            deduct_year += brandDailyTotal[it]["daydeduct"][ite];
                            addrow[r] = brandDailyTotal[it]["daysum"][ite];
                            r++;
                            addrow[r] = brandDailyTotal[it]["daydeduct"][ite];
                            r++;
                            addrow[r] = brandDailyTotal[it]["daysum"][ite] - brandDailyTotal[it]["daydeduct"][ite];
                            r++;
                        }
                        if (CrossMonth)
                        {
                            addrow[r] = sum_monthly;
                            r++;
                            addrow[r] = deduct_monthly;
                            r++;
                            addrow[r] = sum_monthly - deduct_monthly;
                            r++;
                        }
                        addrow[r] = sum_year;
                        r++;
                        addrow[r] = deduct_year;
                        r++;
                        addrow[r] = sum_year - deduct_year;
                        _dt.Rows.Add(addrow);
                    }
               // }

                //if (_dt.Rows.Count > 0)
                //{
                    //string fileName = "品牌營業額匯出_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                    //MemoryStream ms = ExcelHelperXhf.ExportDT(_dt, "");
                    //Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                    //Response.BinaryWrite(ms.ToArray());
                    string fileName = "品牌營業額匯出_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";
                    //MemoryStream ms = ExcelHelperXhf.ExportDT(_dt, "");
                    //Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                    //Response.BinaryWrite(ms.ToArray());
                    StringWriter sw = ExcelHelperXhf.SetCsvFromData(_dt, fileName);
                    Response.Clear();
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                    Response.ContentType = "application/ms-excel";
                    Response.ContentEncoding = Encoding.Default;
                    Response.Write(sw);
                    Response.End();
                //}
                //else
                //{
                //    Response.Write("匯出數據不存在");
                //}

            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);

            }



        }
Exemplo n.º 3
0
        public HttpResponseBase GetNewOrderRevenueList()
        {
            string json = string.Empty;
            try
            {
                OrderDetailQuery query = new OrderDetailQuery();
                #region 前置查詢條件
                if (!string.IsNullOrEmpty(Request.Params["Brand_Id"]))/*品牌編號*/
                {
                    query.Brand_Id_In = Request.Params["Brand_Id"];
                }
                if (!string.IsNullOrEmpty(Request.Params["product_manage"]))//管理人員 
                {//獲取管理人
                    query.product_manage = int.Parse(Request.Params["product_manage"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["dateOne"]))
                {
                    query.time_start = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateOne"]).ToString("yyyy/MM/dd 00:00:00"));
                }
                if (!string.IsNullOrEmpty(Request.Params["dateTwo"]))
                {
                    query.time_end = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateTwo"]).ToString("yyyy/MM/dd 23:59:59"));
                }
                long start = query.time_start;//開始時間
                long end = query.time_end;//結束時間
                if (!string.IsNullOrEmpty(Request.Params["Channel_Id"]))//賣場
                {
                    query.channel = int.Parse(Request.Params["Channel_Id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["slave_status"]))//訂單狀態
                {
                    query.Status = int.Parse(Request.Params["slave_status"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["order_payment"]))//付款方式
                {
                    query.order_payment = int.Parse(Request.Params["order_payment"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["selecttype"]))//關鍵字查詢類型
                {
                    query.select_type = int.Parse(Request.Params["selecttype"]);
                    if (!string.IsNullOrEmpty(Request.Params["searchcon"]))//關鍵字查詢內容
                    {
                        query.select_con = Request.Params["searchcon"];
                    }
                }


                #endregion
                VendorBrandQuery Vendorbrandquery = new VendorBrandQuery();
                Dictionary<uint, VendorBrandQuery> brands = new Dictionary<uint, VendorBrandQuery>();///字典----儲存供應商編號,供應商名稱和錧別,錧別編號的信息
                Dictionary<uint, Dictionary<string, Dictionary<string, uint>>> brandDailyTotal = new Dictionary<uint, Dictionary<string, Dictionary<string, uint>>>();///字典,儲存錧別,每天的計算和每天的購物金
                ///////////////brand_id//////////daysum,dayduct/////日期///值
                List<VendorBrandQuery> aDB_Brand_Select = new List<VendorBrandQuery>();
                _vbrand = new VendorBrandMgr(mySqlConnectionString);
                aDB_Brand_Select = _vbrand.GetBandList(Vendorbrandquery);//把錧別和供應商信息保存到字典里
                for (int i = 0; i < aDB_Brand_Select.Count; i++)
                {
                    if (!brands.Keys.Contains(aDB_Brand_Select[i].Brand_Id))
                    {
                        brands.Add(aDB_Brand_Select[i].Brand_Id, aDB_Brand_Select[i]);
                    }
                }

                bool CrossMonth = CommonFunction.GetNetTime(start).Month == CommonFunction.GetNetTime(end).Month ? false : true;
                string timelong = "";
                while (start <= end)//時間格式化,用來保存每天的小計
                {
                    timelong += CommonFunction.GetNetTime(start).ToString("yyyy/MM/dd") + ",";
                    start += 86400;
                }
                timelong = timelong.Substring(0, timelong.LastIndexOf(","));
                string[] times = timelong.Split(',');
                Dictionary<string, uint> timetro = new Dictionary<string, uint>();
                for (int i = 0; i < times.Count(); i++)//字典加上日期時間
                {
                    timetro.Add(times[i], 0);
                }
                Dictionary<string, Dictionary<string, uint>> daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();//保存每個商品每日的小計和購物金
                daysum_deduct.Add("daysum", timetro);//每日小計
                daysum_deduct.Add("daydeduct", timetro);//每日小計


                _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                List<OrderDetailQuery> ordertailList = new List<OrderDetailQuery>();
                ordertailList = _orderDetailMgr.GetOrderDetailList(query);//通過查詢條件獲取的數據
                //if (ordertailList.Count == 0)
                //{
                //    json = "{success:true,msg:\"" + "<div style='overflow:auto;text-align:center;width:1650px;height:550px;><p tyle='text-align:center'>~~暫無數據~~</p></div>" + "\"}";
                //}
                //else
                //{
                 string[] quanxuan = query.Brand_Id_In.Split(',');
                    foreach (uint item in brands.Keys)
                    {
                        if (!brandDailyTotal.Keys.Contains(item))
                        {
                            daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();
                            timetro = new Dictionary<string, uint>();
                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daysum", timetro);//每日小計
                            timetro = new Dictionary<string, uint>();

                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daydeduct", timetro);//購物金
                            brandDailyTotal.Add(item, daysum_deduct);
                        }
                    }
                    for (int i = 0; i < ordertailList.Count; i++)
                    {
                        ordertailList[i].subtotal = ordertailList[i].Single_Money * ordertailList[i].Buy_Num;
                        ordertailList[i].cost = (ordertailList[i].Event_Cost != 0 && ordertailList[i].Single_Cost != ordertailList[i].Single_Money) ? ordertailList[i].Event_Cost : ordertailList[i].Single_Cost;
                        if (!brands.Keys.Contains(ordertailList[i].Brand_Id))
                        {
                            VendorBrandQuery brand = new VendorBrandQuery();
                            brand.Vendor_Id = ordertailList[i].Vendor_Id;
                            brand.Brand_Name = ordertailList[i].Brand_Name;
                            brand.Brand_Id = ordertailList[i].Brand_Id;
                            brand.vendor_name_simple = ordertailList[i].Vendor_Name_Simple;
                            brands.Add(ordertailList[i].Brand_Id, brand);
                        }
                        if (!brandDailyTotal.Keys.Contains(ordertailList[i].Brand_Id))
                        {
                            daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();
                            timetro = new Dictionary<string, uint>();
                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daysum", timetro);//每日小計
                            timetro = new Dictionary<string, uint>();

                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daydeduct", timetro);//購物金

                            brandDailyTotal.Add(ordertailList[i].Brand_Id, daysum_deduct);
                        }
                        string time = CommonFunction.GetNetTime(ordertailList[i].Order_Createdate).ToString("yyyy/MM/dd");
                        brandDailyTotal[ordertailList[i].Brand_Id]["daysum"][time] += ordertailList[i].subtotal;//每個商品的小計
                        brandDailyTotal[ordertailList[i].Brand_Id]["daydeduct"][time] += ordertailList[i].Deduct_Bonus;//每個商品的購物金小計
                    }
                    Dictionary<string, uint> daysum_allbrand = new Dictionary<string, uint>();//所有品牌的每日小計
                    Dictionary<string, uint> deductsum_allbrand = new Dictionary<string, uint>();//所有品牌的每日購物金
                    foreach (uint key in brandDailyTotal.Keys)
                    {
                        foreach (string time in brandDailyTotal[key]["daysum"].Keys)//循環每個品牌的每日小計,計算到所有品牌的每日小計
                        {
                            if (!daysum_allbrand.Keys.Contains(time))
                            {
                                daysum_allbrand.Add(time, brandDailyTotal[key]["daysum"][time]);
                            }
                            else
                            {
                                daysum_allbrand[time] += brandDailyTotal[key]["daysum"][time];
                            }
                        }
                        foreach (string time in brandDailyTotal[key]["daydeduct"].Keys)//循環每個品牌的每日購物金小計,計算到所有品牌的每日小計
                        {
                            if (!deductsum_allbrand.Keys.Contains(time))
                            {
                                deductsum_allbrand.Add(time, brandDailyTotal[key]["daydeduct"][time]);
                            }
                            else
                            {
                                deductsum_allbrand[time] += brandDailyTotal[key]["daydeduct"][time];
                            }
                        }

                    }
                    StringBuilder html_table = new StringBuilder();//匯出html頁面
                    html_table.AppendFormat(@"<div style='overflow:auto;text-align:right;width:1590px;height:580px;'><table style='border:0px;'>");

                    html_table.AppendFormat("<thead style='text-align:center;border-bottom: 1px solid #ccc;color: #000;'><tr><td style='border-bottom: 1px solid #ccc;color: #000;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center; text-align: center;'>&nbsp;&nbsp;品牌名稱&nbsp;&nbsp;</td>");
                    html_table.AppendFormat("<td style='border-bottom: 1px solid #ccc;color: #000;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center; text-align: center;'>&nbsp;&nbsp;供應商名稱&nbsp;&nbsp;</td>");
                    string ym_last = "";
                    foreach (string it in timetro.Keys)
                    {
                        string ym = it.Substring(0, 7);
                        if (string.IsNullOrEmpty(ym_last))
                            ym_last = ym;
                        if (!ym_last.Equals(ym))
                        {
                            html_table.AppendFormat("<td style= 'color: #c00;border-bottom: 1px solid #ccc;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", ym_last.Split('/')[1] + "月小計");
                            ym_last = ym;
                        }
                        html_table.AppendFormat("<td style='color: #000;border-bottom: 1px solid #ccc; text-align: center;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", it);
                    }
                    if (CrossMonth)
                    {
                        html_table.AppendFormat("<td style= 'color: #c00;border-bottom: 1px solid #ccc;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", ym_last.Split('/')[1] + "月小計");
                    }
                    html_table.AppendFormat("<td style= 'color: #c00;border-bottom: 1px solid #ccc;line-height: 1.2em;white-space: nowrap;font-size: 12px;  text-align: center;'>&nbsp;&nbsp;品牌總計&nbsp;&nbsp;</td></tr>");






                    html_table.AppendFormat("<tr><td colspan='2' style= 'text-align: right;border-bottom: 1px solid #ccc;color: #000;'>&nbsp;&nbsp;每日小計&nbsp;&nbsp;</td>");
                    ym_last = "";
                    uint sum_monthly = 0;
                    uint sum_year = 0;
                    foreach (string it in daysum_allbrand.Keys)
                    {
                        string ym = it.Substring(0, 7);
                        if (string.IsNullOrEmpty(ym_last))
                            ym_last = ym;
                        if (!ym_last.Equals(ym))
                        {
                            html_table.AppendFormat("<td style= 'border-bottom: 1px solid #ccc; text-align: right;color: #c00; '>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", sum_monthly);
                            ym_last = ym;
                            sum_monthly = 0;
                        }
                        sum_monthly += daysum_allbrand[it];
                        sum_year += daysum_allbrand[it];
                        html_table.AppendFormat("<td style='text-align:right;border-bottom: 1px solid #ccc; '>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", daysum_allbrand[it]);

                    }
                    if (CrossMonth)
                    {
                        html_table.AppendFormat("<td style= 'text-align:right;color: #c00;border-bottom: 1px solid #ccc; '>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", sum_monthly);
                    }
                    html_table.AppendFormat("<td style= 'text-align:right;color: #c00;border-bottom: 1px solid #ccc; '>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td></tr></thead>", sum_year);
                    html_table.AppendFormat("<tbody>");

                    foreach (uint it in brandDailyTotal.Keys)
                    {

                        ym_last = "";
                        sum_monthly = 0;
                        sum_year = 0;
                        if (brands.Keys.Contains(it))
                        {
                            html_table.AppendFormat("<tr><td style=' white-space: nowrap;text-align:left;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td><td style='text-align:left; white-space: nowrap;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{1}&nbsp;&nbsp;</td>", brands[it].Brand_Name, brands[it].vendor_name_simple);
                        }
                        else
                        {
                            html_table.AppendFormat("<tr><td>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td><td >&nbsp;&nbsp;{1}&nbsp;&nbsp;</td>", " ", " ");
                        }
                        foreach (string ite in brandDailyTotal[it]["daysum"].Keys)
                        {
                            string ym = ite.Substring(0, 7);
                            if (string.IsNullOrEmpty(ym_last))
                                ym_last = ym;
                            if (!ym_last.Equals(ym))
                            {
                                html_table.AppendFormat("<td style= 'text-align:right;color: #c00; white-space: nowrap;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", sum_monthly);
                                ym_last = ym;
                                sum_monthly = 0;
                            }
                            sum_monthly += brandDailyTotal[it]["daysum"][ite];
                            sum_year += brandDailyTotal[it]["daysum"][ite];
                            html_table.AppendFormat("<td style='text-align:right;white-space: nowrap;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", brandDailyTotal[it]["daysum"][ite]);
                        }
                        if (CrossMonth)
                        {
                            html_table.AppendFormat("<td style= 'text-align:right;color: #c00; white-space: nowrap;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", sum_monthly);
                        }
                        html_table.AppendFormat("<td style= 'text-align:right;color: #c00; white-space: nowrap;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td> </tr>", sum_year);



                    }
                    html_table.AppendFormat("</tbody></table>");
                    json = "{success:true,msg:\"" + html_table.ToString() + "\"}";
                }


           // }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";

            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;


        }
Exemplo n.º 4
0
        public HttpResponseBase ExportFile()
        {
            int totalCount = 0;
            string json = "false";
            try
            {
                VendorBrandQuery query = new VendorBrandQuery();
                _vendorBrand = new VendorBrandMgr(connectionString);
                query.IsPage = false;
                query.isExport = true;
                // query.searchContent = Request.Params["searchContent"];
                if (!string.IsNullOrEmpty(Request.Params["searchContent"]))
                {
                    //支持空格,中英文逗號隔開
                    string content = Regex.Replace(Request.Params["searchContent"].Trim(), "(\\s+)|(,)|(\\,)", ",");
                    string[] contents = content.Split(',');
                    int pid = 0;
                    for (int i = 0; i < contents.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(contents[i].Trim()))
                        {
                            if (query.searchContent == "")
                            {
                                if (int.TryParse(contents[i], out pid))
                                {
                                    query.searchContent += Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ",");
                                }
                                else
                                {
                                    query.searchContent += Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ",");
                                }
                            }
                            else
                            {
                                if (int.TryParse(contents[i], out pid))
                                {
                                    query.searchContent += "," + Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ",");
                                }
                                else
                                {
                                    query.searchContent += "," + Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ",");
                                }
                            }
                        }
                        else
                        {
                            continue;
                        }

                    }
                }
                query.story_createname = Request.Params["createname"];
                if (!string.IsNullOrEmpty(Request.Params["searchVendor"]))
                {
                    if (Request.Params["searchVendor"] != "undefined")
                    {
                        query.Vendor_Id = uint.Parse(Request.Params["searchVendor"]);
                    }
                }
                if (!string.IsNullOrEmpty(Request.Params["brandid"]))
                {
                    if (Request.Params["brandid"] != "undefined")
                    {
                        query.Brand_Id = uint.Parse(Request.Params["brandid"]);
                    }
                }
                // query.searchState = Convert.ToInt32(Request.Params["searchState"]);
                if (!string.IsNullOrEmpty(Request.Params["start_date"]))
                {
                    query.date_start = Convert.ToDateTime(Request.Params["start_date"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["end_date"]))
                {
                    query.date_end = Convert.ToDateTime(Request.Params["end_date"]);
                }
                if (Request.Params["searchState"] == "0")
                {
                    query.Brand_Story_Text = string.Empty;
                }
                else if (Request.Params["searchState"] == "1")
                {
                    query.Brand_Story_Text = "1";
                }
                else if (Request.Params["searchState"] == "2")
                {
                    query.Brand_Story_Text = "2";
                }
                #region 供應商狀態、品牌狀態
                if (!string.IsNullOrEmpty(Request.Params["vendorState"]))
                {
                    query.vendorState = Convert.ToInt32(Request.Params["vendorState"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["brandState"]))
                {
                    query.Brand_Status = Convert.ToUInt32(Request.Params["brandState"]);
                }
                #endregion

                query.IsPage = false;

                DataTable dtHZ = new DataTable();

                string newExcelName = string.Empty;
                dtHZ.Columns.Add("供應商編號", typeof(String));
                dtHZ.Columns.Add("供應商名稱", typeof(String));
                dtHZ.Columns.Add("品牌編號", typeof(String));
                dtHZ.Columns.Add("品牌名稱", typeof(String));
                dtHZ.Columns.Add("建立人", typeof(String));
                dtHZ.Columns.Add("建立時間", typeof(String));
                dtHZ.Columns.Add("修改人", typeof(String));
                dtHZ.Columns.Add("修改時間", typeof(String));

                DataTable _dt = _vendorBrand.GetVendorBrandStory(query, out totalCount);

                foreach (DataRow dr_v in _dt.Rows)
                {
                    DataRow dr = dtHZ.NewRow();
                    dr[0] = dr_v["vendor_id"].ToString();
                    dr[1] = dr_v["vendor_name_full"].ToString();
                    dr[2] = dr_v["brand_id"].ToString();
                    dr[3] = dr_v["brand_name"].ToString();
                    dr[4] = dr_v["story_createname"].ToString();
                    dr[5] = dr_v["story_createdate"].ToString();
                    dr[6] = dr_v["story_updatename"].ToString();
                    dr[7] = dr_v["story_updatedate"].ToString();

                    dtHZ.Rows.Add(dr);
                }
                string[] colname = new string[dtHZ.Columns.Count];
                string filename = "vendorbrand_story" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                newExcelName = Server.MapPath(excelPath_export) + filename;
                for (int i = 0; i < dtHZ.Columns.Count; i++)
                {
                    colname[i] = dtHZ.Columns[i].ColumnName;
                }

                if (System.IO.File.Exists(newExcelName))
                {
                    System.IO.File.Delete(newExcelName);
                }
                ExcelHelperXhf.ExportDTtoExcel(dtHZ, "", newExcelName);
                //CsvHelper.ExportDataTableToCsv(_dt, newExcelName, columnName, true);
                json = "{success:true,ExcelName:\'" + filename + "\'}";

            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);

            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 5
0
        public HttpResponseBase VendorBrandPreview()
        {
            _siteConfigMgr = new SiteConfigMgr(Server.MapPath(xmlPath));
            List<SiteConfig> configList = _siteConfigMgr.Query();
            string DomainName = configList.Where(m => m.Name.Equals("DoMain_Name")).FirstOrDefault().Value;
            string json = string.Empty;
            try
            {
                VendorBrandQuery query = new VendorBrandQuery();
                _vendorBrand = new VendorBrandMgr(connectionString);
                if (!string.IsNullOrEmpty(Request.Params["brand_id"]))
                {
                    query.Brand_Id = Convert.ToUInt32(Request.Params["brand_id"]);
                    int classify = _vendorBrand.GetClassify(query);
                    string result = string.Empty;
                    switch (classify)
                    {
                        case 10:
                            result += "http://" + DomainName + "/food/brand_food.php?b_id=" + query.Brand_Id;//商品預覽
                            break;
                        case 20:
                            result += "http://" + DomainName + "/stuff/brand_stuff.php?b_id=" + query.Brand_Id;//商品預覽
                            break;
                        default:
                            result += "http://" + DomainName + "/brand.php?b_id=" + query.Brand_Id;//商品預覽
                            break;
                        //www.gigade100.com/newweb/food/brand_food.php?b_id=332
                    }
                    json = result.ToString().ToLower();
                }

            }
            catch (Exception ex)
            {

                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "無預覽信息";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 6
0
        public HttpResponseBase AddVendorBrandStory()
        {
            string json = string.Empty;
            int i = 0;
            try
            {
                VendorBrandQuery query = new VendorBrandQuery();
                _vendorBrand = new VendorBrandMgr(connectionString);
                query.Brand_Id = Convert.ToUInt32(Request.Params["brandid"]);
                query.Brand_Name = Request.Params["brandName"];
                query.Brand_Story_Text = Request.Params["brandStoryText"];
                query.Brand_Story_Text = query.Brand_Story_Text.Replace("\\", "\\\\");
                VendorBrand oldbrand = _vendorBrand.GetVendorBrand(query).FirstOrDefault();
                query.Story_Update = Convert.ToInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                query.Story_Updatedate = DateTime.Now;
                if (oldbrand.Story_Created == 0)
                {
                    query.Story_Created = query.Story_Update;
                    query.Story_Createdate = query.Story_Updatedate;
                }
                else
                {
                    query.Story_Created = oldbrand.Story_Created;
                    query.Story_Createdate = oldbrand.Story_Createdate;
                }

                i = _vendorBrand.AddVendorBrandStory(query);
                if (i > 0)
                {
                    json = "{success:true,msg:'修改成功!'}";//返回json數據
                }
                else
                {
                    json = "{success:false,msg:'修改失敗!'}";
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,msg:'異常!'}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 7
0
        public List<VendorBrandQuery> GetBandList(VendorBrandQuery query)
        {
            StringBuilder strSql = new StringBuilder(@"SELECT vb.brand_id,vb.brand_name,v.vendor_id,v.vendor_name_simple ");
            try
            {
            strSql.Append("  FROM vendor_brand vb,vendor v ");
            strSql.Append("  WHERE vb.vendor_id=v.vendor_id AND vb.brand_status=1 ");
            
            strSql.Append("   ORDER BY vb.brand_id ASC");
            
                return _dbAccess.getDataTableForObj<VendorBrandQuery>(strSql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("VendorBrandDao-->GetBandList-->" + ex.Message + "sql:" + strSql.ToString(), ex);
            }

        }
Exemplo n.º 8
0
        public int GetClassify(VendorBrandQuery query)
        {
            try
            {
                return _vendorBrandDao.GetClassify(query);
            }
            catch (Exception ex)
            {

                throw new Exception("VendorBrandMgr-->GetClassify-->" + ex.Message, ex);
            }
        }
Exemplo n.º 9
0
        public List<VendorBrand> GetVendorBrand(VendorBrandQuery query)
        {
            query.Replace4MySQL();
            StringBuilder strSql = new StringBuilder();
            try
            {
                strSql.AppendFormat(@"SELECT brand_id,brand_name,brand_status,brand_story_text,story_created,story_createdate,story_update,story_updatedate FROM vendor_brand ");
                if (query.Brand_Id != 0)
                {
                    strSql.AppendFormat(" where brand_id='{0}'", query.Brand_Id);
                }
                return _dbAccess.getDataTableForObj<VendorBrand>(strSql.ToString());
            }
            catch (Exception ex)
            {

                throw new Exception("VendorBrandDao-->GetVendorBrand-->" + ex.Message + "sql:" + strSql.ToString(), ex);
            }
        }
Exemplo n.º 10
0
 public string GetBrand_idByBrand_name(VendorBrandQuery query)
 {
     StringBuilder sql = new StringBuilder();
     try
     {
         query.Replace4MySQL();
         sql.AppendFormat(@"SELECT brand_id,brand_name from vendor_brand WHERE brand_name LIKE N'%{0}%'",query.Brand_Name);
         return sql.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("VendorBrandDao-->GetBrand_idByBrand_name-->" + ex.Message + "sql:" + sql.ToString(), ex);
     }
 }
Exemplo n.º 11
0
        public int GetClassify(VendorBrandQuery query)
        {
            query.Replace4MySQL();
            StringBuilder strSql = new StringBuilder();
            DataTable store = new DataTable();
            int classify = 0;

            try
            {
                strSql.AppendFormat(@"SELECT DISTINCT prod_classify from product WHERE brand_id={0}  ", query.Brand_Id);

                store = _dbAccess.getDataTable(strSql.ToString());
                foreach (DataRow row in store.Rows)
                {
                    if (Convert.ToInt32(row[0]) == 10 || Convert.ToInt32(row[0]) == 20)
                    {
                        classify = Convert.ToInt32(row[0]);
                        break;
                    }
                    else
                    {
                        classify = Convert.ToInt32(row[0]);
                    }
                }
            }
            catch (Exception ex)
            {

                throw new Exception("VendorBrandDao-->GetClassify-->" + ex.Message + "sql:" + strSql.ToString(), ex);
            }
            return classify;
        }
Exemplo n.º 12
0
        public int AddVendorBrandStory(VendorBrandQuery query)
        {
            query.Replace4MySQL();
            StringBuilder strSql = new StringBuilder();
            DataTable store = new DataTable();

            try
            {
                query.Brand_Story_Text = query.Brand_Story_Text.Replace("\n", "<br/>");
                strSql.AppendFormat(@"UPDATE vendor_brand SET brand_story_text ='{0}',story_created='{1}',story_createdate='{2}',", query.Brand_Story_Text, query.Story_Created, Common.CommonFunction.DateTimeToString(query.Story_Createdate));
                strSql.AppendFormat(" story_update='{0}', story_updatedate='{1}'  WHERE brand_id={2} ", query.Story_Update, Common.CommonFunction.DateTimeToString(query.Story_Updatedate), query.Brand_Id);
                return _dbAccess.execCommand(strSql.ToString());

            }
            catch (Exception ex)
            {

                throw new Exception("VendorBrandDao-->AddVendorBrandStory-->" + ex.Message + "sql:" + strSql.ToString(), ex);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 獲取品牌故事文字列表
        /// </summary>
        /// <param name="query">VendorBrand表對象</param>
        /// <param name="totalCount">查詢記錄總條數</param>
        /// <returns></returns>
        public DataTable GetVendorBrandStory(VendorBrandQuery query, out int totalCount)
        {
            query.Replace4MySQL();
            StringBuilder conditionsql = new StringBuilder();
            StringBuilder strSql = new StringBuilder();
            StringBuilder sqlWhere = new StringBuilder();
            StringBuilder count = new StringBuilder();
            VendorBrand list = new VendorBrand();
            DataTable store = new DataTable();
            totalCount = 0;
            try
            {
                if (query.isExport)
                {
                    conditionsql.AppendFormat(@"SELECT v.vendor_id,v.vendor_name_full, brand_id,brand_name,mu.user_username story_createname,story_createdate,mu1.user_username story_updatename,story_updatedate ");
                    conditionsql.AppendFormat(@"  FROM vendor_brand vb  ");
                }
                else
                {
                    conditionsql.AppendFormat(@"SELECT brand_id,brand_name,brand_status,brand_story_text,story_created,mu.user_username story_createname,story_createdate, ");
                    conditionsql.AppendFormat(@"  story_update,mu1.user_username story_updatename,story_updatedate FROM vendor_brand vb  ");
                }
                strSql.AppendFormat(@" LEFT JOIN manage_user mu on mu.user_id=vb.story_created ");
                strSql.AppendFormat(@" LEFT JOIN manage_user mu1 on mu1.user_id=vb.story_update ");
                strSql.AppendFormat(@" LEFT JOIN vendor v on vb.vendor_id=v.vendor_id  ");

                count.AppendFormat(@" SELECT count(brand_id) as totalCount from vendor_brand vb ");
                if (query.Vendor_Id != 0)
                {
                    sqlWhere.AppendFormat(" AND vb.vendor_id={0} ", query.Vendor_Id);
                }
                if (query.Brand_Id != 0)
                {
                    sqlWhere.AppendFormat(" AND vb.brand_id={0} ", query.Brand_Id);
                }
                if (query.date_start != DateTime.MinValue)
                {
                    sqlWhere.AppendFormat(" and vb.story_createdate >= '{0}'", Common.CommonFunction.DateTimeToString(query.date_start));

                }
                if (query.date_end != DateTime.MinValue)
                {
                    sqlWhere.AppendFormat(" and  vb.story_createdate <= '{0}'", Common.CommonFunction.DateTimeToString(query.date_end));
                }

                if (!string.IsNullOrEmpty(query.searchContent))
                {
                    //判斷“品牌編號/品牌名稱”輸入欄是否輸入的是數字
                    //如果是數字就按品牌編號和品牌名稱中帶輸入內容的條件進行搜索,不是數字就按品牌名稱帶搜索內容的條件來搜索
                    int result = 0;
                    //支持空格,中英文逗號隔開
                    string content = Regex.Replace(query.searchContent.Trim(), "(\\s+)|(,)|(\\,)", ",");
                    string[] contents = content.Split(',');
                    bool isSucess = int.TryParse(contents[0], out result);
                    if (isSucess)
                    {
                        sqlWhere.AppendFormat(" AND vb.brand_id IN ({0})  ", content);
                    }
                    else
                    {
                        sqlWhere.AppendFormat(@" AND ( ");
                        for (int i = 0; i < contents.Length; i++)
                        {
                            if (i == 0)
                            {
                                sqlWhere.AppendFormat(@"  vb.brand_name LIKE N'%{0}%' ", contents[i]);
                            }
                            else
                            {
                                sqlWhere.AppendFormat(@" OR vb.brand_name LIKE N'%{0}%'  ", contents[i]);
                            }

                        }
                        sqlWhere.AppendFormat(@" )");
                    }

                }
                if (!string.IsNullOrEmpty(query.story_createname))
                {
                    sqlWhere.AppendFormat(" AND mu.user_username like N'%{0}%'  ", query.story_createname);
                }
                //Brand_Story_Text是未編輯狀態
                if (query.Brand_Story_Text == "1")
                {
                    sqlWhere.AppendFormat(" AND vb.brand_story_text IS NULL");
                }
                //Brand_Story_Text是已編輯狀態
                else if (query.Brand_Story_Text == "2")
                {
                    sqlWhere.AppendFormat(" AND vb.brand_story_text IS NOT NULL");
                }
                if (query.vendorState != 0)
                {
                    sqlWhere.AppendFormat(" AND v.vendor_status={0}", query.vendorState);
                }
                if (query.Brand_Status != 0)
                {
                    sqlWhere.AppendFormat(" AND vb.brand_status={0}", query.Brand_Status);
                }
                if (sqlWhere.Length != 0)
                {
                    strSql.Append(" WHERE ");
                    strSql.Append(sqlWhere.ToString().TrimStart().Remove(0, 3));
                }
                if (query.IsPage)
                {
                    DataTable dt = _dbAccess.getDataTable(count.ToString() + strSql.ToString());
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        totalCount = Convert.ToInt32(dt.Rows[0]["totalCount"]);
                    }
                    strSql.AppendFormat(" order by brand_id limit {0},{1} ", query.Start, query.Limit);
                }
                else
                {
                    strSql.AppendFormat(" order by brand_id ");
                }

                store = _dbAccess.getDataTable(conditionsql.ToString() + strSql.ToString());
                return store;
            }
            catch (Exception ex)
            {

                throw new Exception("VendorBrandDao-->GetVendorBrandStory-->" + ex.Message + "sql:" + conditionsql.ToString() + strSql.ToString(), ex);
            }
        }
Exemplo n.º 14
0
        public DataTable GetVendorBrandStory(VendorBrandQuery query, out int totalCount)
        {
            try
            {
                return _vendorBrandDao.GetVendorBrandStory(query, out totalCount);
            }
            catch (Exception ex)
            {

                throw new Exception("VendorBrandMgr-->GetVendorBrandStory-->" + ex.Message, ex);
            }
        }
Exemplo n.º 15
0
        public string GetBrandName(PromotionBannerQuery query)
        {
            try
            {
                VendorBrandQuery vb_query = new VendorBrandQuery();
                vb_query.Brand_Id = (uint)query.singleBrand_id;
                List<VendorBrand> exits = _vendorBrandDao.GetVendorBrand(vb_query);//查詢是否有這個品牌編號
                uint brand_id = 0;
                string brand_name = string.Empty;
                if (exits.Count != 0)
                {
                    if (query.multi == 0)
                    {
                        string[] bids = query.singleBrand_id.ToString().Split(',');
                        AllowShowOrNot(query, bids, out brand_id);
                        if (brand_id != 0)
                        {
                            return "-2";//品牌编号在該促銷圖片顯示期間已有其他促銷圖片 且已啟用
                        }
                    }
                    List<VendorBrand> vb_store = _vendorBrandDao.GetBrandListByIds(string.Empty, query.singleBrand_id);
                    if (vb_store != null)
                    {
                        brand_name = vb_store[0].Brand_Name;
                    }
                    return brand_name;
                }
                else
                {
                    return "-1";
                }

            }
            catch (Exception ex)
            {
                throw new Exception("PromotionBannerRelationMgr-->GetBrandName-->" + ex.Message, ex);
            }
        }
Exemplo n.º 16
0
        public int AddVendorBrandStory(VendorBrandQuery query)
        {
            try
            {
                return _vendorBrandDao.AddVendorBrandStory(query);
            }
            catch (Exception ex)
            {

                throw new Exception("VendorBrandMgr-->AddVendorBrandStory-->" + ex.Message, ex);
            }
        }
Exemplo n.º 17
0
        public HttpResponseBase GetVendorBrandStory()
        {
            string json = string.Empty;
            DataTable stores = new DataTable();
            try
            {
                VendorBrandQuery query = new VendorBrandQuery();
                _vendorBrand = new VendorBrandMgr(connectionString);
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量   
                // query.searchContent = Request.Params["searchContent"].Trim();

                if (!string.IsNullOrEmpty(Request.Params["searchContent"]))
                {
                    //支持空格,中英文逗號隔開
                    string content = Regex.Replace(Request.Params["searchContent"].Trim(), "(\\s+)|(,)|(\\,)", ",");
                    string[] contents = content.Split(',');
                    int pid = 0;
                    for (int i = 0; i < contents.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(contents[i].Trim()))
                        {
                            if (query.searchContent == "")
                            {
                                if (int.TryParse(contents[i], out pid))
                                {
                                    query.searchContent += Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ",");
                                }
                                else
                                {
                                    query.searchContent += Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ",");
                                }
                            }
                            else
                            {
                                if (int.TryParse(contents[i], out pid))
                                {
                                    query.searchContent += "," + Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ",");
                                }
                                else
                                {
                                    query.searchContent += "," + Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ",");
                                }
                            }
                        }
                        else
                        {
                            continue;
                        }

                    }
                }
                query.story_createname = Request.Params["createname"].Trim();
                query.story_createname = query.story_createname.Trim();
                if (!string.IsNullOrEmpty(Request.Params["searchVendor"]))
                {
                    query.Vendor_Id = uint.Parse(Request.Params["searchVendor"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["brandid"]))
                {
                    query.Brand_Id = uint.Parse(Request.Params["brandid"]);
                }
                // query.searchState = Convert.ToInt32(Request.Params["searchState"]);
                if (!string.IsNullOrEmpty(Request.Params["start_date"]))
                {
                    query.date_start = Convert.ToDateTime(Request.Params["start_date"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["end_date"]))
                {
                    query.date_end = Convert.ToDateTime(Request.Params["end_date"]);
                }
                if (Request.Params["searchState"] == "0")
                {
                    query.Brand_Story_Text = string.Empty;
                }
                else if (Request.Params["searchState"] == "1")
                {
                    query.Brand_Story_Text = "1";
                }
                else if (Request.Params["searchState"] == "2")
                {
                    query.Brand_Story_Text = "2";
                }
                #region 供應商狀態、品牌狀態
                if (!string.IsNullOrEmpty(Request.Params["vendorState"]))
                {
                    query.vendorState = Convert.ToInt32(Request.Params["vendorState"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["brandState"]))
                {
                    query.Brand_Status = Convert.ToUInt32(Request.Params["brandState"]);
                }
                #endregion
                int totalCount = 0;
                stores = _vendorBrand.GetVendorBrandStory(query, out totalCount);

                foreach (DataRow dr in stores.Rows)
                {
                    dr["Brand_Story_Text"] = dr["Brand_Story_Text"].ToString().Replace("<br/>", "\n");
                }
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Newtonsoft.Json.Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Exemplo n.º 18
0
        public List<VendorBrand> GetVendorBrand(VendorBrandQuery query)
        {
            try
            {
                return _vendorBrandDao.GetVendorBrand(query);
            }
            catch (Exception ex)
            {

                throw new Exception("VendorBrandMgr-->GetVendorBrand-->" + ex.Message, ex);
            }
        }
 public HttpResponseBase BrandStore()
 {
     string json = string.Empty;
     try
     {
         VendorBrandQuery query = new VendorBrandQuery();
         List<VendorBrand> store = new List<VendorBrand>();
         query.Brand_Status = 1;
         _vendorBrand = new BLL.gigade.Mgr.VendorBrandMgr(mySqlConnectionString);
         store = _vendorBrand.GetProductBrandList(query);
         json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented) + "}";
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:false,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }