public void GetRootProductMinPriceAndNumProducts(long productID, out int minprice, out int numProducts) { Product_KeyComparisonEntyties obj = this.SelectByProductID(productID); minprice = 0; numProducts = 0; if (obj.Code != null) { if (obj.Code.Trim().Length <= 0) { return; } obj.InitKeyword(); var adt = new DBTableAdapters.ProductTableAdapter { Connection = { ConnectionString = Server.ConnectionString } }; var productAnalyticDataTable = new DB.ProductAnalyticDataTable(); var productAnalyticTableAdapter = new DBTableAdapters.ProductAnalyticTableAdapter(); productAnalyticTableAdapter.Connection.ConnectionString = Server.ConnectionString; productAnalyticTableAdapter.CMS_Product_SearchAnaytic_v2(productAnalyticDataTable, obj.PriceMin, obj.PriceMax, obj.codeContains, obj.codeLike, obj.codeLike1, obj.codeLike2, obj.codeLike3, obj.notCode, obj.notCodeLike, obj.notCodeLike1, obj.notCodeLike2, obj.notCodeLike3, 0); /// hiện thời đang không dùng đên idproduct sản phẩm gốc để check /// if (productAnalyticDataTable.Rows.Count > 0) { numProducts = productAnalyticDataTable.Rows.Count; minprice = Common.Obj2Int(productAnalyticDataTable.Rows[0]["Price"].ToString()); } productAnalyticDataTable.Dispose(); adt.Dispose(); productAnalyticTableAdapter.Dispose(); } }
public int UpdateProductIDTinLienQuan(int IDProduct) { int r = 0; Product_KeyComparisonEntyties obj = new Product_KeyComparisonEntyties(); obj = this.SelectByProductID(IDProduct); if (obj.Code != null) { if (obj.Code.Trim().Length <= 0) { return(0); } obj.InitKeyword(); DB.NewsDataTable dtNews = new DB.NewsDataTable(); DBTableAdapters.NewsTableAdapter adtNews = new DBTableAdapters.NewsTableAdapter(); adtNews.Connection.ConnectionString = QT.Entities.Server.ConnectionString; try { adtNews.FillBy_SearchAnalytic(dtNews, obj.codeContains, obj.codeLike, obj.codeLike1, obj.codeLike2, obj.codeLike3 ); } catch (Exception) { } if (dtNews.Rows.Count > 0) { for (int i = 0; i < dtNews.Rows.Count; i++) { int newsID = Common.Obj2Int(dtNews.Rows[i]["NewsID"]); try { adtNews.UpdateQuery_ProductID(IDProduct, newsID); } catch (Exception) { } } } r = dtNews.Rows.Count; dtNews.Dispose(); adtNews.Dispose(); //try //{ // DBTableAdapters.Product_KeyComparisonTableAdapter adtKey = new DBTableAdapters.Product_KeyComparisonTableAdapter(); // adtKey.Connection.ConnectionString = Server.ConnectionString; // adtKey.UpdateQuery_GiaSauPhanTich(tong, priceMin, priceMax, DateTime.Now, obj.GiaChenh, IDProduct); //} //catch (Exception) //{ // throw; //} } return(r); }
public Product_KeyComparisonEntyties UpdatePriceAndTongSP_ProductAndKeyComparision(long IDProduct) { Product_KeyComparisonEntyties obj = new Product_KeyComparisonEntyties(); obj = this.SelectByProductID(IDProduct); if (obj.Code != null) { if (obj.Code.Trim().Length <= 0) { return(obj); } obj.InitKeyword(); DBTableAdapters.ProductTableAdapter adt = new DBTableAdapters.ProductTableAdapter(); adt.Connection.ConnectionString = Server.ConnectionString; DB.ProductAnalyticDataTable dtAN = new DB.ProductAnalyticDataTable(); DBTableAdapters.ProductAnalyticTableAdapter adtAN = new DBTableAdapters.ProductAnalyticTableAdapter(); adtAN.Connection.ConnectionString = Server.ConnectionString; DBTableAdapters.Price_LogsTableAdapter adtPriceLog = new DBTableAdapters.Price_LogsTableAdapter(); adtPriceLog.Connection.ConnectionString = Server.ConnectionString; int priceMin = 0, priceMax = 0, tong = 0; try { adtAN.CMS_Product_SearchAnaytic_v2(dtAN, obj.PriceMin, obj.PriceMax, obj.codeContains, obj.codeLike, obj.codeLike1, obj.codeLike2, obj.codeLike3, obj.notCode, obj.notCodeLike, obj.notCodeLike1, obj.notCodeLike2, obj.notCodeLike3, 0); /// hiện thời đang không dùng đên idproduct sản phẩm gốc để check /// if (dtAN.Rows.Count > 0) { tong = dtAN.Rows.Count; priceMin = Common.Obj2Int(dtAN.Rows[0]["Price"].ToString()); priceMax = Common.Obj2Int(dtAN.Rows[tong - 1]["Price"].ToString()); if (dtAN.Rows.Count > 1) { obj.GiaChenh = Common.Obj2Int(dtAN.Rows[1]["Price"].ToString()) - priceMin; } else { obj.GiaChenh = 0; } /// Map lại toàn bộ product ID /// int proid = Common.Obj2Int(IDProduct); foreach (DB.ProductAnalyticRow dr in dtAN) { adt.UpdateQuery_ProductID(proid, dr.ID); } } // return xem log obj.TongSanPham = tong; obj.PriceMin = priceMin; obj.PriceMax = priceMax; } catch (Exception) { } try { adt.UpdateQuery_GiaSPGoc(priceMin, DateTime.Now, String.Format("Tìm thấy {0} sản phẩm", tong), IDProduct); if (priceMin > 0) { adtPriceLog.Insert(IDProduct, DateTime.Now, priceMin, 0); } } catch (Exception) { } try { DBTableAdapters.Product_KeyComparisonTableAdapter adtKey = new DBTableAdapters.Product_KeyComparisonTableAdapter(); adtKey.Connection.ConnectionString = Server.ConnectionString; adtKey.UpdateQuery_GiaSauPhanTich(tong, priceMin, priceMax, DateTime.Now, obj.GiaChenh, IDProduct); } catch (Exception) { } dtAN.Dispose(); adt.Dispose(); adtAN.Dispose(); adtPriceLog.Dispose(); } return(obj); }