Ejemplo n.º 1
0
 public List<ProductComboCustomVendor> combQueryByVendor(ProductComboCustomVendor query)
 {
     try
     {
         return _tempDao.combQueryByVendor(query);
     }
     catch (Exception ex)
     {
         throw new Exception("ProductComboTempMgr.combQueryByVendor-->" + ex.Message, ex);
     }
 }
 public HttpResponseBase combSpecQuery()
 {
     string json = "{success:true}";
     try
     {
         int pileId = 0;
         int.TryParse(Request.Params["pileId"] ?? "0", out pileId);
         string parentId = string.Empty;
         _combTempMgr = new ProductComboTempMgr(connectionString);
         if (!string.IsNullOrEmpty(Request.Params["ProductId"]))
         {
             parentId = Request.Params["ProductId"];
         }
         ProductComboCustomVendor query = new ProductComboCustomVendor { Pile_Id = pileId, create_channel = 2, temp_status = 12, Parent_Id = parentId };
         json = "{success:true,data:" + JsonConvert.SerializeObject(_combTempMgr.combQueryByVendor(query)) + "}";
     }
     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);
     }
     Response.Clear();
     Response.Write(json);
     Response.End();
     return this.Response;
 }
        public HttpResponseBase combSpecQuery()
        {
            string json = "{success:false}";
            try
            {
                int pileId = 0;
                int.TryParse(Request.Params["pileId"] ?? "0", out pileId);
                uint parentId = 0;

                BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
                int writer_id = Convert.ToInt32(vendorModel.vendor_id);
                if (!string.IsNullOrEmpty(Request.Params["ProductId"]))
                {
                    if (uint.TryParse(Request.Params["ProductId"].ToString(), out parentId))
                    {
                        _combMgr = new ProductComboMgr(connectionString);
                        json = "{success:true,data:" + JsonConvert.SerializeObject(_combMgr.combQuery(new ProductComboCustom { Parent_Id = int.Parse(Request.Params["ProductId"]), Pile_Id = pileId })) + "}";

                    }
                    else
                    {
                        _combTempMgr = new ProductComboTempMgr(connectionString);
                        ProductComboCustomVendor query = new ProductComboCustomVendor { Writer_Id = writer_id, Pile_Id = pileId, create_channel = 2, temp_status = 12, Parent_Id = Request.Params["ProductId"] };
                        json = "{success:true,data:" + JsonConvert.SerializeObject(_combTempMgr.combQueryByVendor(query)) + "}";
                    }
                }
            }
            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);
            }

            Response.Clear();
            Response.Write(json);
            Response.End();
            return this.Response;
        }
Ejemplo n.º 4
0
        public List<ProductComboCustomVendor> combQueryByVendor(ProductComboCustomVendor query)
        {
            StringBuilder sql = new StringBuilder();
            try
            {
                //子商品為正式單一商品時
                StringBuilder productSql = new StringBuilder();
                productSql.Append("select c.child_id ,p.product_name,p.prod_sz,p.brand_id,c.s_must_buy, ");
                productSql.Append("c.g_must_buy,c.pile_id,c.buy_limit from product p ");
                productSql.Append(" inner join product_combo_temp c  on p.product_id = c.child_id where 1=1");

                if (query.Writer_Id != 0)
                {
                    productSql.AppendFormat(" and c.writer_id = {0}", query.Writer_Id);
                }
                if (query.Pile_Id != 0)
                {
                    productSql.AppendFormat(" and c.pile_id = {0}", query.Pile_Id);
                }
                if (!string.IsNullOrEmpty(query.Parent_Id))
                {
                    productSql.AppendFormat(" and parent_id='{0}' ", query.Parent_Id);
                }

                //子商品為供應商新建立的已經完成的單一商品時
                StringBuilder productTempSql = new StringBuilder();
                productTempSql.Append("select ct.child_id  ,pt.product_name,pt.prod_sz,pt.brand_id,ct.s_must_buy, ");
                productTempSql.Append("ct.g_must_buy,ct.pile_id,ct.buy_limit from product_temp pt  ");
                productTempSql.Append("  inner join product_combo_temp ct  on pt.product_id = ct.child_id  where 1=1 ");

                if (query.Writer_Id != 0)
                {
                    productTempSql.AppendFormat(" and ct.writer_id = {0}", query.Writer_Id);
                }
                if (query.Pile_Id != 0)
                {
                    productTempSql.AppendFormat(" and ct.pile_id = {0}", query.Pile_Id);
                }
                if (query.create_channel != 0)
                {
                    productTempSql.AppendFormat(" and pt.create_channel = {0}", query.create_channel);
                }
                if (query.temp_status != 0)
                {
                    productTempSql.AppendFormat(" and pt.temp_status = {0}", query.temp_status);
                }
                if (!string.IsNullOrEmpty(query.Parent_Id))
                {
                    productTempSql.AppendFormat(" and parent_id='{0}' ", query.Parent_Id);
                }

                sql.Append("(" + productSql + ")" + " UNION " + "(" + productTempSql + ")");

                return _access.getDataTableForObj<ProductComboCustomVendor>(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("ProductComboTempDao-->combQueryByVendor-->" + ex.Message + sql.ToString(), ex);
            }
        }