예제 #1
0
        public void SetProductID(int productID)
        {
            _productID = productID;
            dBPMan.ProductAnanytic.Clear();
            DBPManTableAdapters.ProductTableAdapter adt = new DBPManTableAdapters.ProductTableAdapter();
            adt.Connection.ConnectionString = Server.ConnectionString;
            DBPMan.ProductDataTable dt = new DBPMan.ProductDataTable();
            adt.FillBy_SelectOne(dt, productID);
            if (dt.Rows.Count > 0)
            {
                nameProduct = dt.Rows[0]["Name"].ToString();
            }
            adt.Dispose();
            dt.Dispose();



            this.product_KeyComparisonTableAdapter.FillBy_ProductID(dBPMan.Product_KeyComparison, productID);

            if (dBPMan.Product_KeyComparison.Rows.Count <= 0)
            {
                this.dBPMan.Product_KeyComparison.IDProductColumn.DefaultValue = productID;
                //this.dBPMan.Product_KeyComparison.IDKeySearchColumn.DefaultValue = 0;
                this.product_KeyComparisonBindingSource.AddNew();
                this.product_KeyComparisonBindingSource.EndEdit();
            }
            txttcode.Text = "";
        }
예제 #2
0
 private void InitData()
 {
     try
     {
         DBPManTableAdapters.ProductTableAdapter _productTableAdapter = new DBPManTableAdapters.ProductTableAdapter();
         _productTableAdapter.Connection.ConnectionString = QT.Entities.Server.ConnectionString;
         DBPMan.ProductDataTable productTable = new DBPMan.ProductDataTable();
         _productTableAdapter.FillBy_ID(productTable, _productId);
         if (productTable.Rows.Count != 0)
         {
             string imagepath = productTable.Rows[0]["ImagePath"].ToString();
             #region Kiểm tran ImagePath
             //nếu có ImagePath thì hiển thị ảnh
             #region Có ảnh
             if (!string.IsNullOrEmpty(imagepath))
             {
                 string imgurl = "http://img.websosanh.vn/" + imagepath;
                 pictureBoxProduct.ImageLocation = imgurl;
                 checkEditProduct.Checked        = true;
             }
             #endregion
             else
             {
                 #region Chưa có ảnh - kiểm tra ImageUrls -> Thực hiện download ảnh -> Tự upload ảnh đại diện
                 string imageurls = productTable.Rows[0]["ImageUrls"].ToString();
                 if (!string.IsNullOrEmpty(imageurls))
                 {
                     if (Common.UploadImageSPGoc(_productId, _nameProduct, imageurls))
                     {
                         labelControlProduct.Text = "Upload success!";
                     }
                     else
                     {
                         labelControlProduct.Text = "Upload fails!";
                     }
                 }
                 else
                 {
                     labelControlProduct.Text = "ImageUrls ko có. Upload ảnh trực tiếp!";
                 }
                 #endregion
             }
             #region Lấy MapCategory của Product để tạo thư mục
             int categoryId = QT.Entities.Common.Obj2Int(productTable.Rows[0]["CategoryID"].ToString());
             _mapcategoryProduct = GetFilterCategory(categoryId);
             #endregion
         }
         else
         {
             richTextBox1.Text = "Xảy ra lỗi, không tìm thấy sản phẩm trong Database!";
         }
         #endregion
     }
     catch (Exception ex)
     {
         richTextBox1.Text = ex.Message;
     }
 }
예제 #3
0
        void doUpdateTongView()
        {
            QT.Entities.Product_KeyComparison obj = new Product_KeyComparison();
            DBPMan.ProductDataTable           dt  = new DBPMan.ProductDataTable();
            if (chkAll.Checked == true)
            {
                this.productTableAdapter.FillBy_AllSPGocValid_orderByLastUpdate(dt, Common.GetIDCompany("quangtrung.vn"), DateTime.Now);
            }
            else
            {
                this.productTableAdapter.FillBy_CompanyID_Valid_Category(dt, Common.GetIDCompany("quangtrung.vn"), true, Common.Obj2Int(this.iDListClassificationTextBox.Text));
            }
            DBPManTableAdapters.Product_LogsTableAdapter adtLog = new DBPManTableAdapters.Product_LogsTableAdapter();
            adtLog.Connection.ConnectionString = QT.Entities.Server.ConnectionString;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                try
                {
                    int productid = 0;

                    productid = Common.Obj2Int(dt.Rows[i]["ID"].ToString());
                    int viewCount = 0;
                    try
                    {
                        viewCount = Common.Obj2Int(adtLog.ScalarQuery_SumCountByProductID_FromDate(productid, DateTime.Now.AddDays(-30)));
                    }
                    catch (Exception)
                    {
                    }
                    int delay = 1000;
                    this.Invoke(
                        (MethodInvoker) delegate
                    {
                        this.laMess1.Text = String.Format("Update thông tin view {0}/{1} sản phẩm: {2}\n Tổng: {3}\n ", i, dt.Rows.Count, dt.Rows[i]["Name"].ToString(),
                                                          viewCount);
                        delay = Common.Obj2Int(txtDelay.Text.Trim());
                    });
                    this.productTableAdapter.UpdateQuery_ViewCount(viewCount, productid);
                    Thread.Sleep(delay);
                }
                catch (Exception)
                {
                }
            }
            adtLog.Dispose();
            if (updateFulltextThread != null)
            {
                if (updateFulltextThread.IsAlive)
                {
                    updateFulltextThread.Abort();
                    updateFulltextThread.Join();
                    updateFulltextThread = null;
                }
            }
        }
예제 #4
0
        void doUpdateGiaSPGoc()
        {
            QT.Entities.Product_KeyComparison obj = new Product_KeyComparison();
            DBPMan.ProductDataTable           dt  = new DBPMan.ProductDataTable();
            while (true)
            {
                if (chkAll.Checked == true)
                {
                    this.productTableAdapter.FillBy_AllSPGocValid_orderByLastUpdate(dt, Common.GetIDCompany("quangtrung.vn"), DateTime.Now.AddDays(-1));
                }
                else
                {
                    this.productTableAdapter.FillBy_CompanyID_Valid_Category(dt, Common.GetIDCompany("quangtrung.vn"), true, Common.Obj2Int(this.iDListClassificationTextBox.Text));
                }
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    try
                    {
                        int productid = 0;

                        productid = Common.Obj2Int(dt.Rows[i]["ID"].ToString());
                        long idSPChuyenSPGoc = Common.Obj2Int64(dt.Rows[i]["ClassificationID"].ToString());
                        /// Update ProductID của những sản phẩm được chuyển sang làm sản phẩm gốc, ProductID=ClassificationID
                        this.productTableAdapter.UpdateQuery_ProductID(productid, idSPChuyenSPGoc);
                        Product_KeyComparisonEntyties oe = obj.UpdatePriceAndTongSP_ProductAndKeyComparision(productid);
                        int delay = 1000;
                        this.Invoke(
                            (MethodInvoker) delegate
                        {
                            this.laMess1.Text = String.Format("Update thông tin so sánh giá {0}/{1} sản phẩm: {2}\n Tổng: {3}\n PriceMin: {4}\n PriceMax: {5}", i, dt.Rows.Count, dt.Rows[i]["Name"].ToString(),
                                                              oe.TongSanPham, oe.PriceMin, oe.PriceMax);
                            delay = Common.Obj2Int(txtDelay.Text.Trim());
                        });
                        Thread.Sleep(delay);
                    }
                    catch (Exception)
                    {
                    }
                }
                if (updateFulltextThread != null)
                {
                    if (updateFulltextThread.IsAlive)
                    {
                        updateFulltextThread.Abort();
                        updateFulltextThread.Join();
                        updateFulltextThread = null;
                    }
                }
            }
        }
예제 #5
0
        private void btUpdateTopGiamGiaTuan_Click(object sender, EventArgs e)
        {
            QT.Entities.Product_KeyComparison obj = new Product_KeyComparison();
            DBPMan.ProductDataTable           dt  = new DBPMan.ProductDataTable();
            if (chkAll.Checked == true)
            {
                this.productTableAdapter.FillBy_AllSPGocValid_orderByLastUpdate(dt, Common.GetIDCompany("quangtrung.vn"), DateTime.Now);
            }
            else
            {
                this.productTableAdapter.FillBy_CompanyID_Valid_Category(dt, Common.GetIDCompany("quangtrung.vn"), true, Common.Obj2Int(this.iDListClassificationTextBox.Text));
            }
            DBPManTableAdapters.Price_LogsTableAdapter adtLog = new DBPManTableAdapters.Price_LogsTableAdapter();
            DBPMan.Price_LogsDataTable dtLog = new DBPMan.Price_LogsDataTable();
            adtLog.Connection.ConnectionString = QT.Entities.Server.ConnectionString;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int productid = 0;

                productid = Common.Obj2Int(dt.Rows[i]["ID"].ToString());
                int PriceChange = 0;
                try
                {
                    adtLog.FillBy_ProductIDFromDate(dtLog, productid, DateTime.Now.AddDays(-7));
                    if (dtLog.Rows.Count > 0)
                    {
                        DateTime dateUpdate = Common.ObjectToDataTime(dtLog.Rows[0]["DateUpdate"]);
                        if (dateUpdate < DateTime.Now.AddDays(-6))
                        {
                            int price0 = Common.Obj2Int(dtLog.Rows[0]["NewPrice"].ToString());
                            int pricen = Common.Obj2Int(dtLog.Rows[dtLog.Rows.Count - 1]["NewPrice"].ToString());
                            PriceChange = pricen - price0;
                        }
                    }
                }
                catch (Exception)
                {
                }

                this.productTableAdapter.UpdateQuery_PriceChangeWeek(PriceChange, productid);
                this.laMess1.Text = String.Format("Update giá giảm trong tuần {0}/{1} sản phẩm: {2}\n Tổng: {3}\n ", i, dt.Rows.Count, dt.Rows[i]["Name"].ToString(),
                                                  PriceChange);
                Application.DoEvents();
            }
            adtLog.Dispose();
        }
예제 #6
0
 private void btUpdateTinLienQuan_Click(object sender, EventArgs e)
 {
     #region update lại giá, tổng số sản phẩm tìm thấy trong dữ liệu
     QT.Entities.Product_KeyComparison obj = new Product_KeyComparison();
     DBPMan.ProductDataTable           dt  = new DBPMan.ProductDataTable();
     if (chkAll.Checked == true)
     {
         this.productTableAdapter.FillBy_AllSPGocValid_orderByLastUpdate(dt, Common.GetIDCompany("quangtrung.vn"), DateTime.Now);
     }
     else
     {
         this.productTableAdapter.FillBy_CompanyID_Valid_Category(dt, Common.GetIDCompany("quangtrung.vn"), true, Common.Obj2Int(this.iDListClassificationTextBox.Text));
     }
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         int productid = 0;
         productid = Common.Obj2Int(dt.Rows[i]["ID"].ToString());
         int tong = obj.UpdateProductIDTinLienQuan(productid);
         this.laMess1.Text = String.Format("Update tin liên quan {0}/{1} sản phẩm: {2}\n Tổng: {3}\n ", i, dt.Rows.Count, dt.Rows[i]["Name"].ToString(),
                                           tong);
         Application.DoEvents();
     }
     #endregion
 }
예제 #7
0
        private void btSiteMap_Click(object sender, EventArgs e)
        {
            DBPMan.ProductDataTable            dt           = new DBPMan.ProductDataTable();
            DBPMan.Product_PropertiesDataTable dtProperties = new DBPMan.Product_PropertiesDataTable();
            DBPManTableAdapters.Product_PropertiesTableAdapter adtProperties = new DBPManTableAdapters.Product_PropertiesTableAdapter();
            adtProperties.Connection.ConnectionString = Server.ConnectionString;
            this.productTableAdapter.FillBy_AllSPGocValid_orderByLastUpdate(dt, Common.GetIDCompany("quangtrung.vn"), DateTime.Now);
            String xml = "";

            xml += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
            xml += "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
            xml += "    <url>\n";
            xml += "        <loc>http://websosanh.vn/home.htm</loc>\n";
            xml += "        <changefreq>daily</changefreq>\n";
            xml += "        <priority>0.8</priority>\n";
            xml += "    </url>\n";
            string f = "";

            f += "    <url>\n";
            f += "        <loc>{0}</loc>\n";
            f += "        <changefreq>daily</changefreq>\n";
            f += "        <priority>0.8</priority>\n";
            f += "    </url>\n";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                long   id = 0;
                string name = "", url = "";
                id   = Common.Obj2Int64(dt.Rows[i]["ID"].ToString());
                name = dt.Rows[i]["Summary"].ToString();
                url  = Bussiness.UrlHelper.GetUrlOfProductIDSoSanh(id, name);
                xml += string.Format(f, url);
            }
            dt.Dispose();
            xml += "</urlset>\n";
            FileLog.WriteText(xml, "sitemap.xml");
        }
예제 #8
0
        /// <summary>
        /// Update lại thời gian cập nhật sản phẩm trên vật giá + giá thấp nhất so sánh trên vật giá
        /// thông tin id sản phẩm từ vật giá được lưu vào trường ClassificationID
        /// Update lại giá nhỏ nhất, tổng số sản phẩm tìm thấy trong dữ liệu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btUpdateGiaSPGoc_Click(object sender, EventArgs e)
        {
            DBPMan.ProductDataTable dt       = new DBPMan.ProductDataTable();
            DBPMan.ProductDataTable dtvatgia = new DBPMan.ProductDataTable();
            this.productTableAdapter.FillBy_CompanyID(dt, Common.GetIDCompany("quangtrung.vn"));
            #region Update lại thông tin trên vật giá
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                long productid = 0;
                productid = Common.Obj2Int64(dt.Rows[i]["ClassificationID"].ToString());
                if (productid == 0)
                {
                    productid = Common.GetIDProduct(dt.Rows[i]["DetailUrl"].ToString());
                }

                try
                {
                    this.productTableAdapter.FillBy_Price_LastUpdateByID(dtvatgia, productid);
                    int      price = 0;
                    DateTime dtpro = DateTime.Now;
                    if (dtvatgia.Rows.Count > 0)
                    {
                        price = Common.Obj2Int(dtvatgia.Rows[0]["Price"].ToString());
                        dtpro = Common.ObjectToDataTime(dtvatgia.Rows[0]["LastUpdate"]);
                    }
                    this.productTableAdapter.UpdateQuery_SPGoc(dtpro, price, productid, Common.Obj2Int64(dt.Rows[i]["ID"].ToString()));
                    this.laMess1.Text = String.Format("{0}/{1}", i, dt.Rows.Count);
                }
                catch (Exception ex)
                {
                    this.laMess1.Text = String.Format("Error {0}/{1}{2}", i, dt.Rows.Count, ex);
                }
                Application.DoEvents();
            }
            #endregion
        }
예제 #9
0
        //Không sử dụng nữa 02-12-2015
        void doUpdateFulltext()
        {
            DBPMan.ProductDataTable            dt           = new DBPMan.ProductDataTable();
            DBPMan.Product_PropertiesDataTable dtProperties = new DBPMan.Product_PropertiesDataTable();
            DBPManTableAdapters.Product_PropertiesTableAdapter adtProperties = new DBPManTableAdapters.Product_PropertiesTableAdapter();
            adtProperties.Connection.ConnectionString = Server.ConnectionString;
            if (chkAll.Checked == true)
            {
                this.productTableAdapter.FillBy_AllSPGocValid_orderByLastUpdate(dt, Common.GetIDCompany("quangtrung.vn"), DateTime.Now);
            }
            else
            {
                this.productTableAdapter.FillBy_CompanyID_Valid_Category(dt, Common.GetIDCompany("quangtrung.vn"), true, Common.Obj2Int(this.iDListClassificationTextBox.Text));
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                try
                {
                    long   id         = 0;
                    int    categoryID = 0;
                    string nameCat    = "";
                    id         = Common.Obj2Int64(dt.Rows[i]["ID"].ToString());
                    categoryID = Common.Obj2Int(dt.Rows[i]["CategoryID"].ToString());
                    var filter = GetFilterCategory(categoryID);
                    nameCat = dt.Rows[i]["CategoryName"].ToString();



                    //adtProperties.FillBy_FillterByProductID(dtProperties, id);

                    //foreach (DBPMan.Product_PropertiesRow dr in dtProperties)
                    //{
                    //    int proid = Common.Obj2Int(dr.PropertiesID);
                    //    int provalue = Common.Obj2Int(dr.PropertiesValueID);

                    //    filter += string.Format(" {0}_{1}", proid, provalue);
                    //}

                    //for (int ii = 0; ii < dtProperties.Rows.Count; ii++)
                    //{
                    //    int proid = Common.Obj2Int(dtProperties.Rows[ii]["PropertiesID"].ToString());
                    //    int provalue = Common.Obj2Int(dtProperties.Rows[ii]["PropertiesValueID"].ToString());

                    //    filter += string.Format(" {0}_{1}", proid, provalue);
                    //}
                    string nameFT    = Common.UnicodeToKoDauFulltext(dt.Rows[i]["Name"].ToString() + " " + nameCat) + " " + nameCat;
                    var    contentft = Common.UnicodeToKoDauFulltext(nameCat) + " " +
                                       filter;
                    if (contentft.Contains("c000"))
                    {
                        contentft = contentft;
                    }
                    this.productTableAdapter.UpdateQuery_ContentFT_NameFT_ByID(
                        contentft,
                        nameFT,
                        id);
                    int delay = 1000;
                    this.Invoke(
                        (MethodInvoker) delegate
                    {
                        this.laMess1.Text = String.Format("Update thông tin search {0}/{1} sản phẩm gốc: {2}\n ", i, dt.Rows.Count, dt.Rows[i]["Name"].ToString());
                        delay             = Common.Obj2Int(txtDelay.Text.Trim());
                    });

                    contentft = nameFT + " " + filter;
                    if (contentft.Contains("c000"))
                    {
                        contentft = contentft;
                    }
                    this.productTableAdapter.UpdateQuery_ContentFT_CategoryID_ByProductID(
                        contentft,
                        Common.Obj2Int(dt.Rows[i]["CategoryID"]),
                        Common.Obj2Int(id));
                    Thread.Sleep(delay);
                }
                catch (Exception ex)
                {
                    var error = ex.Message;
                    error += "";
                }
            }
            dt.Dispose();

            if (updateFulltextThread != null)
            {
                if (updateFulltextThread.IsAlive)
                {
                    updateFulltextThread.Abort();
                    updateFulltextThread.Join();
                    updateFulltextThread = null;
                }
            }
        }
예제 #10
0
        void doConvertSPGoc()
        {
            this.Invoke((MethodInvoker) delegate
            {
                this.lamssconvert.Text = "Start convert";
            });
            DBPManTableAdapters.ProductTableAdapter adtProduct = new DBPManTableAdapters.ProductTableAdapter();
            DBPMan.ProductDataTable dtP = new DBPMan.ProductDataTable();
            adtProduct.Connection.ConnectionString = Server.ConnectionString;
            int i = 0;

            foreach (DBMap.ProductRow dr in dBMap.Product)
            {
                //if (Common.Obj2Int64(dr.ProductID) <= 0)
                //{
                //insert to productid
                // vatgia
                if ((dBMap.Product.Rows[i]["ImageUrls"].ToString().Trim() != "")
                    //&& (dBMap.Product.Rows[i]["ProductContent"].ToString().Trim().Length > 10)
                    && (dBMap.Product.Rows[i]["ImageUrls"].ToString().Trim() != ""))
                {
                    int ID = Common.GetID_ProductID(dr.Name, IDCategory);
                    try
                    {
                        string name      = dr.Name.Replace("- Thông số kỹ thuật", "").Trim();
                        string contentft = Common.UnicodeToKoDauFulltext(name + " " + labelControlListIDSearch.Text);
                        if (adtProduct.Connection.State == ConnectionState.Closed)
                        {
                            adtProduct.Connection.Open();
                        }
                        try
                        {
                            /// check san pham nay da được tạo chưa
                            /// nếu chưa thì insert
                            /// đã có thì update lại thông số kỹ thuật
                            ///
                            dtP = new DBPMan.ProductDataTable();
                            adtProduct.FillBy_CheckID(dtP, ID);
                            if (dtP.Rows.Count > 0)
                            {
                                //adtProduct.UpdateQuery_SPGoc(
                                //    12,
                                //    Common.GetIDCompany("quangtrung.vn"),
                                //    DateTime.Now,
                                //    dBMap.Product.Rows[i]["ProductContent"].ToString(),
                                //    name,
                                //    dr.DetailUrl,
                                //    dr.ImageUrls,
                                //    Common.UnicodeToKoDauFulltext(name),
                                //    false,
                                //    Common.GetHashNameProduct("quangtrung.vn", name),
                                //    "",
                                //    IDCategory,
                                //    ID);
                            }
                            else
                            {
                                // chuyển sang làm sản phẩm gốc
                                adtProduct.InsertQuery_SPGoc(
                                    ID,
                                    Common.GetIDCompany("quangtrung.vn"),
                                    DateTime.Now,
                                    name,
                                    dBMap.Product.Rows[i]["ProductContent"].ToString(),
                                    name,
                                    dr.DetailUrl,
                                    dr.ImageUrls,
                                    Common.UnicodeToKoDauFulltext(name) + " " + NameCategory + " " + Common.UnicodeToKoDauFulltext(NameCategory),
                                    false,
                                    Common.GetHashNameProduct("quangtrung.vn", name),
                                    "",
                                    IDCategory,
                                    Common.Obj2Int(dBMap.Product.Rows[i]["Price"].ToString()),
                                    dr.ID,  // lưu product id vào trường classification vì productid chỉ là kiểu int
                                    contentft);
                                LogJobAdapter.SaveLog(JobName.FrmEditeProductByCat_Them_moi_san_pham_goc, "Thêm mới sản phẩm gốc MAP PRODUCT!", ID, (int)JobTypeData.Product);
                            }
                            dtP.Dispose();
                            List <PropertyEntyties> ls = new List <PropertyEntyties>();
                            ls = ContentAnalytic.GetListProperties(dBMap.Product.Rows[i]["ProductContent"].ToString().Trim(),
                                                                   dBMap.Product.Rows[i]["DetailUrl"].ToString().Trim());
                            ContentAnalytic.UpdateContent(ID, ls);
                        }
                        catch (Exception)
                        {
                            //  tên sản phẩm trong chuyên mục này đã có
                        }

                        // update lại sản phẩm vừa chuyển đã chuyển
                        adtProduct.UpdateQuery_ProductID(ID, dr.ID);
                    }
                    catch (Exception)
                    {
                    }
                    this.Invoke((MethodInvoker) delegate
                    {
                        this.lamssconvert.Text = string.Format("{0}/{1} - {2}", i, dBMap.Product.Count, dr.Name);
                    });
                    Application.DoEvents();
                    adtProduct.Connection.Close();
                    //String[] images = dBMap.Product.Rows[i++]["Promotion"].ToString().Split('\n');
                    //if ((images.Length > 0) && (images[0].Trim().Length > 0))
                    //{

                    //try
                    //{
                    //    adtID.Insert(
                    //    ID,
                    //    images[0].ToString(),
                    //    IDCategory,
                    //    0, 0, 0,
                    //    dr.ProductContent,
                    //    dr.DetailUrl,
                    //    dr.Name,
                    //    dr.NameFT,
                    //    Common.Obj2Int(Common.ProductIDStatus.NotValid));
                    //}
                    //catch (Exception)
                    //{

                    //}

                    //}
                }
                //}
                i++;
            }
        }