예제 #1
0
 public string QueryBrand(int hideOffGrade = 0)
 {
     VendorBrand vb = new VendorBrand();
     vbMgr = new VendorBrandMgr(connectionString);
     //edit by Castle
     //date:2014/07/18
     //要求不限制
     //vb.Brand_Status = 1;
     string json = vbMgr.QueryBrand(vb, hideOffGrade);
     return json;
 }
예제 #2
0
 public string QueryBrand()
 {
     VendorBrand vb = new VendorBrand();
     vb.Vendor_Id = Convert.ToUInt32((Session["vendor"] as BLL.gigade.Model.Vendor).vendor_id);
     vbMgr = new VendorBrandMgr(connectionString);
     //edit by Castle
     //date:2014/07/18
     //要求不限制
     //vb.Brand_Status = 1;
     string json = vbMgr.QueryBrand(vb);
     return json;
 }
예제 #3
0
        public string QueryBrand()
        {
            string json = string.Empty;
            try
            {
                BLL.gigade.Model.Vendor vendorModel=(BLL.gigade.Model.Vendor)Session["vendor"];
                VendorBrand vb = new VendorBrand();
                vb.Vendor_Id = vendorModel.vendor_id;//獲取該供應商下的所有品牌,暫時寫死
                vbMgr = new VendorBrandMgr(connectionString);

                json = vbMgr.QueryBrand(vb);

            }
            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);
            }
            return json;
        }
예제 #4
0
 /// <summary>
 /// 獲得品牌
 /// </summary>
 /// <returns></returns>
 public HttpResponseBase GetVendorBrand()
 {
     VendorBrand vb = new VendorBrand();
     List<VendorBrand> store = new List<VendorBrand>();
     string json = string.Empty;
     try
     {
         vbMgr = new VendorBrandMgr(connectionString);
         if (!string.IsNullOrEmpty(Request.Params["vendor_id"]))
         {
             vb.Vendor_Id = uint.Parse(Request.Params["vendor_id"]);
         }
         store = vbMgr.GetProductBrandList(vb);
         json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented) + "}";//返回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,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
        public string QueryClassBrand()
        {
            string json = string.Empty;
            try
            {
                uint cid = 0;
                VendorBrand vb = new VendorBrand();
                VendorBrandMgr vbMgr = new VendorBrandMgr(connectionString);
                //Edit By Castle
                //Date:2014/07/01
                //Discription:Brand_status是给前台用的后台不做限制
                vb.Brand_Status = 0;
                //vb.Brand_Status = 1;

                if (!string.IsNullOrEmpty(Request.Form["topValue"]))
                {
                    cid = Convert.ToUInt32(Request.Form["topValue"]);
                }

                json = vbMgr.QueryClassBrand(vb, cid);

            }
            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);
            }
            return json;
        }
 public string QueryBrand()
 {
     string json = string.Empty;
     try
     {
         VendorBrandMgr vbMgr = new VendorBrandMgr(connectionString);
         json = vbMgr.QueryBrand(new VendorBrand { Brand_Status = 1 });
     }
     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);
     }
     return json;
 }
        public HttpResponseBase ISVendorProduct()
        {
            string resultStr = "{success:false}";
            try
            {
                BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];

                int writer_id = Convert.ToInt32(vendorModel.vendor_id);

                VendorBrand vb = new VendorBrand();
                vb.Vendor_Id = vendorModel.vendor_id;//todo:獲取該供應商下的所有品牌,暫時寫死
                vbMgr = new VendorBrandMgr(connectionString);
                List<VendorBrand> brandList = vbMgr.GetProductBrandList(vb);

                uint brand = 0;

                if (!string.IsNullOrEmpty(Request.Form["ProductId"]))//編輯數據
                {
                    uint product_id = 0;
                    if (uint.TryParse(Request.Form["ProductId"], out product_id)) //正式表數據
                    {
                        _productMgr = new ProductMgr(connectionString);
                        Product p = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault();
                        if (p != null)
                        {
                            brand = p.Brand_Id;
                        }
                    }
                    else
                    {//臨時表數據
                        _productTempMgr = new ProductTempMgr(connectionString);
                        ProductTemp pTemp = _productTempMgr.GetProTempByVendor(new ProductTemp { Product_Id = Request.Form["ProductId"], Writer_Id = writer_id, Create_Channel = 2, Temp_Status = 12 }).FirstOrDefault();
                        if (pTemp != null)
                        {
                            brand = pTemp.Brand_Id;
                        }
                    }

                    foreach (VendorBrand item in brandList)
                    {
                        if (brand == item.Brand_Id)
                        {
                            resultStr = "{success:true}";
                            break;
                        }
                    }
                }
            }
            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);
                resultStr = "{success:false}";
            }

            this.Response.Clear();
            this.Response.Write(resultStr);
            this.Response.End();
            return this.Response;
        }
예제 #8
0
 public string QueryBrand()
 {
     VendorBrand vb = new VendorBrand();
     vbMgr = new VendorBrandMgr(connectionString);
     vb.Brand_Status = 1;
     string json = vbMgr.QueryBrand(vb);
     return json;
 }
예제 #9
0
        //加購物金欄位
        public HttpResponseBase GetOrderRevenue()
        {
            string json = string.Empty;
            string brandserch = "是否单个查询";
            StringBuilder sb = new StringBuilder();//查詢訂單的條件
            StringBuilder Sbandlist = new StringBuilder();//查詢賣場和管別的條件
            OrderBrandProducesQuery oq = new OrderBrandProducesQuery();
            uint id; int cid;
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["Brand_Id"]))/*品牌編號*/
                {
                    oq.bid = Request.Params["Brand_Id"];
                    if (oq.bid.Substring(0, 1) != "0")
                    {
                        sb.AppendFormat("and p.brand_id in ({0})", oq.bid);
                        Sbandlist.AppendFormat("and vb.brand_id in ( {0})", oq.bid);
                    }
                }
                if (uint.TryParse(Request.Params["product_manage"], out id))
                {//獲取管理人
                    oq.product_manage = id;
                    if (id > 0)
                    {
                        sb.AppendFormat(" AND v.product_manage='{0}'", id);
                    }
                }
                if (int.TryParse(Request.Params["channel"], out cid))
                {//獲取管理人
                    oq.channel = cid;
                    if (cid > 0)
                    {
                        sb.AppendFormat(" AND om.channel='{0}'", cid);
                    }
                }
                if (uint.TryParse(Request.Params["slave_status"], out id))
                {//獲取 訂單狀態
                    oq.slave_status = id;
                    switch (id)
                    {
                        case 0:
                            sb.AppendFormat(" and os.slave_status in(0,2,4,99,5,6)");
                            break;
                        default:
                            sb.AppendFormat(" and os.slave_status={0}", id);
                            break;
                    }
                }
                if (uint.TryParse(Request.Params["order_payment"], out id))
                {//獲取 付款方式
                    oq.order_payment = id;
                    if (id > 0)
                    {
                        sb.AppendFormat(" and om.order_payment={0}", id);
                    }
                }
                if (!string.IsNullOrEmpty(Request.Params["selecttype"]))
                {
                    oq.selecttype = Request.Params["selecttype"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["searchcon"]))
                {
                    oq.searchcon = Request.Params["searchcon"].ToString();
                    if (string.IsNullOrEmpty(oq.searchcon) && oq.searchcon != "null")
                    {//查詢內容不為空就執行模糊查詢
                        switch (oq.selecttype)
                        {
                            case "1":
                                sb.AppendFormat(" AND od.product_name LIKE  '%{0}%'", oq.searchcon);
                                break;
                            case "2"://會員編號
                                sb.AppendFormat(" AND om.user_id LIKE '%{0}%'", oq.searchcon);
                                break;
                            case "3":
                                sb.AppendFormat(" om.order_name LIKE   '%{0}%'", oq.searchcon);
                                break;
                            default:
                                break;
                        }
                    }
                }
                string sqlap = sb.ToString();
                #region 日期條件
                DateTime dtime;
                if (DateTime.TryParse(Request.Params["dateOne"], out dtime))
                {
                    oq.dateOne = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                    if (oq.dateOne > DateTime.MinValue)
                    {
                        sb.AppendFormat(" AND om.order_createdate  >= '{0}' ", CommonFunction.GetPHPTime(oq.dateOne.ToString()));
                    }
                }
                if (DateTime.TryParse(Request.Params["dateTwo"], out dtime))
                {
                    oq.dateTwo = DateTime.Parse(dtime.ToString("yyyy-MM-dd 23:59:59"));
                    if (oq.dateTwo > DateTime.MinValue)
                    {
                        sb.AppendFormat(" AND om.order_createdate <= '{0}' ", CommonFunction.GetPHPTime(oq.dateTwo.ToString()));
                    }
                }
                #endregion
                int a = 0;
                _vbrand = new VendorBrandMgr(mySqlConnectionString);
                _Iorderbrandproduces = new OrderBrandProducesMgr(mySqlConnectionString);
                dt = _vbrand.GetBandList(Sbandlist.ToString());//查詢品牌列表
                if (string.IsNullOrEmpty(brandserch))//查询所有
                {
                    DataTable ds = _Iorderbrandproduces.GetOrderVendorRevenuebyday(sb.ToString(), brandserch);//查詢品牌列表中的營業額,之查詢每天的
                    #region 没有的品牌添加上
                    foreach (DataRow item in ds.Rows)
                    {
                        DataRow[] rows = dt.Select("brand_id='" + item["brand_id"] + "' and vendor_id='" + item["vendor_id"] + "'");
                        if (rows.Count() == 0)
                        {
                            DataRow drr = dt.NewRow();
                            drr[0] = item["brand_id"];
                            drr[1] = item["brand_name"];
                            drr[2] = item["vendor_id"];
                            drr[3] = item["vendor_name_simple"];
                            dt.Rows.Add(drr);
                        }
                    }
                    #endregion
                }
                string q = a.ToString();
                TimeSpan s = oq.dateTwo - oq.dateOne;//查詢的開始日期和結束日期相差的天數
                int day = s.Days;

                #region 測試方法
                _Iorderbrandproduces = new OrderBrandProducesMgr(mySqlConnectionString);
                DataColumn addcolms;//循環添加列每月的統計
                DataRow addrow = dt.NewRow();//添加一行每日小計
                addrow[3] = "每日小計";
                int m = 0;//記錄增加了多少列,來確定每月一記的具體位置
                int M_total = 0;//每月一記

                StringBuilder html_table = new StringBuilder();//匯出html頁面
                html_table.AppendFormat(@"<div style='overflow:auto;text-align:right;width:1650px;height:550px;'><table style='border:1px;'>");
                html_table.AppendFormat("<tr><td>品牌名稱</td><td>供應商名稱</td>");

                int startclome = 4;//設求每月之初的列的下標,初始為4/。
                int stopclome = 3;//每個月結束的列的下標,初始為3/。
                #region  循環每天

                for (int d = 0; d <= day; d++)//查詢每天
                {
                    int D_bandsum = 0; //所有品牌每日的營業額
                    string daytimes = oq.dateOne.AddDays(d).ToString("yyyy-MM-dd");//循環的每一天
                    addcolms = new DataColumn(daytimes, typeof(String));
                    dt.Columns.Add(addcolms);
                    html_table.AppendFormat("<td>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", daytimes);

                    stopclome++;//加一列
                    #region 每日一記
                    string daytimeone = DateTime.Parse(daytimes).ToString("yyyy-MM-dd 00:00:00");//把每天轉換成初始從零點開始
                    string daytimetwo = DateTime.Parse(daytimes).ToString("yyyy-MM-dd 23:59:59");//每天的結束時間
                    string orderby = string.Format(" AND om.order_createdate  >= '{0}' AND om.order_createdate <= '{1}'", CommonFunction.GetPHPTime(daytimeone), CommonFunction.GetPHPTime(daytimetwo));
                    DataTable ds = _Iorderbrandproduces.GetOrderVendorRevenuebyday(sqlap + orderby, brandserch);//查詢品牌列表中的營業額,之查詢每天的


                    for (int i = 0; i < dt.Rows.Count; i++)//循環品牌列表,把每天的營業額追加進這個表裡
                    {
                        DataRow[] rows = ds.Select("brand_id='" + dt.Rows[i]["brand_id"] + "' and vendor_id='" + dt.Rows[i]["vendor_id"] + "'");//篩選出一個品牌的這個時間段的營業額
                        dt.Rows[i][daytimes] = 0;//單個品牌每日的營業額先賦初始值為0
                        foreach (DataRow row in rows)//篩選出的最多只有一條數據,如果有,加入某個品牌的每日營業額,沒有就為初始值
                        {
                            if (!string.IsNullOrEmpty(row["order_createdate"].ToString()))
                            {
                                string tb_createdate = CommonFunction.GetNetTime(long.Parse(rows[0]["order_createdate"].ToString())).ToString("yyyy-MM-dd");

                                dt.Rows[i][daytimes] = int.Parse(rows[0]["subtotal"].ToString());
                                D_bandsum = D_bandsum + int.Parse(rows[0]["subtotal"].ToString());
                            }
                        }
                    }
                    #endregion
                    #region 是否添加每月小計

                    addrow[4 + d + m] = D_bandsum;
                    M_total = M_total + D_bandsum;
                    if (oq.dateOne.Month != oq.dateTwo.Month || oq.dateOne.Year != oq.dateTwo.Year)//開始時間和結束時間不是在同一個月
                    {
                        DateTime days = DateTime.Parse(daytimes);
                        int t = DateTime.DaysInMonth(days.Year, days.Month);//一個月多少天
                        if (t == days.Day || d == day)//現在這個月的月底
                        {
                            addcolms = new DataColumn(days.Month + "月小計", typeof(String));//style='float:left;width:500px'
                            dt.Columns.Add(addcolms);
                            html_table.AppendFormat("<td ><font color='red'>&nbsp;&nbsp;&nbsp;&nbsp;{0}月小計&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></td>", days.Month);
                            m++;
                            foreach (DataRow item in dt.Rows)
                            {
                                item[stopclome + 1] = 0;//每月總計賦初始值
                                for (int i = startclome; i <= stopclome; i++)//每個品牌的每月總計
                                {
                                    item[stopclome + 1] = int.Parse(item[stopclome + 1].ToString()) + int.Parse(item[i].ToString());
                                }
                            }
                            addrow[stopclome + 1] = M_total;
                            startclome = stopclome + 2;
                            stopclome++;
                            M_total = 0;
                        }
                    }
                    #endregion
                }
                #endregion
                dt.Rows.InsertAt(addrow, 0);//添加一行總計
                #region  品牌總計
                addcolms = new DataColumn("品牌總計", typeof(String));
                html_table.AppendFormat("<td><font color='red'>品牌總計</font></td></tr>");
                dt.Columns.Add(addcolms);
                int S_total = 0;//所有品牌的總計
                DataTable dstable = _Iorderbrandproduces.GetOrderVendorRevenuebyday(sb.ToString(), brandserch);//查詢品牌列表中的營業額
                for (int i = 1; i < dt.Rows.Count; i++)
                {
                    int Aull_bandSum = 0;//每個商品的開始時間和結束時間的總計
                    DataRow[] rows = dstable.Select("brand_id='" + dt.Rows[i]["brand_id"] + "' and vendor_id='" + dt.Rows[i]["vendor_id"] + "'");//篩選出一個品牌的這個時間段的營業額
                    foreach (DataRow row in rows)
                    {
                        if (!string.IsNullOrEmpty(row["subtotal"].ToString()))
                        {
                            Aull_bandSum = Aull_bandSum + int.Parse(row["subtotal"].ToString());
                        }
                        S_total = S_total + Aull_bandSum;
                    }
                    dt.Rows[i]["品牌總計"] = Aull_bandSum;
                }
                dt.Rows[0]["品牌總計"] = S_total;
                #endregion
                #endregion
                #region  要查詢的列表,匯成一張table
                dt.Columns.RemoveAt(2);//移除多餘的列,供應商編號
                dt.Columns.RemoveAt(0);//移除多餘的列,品牌編號
                dt.Columns[0].ColumnName = "品牌名稱";
                dt.Columns[1].ColumnName = "供應商名稱";
                for (int x = 0; x < dt.Rows.Count; x++)
                {
                    html_table.AppendFormat("<tr>");
                    for (int y = 0; y < dt.Columns.Count; y++)
                    {
                        if (dt.Columns[y].ColumnName.ToString().IndexOf("月小計") > 0 || dt.Columns[y].ColumnName.ToString() == "品牌總計")
                        {
                            html_table.AppendFormat("<td style='text-align:right'>&nbsp;&nbsp;<font color='red'>{0}</font>&nbsp;&nbsp;</td>", dt.Rows[x][y]);
                        }
                        else
                        {
                            html_table.AppendFormat("<td style='text-align:right'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", dt.Rows[x][y]);
                        }

                        if (y == dt.Columns.Count - 1)
                        {
                            html_table.AppendFormat("</tr>");
                        }
                    }
                }

                html_table.AppendFormat(@"</table></div>");
                #endregion
                string n = html_table.ToString();
                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;
        }
예제 #10
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;
        }
예제 #11
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;
        }
예제 #12
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;
        }
예제 #13
0
        public ActionResult PictureMaintain()
        {
            VendorBrand query = new VendorBrand();
            _vendorBrand = new VendorBrandMgr(connectionString);

            ViewBag.BrandId = Request.Params["Brand_Id"];
            query.Brand_Id = Convert.ToUInt32(Request.Params["Brand_Id"]);
            VendorBrand model = _vendorBrand.GetProductBrand(query);
            if (model != null)
            {
                ViewBag.BrandName = model.Brand_Name;
                //Request.Params["Brand_Name"];
            }
            else
            {
                ViewBag.BrandName = "";
            }
            return View();
        }
예제 #14
0
        public string QueryBrand()
        {
            string json = string.Empty;
            try
            {
                uint cid = 0;
                int isShowGrade = 0;
                VendorBrandMgr vbMgr = new VendorBrandMgr(mySqlConnectionString);

                if (!string.IsNullOrEmpty(Request.Params["class_id"]))
                {
                    cid = Convert.ToUInt32(Request.Params["class_id"]);
                }

                if (!string.IsNullOrEmpty(Request.Params["isShowGrade"]))
                {
                    isShowGrade = Convert.ToInt32(Request.Params["isShowGrade"]);
                }
                json = vbMgr.QueryClassBrand(new VendorBrand { }, cid, isShowGrade);//參1:品牌條件 參2:館別條件 參3:失格供應商下是否顯示

            }
            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);
            }
            return json;
        }
예제 #15
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;


        }
예제 #16
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);

            }



        }
예제 #17
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;
        }
예제 #18
0
        public HttpResponseBase GetVendorBand()/*品牌列表*/
        {
            VendorBrand vb = new VendorBrand();
            _vbrand = new VendorBrandMgr(mySqlConnectionString);
            List<VendorBrand> stores = new List<VendorBrand>();
            string json = string.Empty;
            try
            {
                DataTable dt = _vbrand.GetBandList("");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    vb = new VendorBrand();
                    vb.Brand_Id = uint.Parse(dt.Rows[i]["brand_id"].ToString());
                    vb.Brand_Name = dt.Rows[i]["brand_name"].ToString();
                    stores.Add(vb);
                }
                json = "{success:true,data:" + JsonConvert.SerializeObject(stores) + "}";//返回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:true,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
예제 #19
0
        public HttpResponseBase DelPromoPicClick()
        {
            string json = "{success:true}";

            try
            {
                string picSrc = Request.Params["src"].ToString();
                var array = picSrc.Split('/');
                string picName = array.Last();
                int brandId = Convert.ToInt32(Request.Params["brand_id"].ToString());
                var path = imgLocalPath + brandPath + GetDetailFolder(picName) + picName;
                string type = Request.Params["type"].ToString();
                //刪除服務器上對應的圖片
                DeletePicFile(path);
                if (brandId != 0)
                {
                    _vendorBrand = new VendorBrandMgr(connectionString);
                    if (_vendorBrand.DelPromoPic(brandId, type) > 0)
                    {
                        json = "{success:true}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }
                }
            }
            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;
        }
        public HttpResponseBase QueryLastModifyRecord()
        {
            string result = string.Empty;
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["Product_Id"]))
                {
                    StringBuilder html = new StringBuilder();
                    int productId = Convert.ToInt32(Request.Form["Product_Id"]);
                    bool isPro = (Request.Form["Type"] ?? "") == "product";
                    _tableHistoryMgr = new TableHistoryMgr(connectionString);
                    _tableHistoryItemMgr = new TableHistoryItemMgr(connectionString);
                    TableHistory query = new TableHistory { pk_value = productId.ToString() };
                    if (isPro)
                    {
                        query.table_name = "product";
                    }
                    TableHistory lastRec = _tableHistoryMgr.QueryLastModifyByProductId(query);
                    if (lastRec != null)
                    {
                        List<TableHistory> histories = _tableHistoryMgr.Query(new TableHistory { batchno = lastRec.batchno });
                        if (histories != null && histories.Count > 0)
                        {
                            List<string> tbls = histories.GroupBy(m => m.table_name).Select(m => m.Key).ToList();
                            uint site = 0, level = 0, userid = 0;
                            string[] priceTable = { "price_master", "item_price" };
                            if (isPro)
                            {
                                tbls.RemoveAll(m => priceTable.Contains(m));
                            }
                            else
                            {
                                uint.TryParse(Request.Form["Site_id"], out site);
                                uint.TryParse(Request.Form["User_Level"], out level);
                                uint.TryParse(Request.Form["User_id"], out userid);
                                tbls.RemoveAll(m => !priceTable.Contains(m));
                            }
                            List<TableHistoryItem> items;
                            #region 初始化
                            StringBuilder pro = new StringBuilder();
                            StringBuilder spec = new StringBuilder();
                            StringBuilder category = new StringBuilder();
                            StringBuilder item = new StringBuilder();
                            StringBuilder master = new StringBuilder();
                            StringBuilder price = new StringBuilder();
                            NotificationController notification = new NotificationController();
                            #endregion
                            foreach (var tbl in tbls)
                            {
                                string tblName = tbl.ToString().ToLower();
                                bool isAdd = false;
                                #region 針對不同表的處理
                                switch (tblName)
                                {
                                    case "product":
                                        #region PRODUCT
                                        items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = lastRec.batchno, table_name = tblName });
                                        if (items != null && items.Count > 0)
                                        {
                                            StringBuilder column_1 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td>");
                                            StringBuilder column_2 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改前</td>");
                                            StringBuilder column_3 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改後</td>");
                                            Array cols = items.GroupBy(m => m.col_name).Select(m => m.Key).ToArray();
                                            foreach (var col in cols)
                                            {
                                                var tmp = items.FindAll(m => m.col_name == col.ToString());
                                                if (tmp.Count == 1 && string.IsNullOrEmpty(tmp.FirstOrDefault().old_value))
                                                { continue; }
                                                else
                                                {
                                                    tmp.Remove(tmp.Find(m => string.IsNullOrEmpty(m.old_value)));
                                                    var first = tmp.FirstOrDefault();
                                                    var last = tmp.LastOrDefault();
                                                    if (first == last)
                                                    {
                                                        notification.GetParamCon(last, true);
                                                    }
                                                    else
                                                    {
                                                        notification.GetParamCon(first, true);
                                                    }
                                                    notification.GetParamCon(last, false);
                                                    column_1.AppendFormat("<td style=\"border:1px solid #99bce8;\">{0}</td>", first.col_chsname);
                                                    column_2.AppendFormat("<td style=\"border:1px solid #99bce8;color:Red;\">{0}</td>", first == last ? last.old_value : first.old_value);//class=\"red\" 
                                                    column_3.AppendFormat("<td style=\"border:1px solid #99bce8;color:green;\">{0}</td>", last.col_value);//class=\"green\"
                                                    isAdd = true;
                                                }
                                            }
                                            if (isAdd)
                                            {
                                                pro.AppendFormat("<table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\">{0}</tr>{1}</tr>{2}</tr></table>", column_1, column_2, column_3);//class=\"tbptstyle\"
                                            }
                                        }
                                        #endregion
                                        break;
                                    case "product_spec":
                                        #region SPEC
                                        StringBuilder spec_1 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改前</td>");
                                        StringBuilder spec_2 = new StringBuilder("<tr><td style=\"border:1px solid #99bce8;\">修改後</td>");
                                        Array specIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in specIds)
                                        {
                                            items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = lastRec.batchno, table_name = tblName, pk_value = id.ToString() });
                                            if (items.Count == 1 && string.IsNullOrEmpty(items.FirstOrDefault().old_value))
                                            { continue; }
                                            else
                                            {
                                                items.Remove(items.Find(m => string.IsNullOrEmpty(m.old_value)));
                                                var first = items.FirstOrDefault();
                                                var last = items.LastOrDefault();
                                                spec_1.AppendFormat("<td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{0}</td>", first == last ? last.old_value : first.old_value);
                                                spec_2.AppendFormat("<td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{0}</td>", last.col_value);
                                                isAdd = true;
                                            }
                                        }
                                        if (isAdd)
                                        {
                                            spec.AppendFormat("<table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\">{0}</tr>{1}</tr></table>", spec_1, spec_2);//class=\"tbptstyle\"
                                        }
                                        #endregion
                                        break;
                                    case "product_category_set":
                                        #region CATEGORY
                                        items = _tableHistoryItemMgr.Query4Batch(new TableHistoryItemQuery { batchno = lastRec.batchno, table_name = tblName, pk_value = productId.ToString() });
                                        if (items.Count > 0)
                                        {
                                            var first = items.FirstOrDefault();
                                            var last = items.LastOrDefault();
                                            category.Append("<table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><tr><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改後</td></tr>");// class=\"tbptstyle\"
                                            category.AppendFormat("<tr><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{0}</td>", first == last ? last.old_value : first.old_value);
                                            category.AppendFormat("<td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{0}</td></td></table>", last.col_value);
                                        }
                                        #endregion
                                        break;
                                    case "product_item":
                                        #region ITEM
                                        ProductItem pItem;
                                        _productItemMgr = new ProductItemMgr(connectionString);
                                        Array itemIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in itemIds)
                                        {
                                            isAdd = false;
                                            pItem = _productItemMgr.Query(new ProductItem { Item_Id = uint.Parse(id.ToString()) }).FirstOrDefault();
                                            if (pItem != null)
                                            {
                                                string title = pItem.GetSpecName();
                                                string top = "<div style=\"float:left\"><table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><caption style=\"text-align:center;border:1px solid #99bce8;\">" + title + "</caption><tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改后</td></tr>";//class=\"tbstyle\"
                                                string bottom = "</table></div>";
                                                string strContent = "<tr><td style=\"border:1px solid #99bce8;\">{0}</td><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{1}</td><td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{2}</td></tr>";
                                                string content = notification.BuildContent(lastRec.batchno, tblName, id.ToString(), strContent, ref isAdd);
                                                if (isAdd)
                                                {
                                                    item.Append(top);
                                                    item.Append(content);
                                                    item.Append(bottom);
                                                }
                                            }
                                        }
                                        #endregion
                                        break;
                                    case "price_master":
                                        #region PRICE_MASTER
                                        PriceMaster pMaster;
                                        _pMaster = new PriceMasterMgr(connectionString);
                                        Array masterIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in masterIds)
                                        {
                                            isAdd = false;
                                            pMaster = _pMaster.Query(new PriceMaster { price_master_id = uint.Parse(id.ToString()) }).FirstOrDefault();
                                            if (pMaster != null && pMaster.site_id == site && pMaster.user_level == level && pMaster.user_id == userid)
                                            {
                                                string siteName = notification.QuerySiteName(pMaster.site_id.ToString());
                                                string userLevel = notification.QueryParaName(pMaster.user_level.ToString(), "UserLevel");
                                                string userMail = pMaster.user_id == 0 ? "" : notification.QueryMail(pMaster.user_id.ToString());
                                                string childName = string.Empty;
                                                if (pMaster.child_id != 0 && pMaster.product_id != pMaster.child_id)
                                                {
                                                    _productMgr = new ProductMgr(connectionString);
                                                    Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(pMaster.child_id) }).FirstOrDefault();
                                                    if (tmpPro != null)
                                                    {
                                                        childName = tmpPro.Product_Name;
                                                    }
                                                }
                                                string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail))
                                                                + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName);
                                                if (!title.Contains("子商品"))
                                                {
                                                    title += "<br/>";
                                                }
                                                string top = "<div style=\"float:left\"><table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><caption style=\"text-align:center;border:1px solid #99bce8;\">" + title + "</caption><tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改后</td></tr>";// class=\"tbstyle\" 
                                                string bottom = "</table></div>";
                                                string strContent = "<tr><td style=\"border:1px solid #99bce8;\">{0}</td><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{1}</td><td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{2}</td></tr>";
                                                string content = notification.BuildContent(lastRec.batchno, tblName, id.ToString(), strContent, ref isAdd);
                                                if (isAdd)
                                                {
                                                    master.Append(top);
                                                    master.Append(content);
                                                    master.Append(bottom);
                                                }
                                            }
                                        }
                                        #endregion
                                        break;
                                    case "item_price":
                                        #region ITEM_PRICE

                                        ItemPriceCustom itemPrice;
                                        PriceMaster tmpMaster;
                                        _itemPriceMgr = new ItemPriceMgr(connectionString);
                                        _pMaster = new PriceMasterMgr(connectionString);
                                        Array priceIds = histories.FindAll(m => m.table_name.ToLower() == tblName).GroupBy(m => m.pk_value).Select(m => m.Key).ToArray();
                                        foreach (var id in priceIds)
                                        {
                                            isAdd = false;
                                            itemPrice = _itemPriceMgr.Query(new ItemPrice { item_price_id = uint.Parse(id.ToString()) }).FirstOrDefault();
                                            if (itemPrice != null)
                                            {
                                                tmpMaster = _pMaster.Query(new PriceMaster { price_master_id = itemPrice.price_master_id }).FirstOrDefault();
                                                if (tmpMaster != null && tmpMaster.site_id == site && tmpMaster.user_level == level && tmpMaster.user_id == userid)
                                                {
                                                    string siteName = notification.QuerySiteName(tmpMaster.site_id.ToString());
                                                    string userLevel = notification.QueryParaName(tmpMaster.user_level.ToString(), "UserLevel");
                                                    string userMail = tmpMaster.user_id == 0 ? "" : notification.QueryMail(tmpMaster.user_id.ToString());
                                                    string childName = string.Empty;
                                                    if (tmpMaster.child_id != 0 && tmpMaster.product_id != tmpMaster.child_id)
                                                    {
                                                        _productMgr = new ProductMgr(connectionString);
                                                        Product tmpPro = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(tmpMaster.child_id) }).FirstOrDefault();
                                                        if (tmpPro != null)
                                                        {
                                                            childName = tmpPro.Product_Name;
                                                        }
                                                    }
                                                    string strSpec = itemPrice.spec_name_1 + (string.IsNullOrEmpty(itemPrice.spec_name_2) ? "" : (" + " + itemPrice.spec_name_2));

                                                    string title = siteName + " + " + userLevel + (string.IsNullOrEmpty(userMail) ? "" : (" + " + userMail))
                                                        + (string.IsNullOrEmpty(childName) ? "<br/>" : "<br/>子商品: " + childName)
                                                        + "<br/>" + strSpec;
                                                    if (strSpec == "")
                                                    {
                                                        title += "<br/>";
                                                    }
                                                    string top = "<div style=\"float:left\"><table style=\"width:180px;text-align:center;font-size: 13px;border:1px solid #99bce8;\"><caption style=\"text-align:center;border:1px solid #99bce8;\">" + title + "</caption><tr><td style=\"border:1px solid #99bce8;\">欄位名稱</td><td style=\"border:1px solid #99bce8;\">修改前</td><td style=\"border:1px solid #99bce8;\">修改后</td></tr>";//class=\"tbstyle\"
                                                    string bottom = "</table></div>";
                                                    string strContent = "<tr><td style=\"border:1px solid #99bce8;\">{0}</td><td class=\"red\" style=\"border:1px solid #99bce8;color:Red;\">{1}</td><td class=\"green\" style=\"border:1px solid #99bce8;color:green;\">{2}</td></tr>";
                                                    string content = notification.BuildContent(lastRec.batchno, tblName, id.ToString(), strContent, ref isAdd);
                                                    if (isAdd)
                                                    {
                                                        price.Append(top);
                                                        price.Append(content);
                                                        price.Append(bottom);
                                                    }
                                                }
                                            }
                                        }
                                        #endregion
                                        break;
                                    default:
                                        break;
                                }
                                #endregion
                            }
                            #region 批次拼接
                            StringBuilder batchHtml = new StringBuilder();
                            if (pro.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">商品信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", pro);
                            }
                            if (spec.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">規格信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", spec);
                            }
                            if (category.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">前臺分類信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", category);
                            }
                            if (item.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">商品細項信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", item);
                            }
                            if (master.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">站臺商品信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", master);
                            }
                            if (price.Length > 0)
                            {
                                batchHtml.AppendFormat("<tr><td style=\"border:1px solid #99bce8;\">站臺價格信息</td><td style=\"border:1px solid #99bce8;\">{0}</td></tr>", price);
                            };
                            if (batchHtml.Length > 0)
                            {
                                _productMgr = new ProductMgr(connectionString);
                                Product product = _productMgr.Query(new Product { Product_Id = Convert.ToUInt32(productId) }).FirstOrDefault();
                                if (product != null)
                                {
                                    string brand = string.Empty;
                                    vbMgr = new VendorBrandMgr(connectionString);
                                    VendorBrand vendorBrand = vbMgr.GetProductBrand(new VendorBrand { Brand_Id = product.Brand_Id });
                                    if (vendorBrand != null)
                                    {
                                        brand = vendorBrand.Brand_Name;
                                    }
                                    _historyBatchMgr = new HistoryBatchMgr(connectionString);
                                    HistoryBatch batch = _historyBatchMgr.Query(new HistoryBatch { batchno = lastRec.batchno });
                                    html.Append("<html><head><style type=\"text/css\">table{ font-size: 13px;border:1px solid #99bce8}td{border:1px solid #99bce8} .tbstyle{width:180px;text-align:center;} .red{color:Red;}.green{color:green;} caption{text-align:center;border:1px solid #99bce8}</style></head><body>");
                                    html.AppendFormat("<table style=\"font-size: 13px;border:1px solid #99bce8;\"><tr><td colspan='2' style=\"border:1px solid #99bce8;\">商品編號:<b>{0}</b>   品牌:<b>{1}</b></td></tr>", productId, brand);
                                    html.AppendFormat("<tr><td colspan='2' style=\"border:1px solid #99bce8;\"><b>{0}</b>  (修改人:{1}", product.Product_Name, batch.kuser);
                                    html.AppendFormat(",修改時間:{0})</td></tr>", batch.kdate.ToString("yyyy/MM/dd HH:mm:ss"));
                                    html.Append(batchHtml);
                                    html.Append("</table>");
                                    html.Append("</body></html>");
                                }
                            }
                            #endregion
                        }
                        result = "{success:true,html:'" + HttpUtility.HtmlEncode(html.ToString()) + "'}";
                    }
                    else
                    {
                        result = "{success:true,html:''}";
                    }
                }
            }
            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);
                result = "{success:true,html:''}";
            }
            this.Response.Clear();
            this.Response.Write(result);
            this.Response.End();
            return this.Response;
        }
 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;
 }