private void btDeleteTrungten_Click(object sender, EventArgs e) { DBTool2.View_SanPhamBiTrungDataTable dt = new DBTool2.View_SanPhamBiTrungDataTable(); DBTool2.ProductDataTable dtpro = new DBTool2.ProductDataTable(); DBTool2TableAdapters.View_SanPhamBiTrungTableAdapter adtViewTrung = new DBTool2TableAdapters.View_SanPhamBiTrungTableAdapter(); DBTool2TableAdapters.ProductTableAdapter adtPro = new DBTool2TableAdapters.ProductTableAdapter(); adtPro.Connection.ConnectionString = QT.Entities.Server.ConnectionString; adtViewTrung.Connection.ConnectionString = QT.Entities.Server.ConnectionString; adtViewTrung.Fill(dt); int j = 0; foreach (DBTool2.View_SanPhamBiTrungRow dr in dt) { try { adtPro.FillBy_Company_Name(dtpro, dr.Company, dr.Name); if (dtpro.Rows.Count > 1) { for (int i = 1; i < dtpro.Rows.Count; i++) { adtPro.DeleteQuery(QT.Entities.Common.Obj2Int64(dtpro.Rows[i]["ID"].ToString())); } } this.laMess1.Text = String.Format("Delete {0}/{1}", j, dt.Rows.Count); j++; Application.DoEvents(); } catch (Exception) { } } adtViewTrung.Dispose(); dt.Dispose(); adtPro.Dispose(); }
private void btUpdateSizeImage_Click(object sender, EventArgs e) { #region update search sản phẩm gốc DBTool2.ProductDataTable dtps = new DBTool2.ProductDataTable(); DBTool2TableAdapters.ProductTableAdapter adtps = new DBTool2TableAdapters.ProductTableAdapter(); adtps.Connection.ConnectionString = QT.Entities.Server.ConnectionString; adtps.FillByCategorySPGoc(dtps); for (int i = 0; i < dtps.Rows.Count; i++) { try { adtps.UpdateQuery_NameFT(QT.Entities.Common.UnicodeToKoDauFulltext(dtps.Rows[i]["Name"].ToString() + " " + dtps.Rows[i]["Category"].ToString()) + " " + dtps.Rows[i]["Category"].ToString(), QT.Entities.Common.Obj2Int64(dtps.Rows[i]["ID"].ToString())); this.laMess1.Text = String.Format("{0}/{1}", i, dtps.Rows.Count); } catch (Exception ex) { this.laMess1.Text = String.Format("Error {0}/{1}{2}", i, dtps.Rows.Count, ex); } Application.DoEvents(); } #endregion #region update size image //DBToolTableAdapters.ProductImagePathTableAdapter adt = new DBToolTableAdapters.ProductImagePathTableAdapter(); //adt.Connection.ConnectionString = Server.ConnectionString; //DBTool.ProductImagePathDataTable dt = new DBTool.ProductImagePathDataTable(); //adt.FillBy_ChuaUpdateWidth(dt); //for (int i = 0; i < dt.Rows.Count; i++) //{ // string path = "C:\\Windows\\Images\\" + dt.Rows[i]["ImagePath"].ToString().Replace("Store/","").Replace('/','\\'); // Bitmap thumbBitmap = null; // try // { // thumbBitmap = new Bitmap(path); // adt.UpdateQuery_WH(thumbBitmap.Width, thumbBitmap.Height, 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 }
void doUpdateLog() { int timeDelay = 0; //bool isMonth = true; this.Invoke((MethodInvoker) delegate { this.laMess1.Text = String.Format("Start download List Log"); //if (rdMonth.Checked) //{ isMonth = true; } //else //{ // isMonth = false; //} }); DBTool2.View_Product_Logs_IDDataTable dtLog = new DBTool2.View_Product_Logs_IDDataTable(); DBTool2.View_Product_Logs_IDDataTable dtLogWeek = new DBTool2.View_Product_Logs_IDDataTable(); DBTool2TableAdapters.View_Product_Logs_IDTableAdapter adtLog = new DBTool2TableAdapters.View_Product_Logs_IDTableAdapter(); DBTool2TableAdapters.ProductTableAdapter adtProduct = new DBTool2TableAdapters.ProductTableAdapter(); adtLog.Connection.ConnectionString = QT.Entities.Server.LogConnectionString; adtProduct.Connection.ConnectionString = QT.Entities.Server.ConnectionString; try { adtLog.Fill_ListLogFromDate(dtLog, DateTime.Now.AddDays(-30)); adtLog.Fill_ListLogFromDate(dtLogWeek, DateTime.Now.AddDays(-7)); } catch (Exception) { } int x = 0; ///UPDATE Product //SET ViewCount = @ViewCount //WHERE (ID = @Original_ID) Boolean checkZencode = false; string f = "UPDATE Product SET ViewCount = {0} WHERE (ID = {1})\n"; string sql = ""; this.Invoke((MethodInvoker) delegate { checkZencode = chkEdite.Checked; }); if (checkZencode) { foreach (DBTool2.View_Product_Logs_IDRow dr in dtLog) { sql += string.Format(f, dr.Tong, dr.IDProduct); x++; this.Invoke((MethodInvoker) delegate { this.laMess1.Text = String.Format("zencode {0}/{1} ViewCount= {2} ", x, dtLog.Count, dr.Tong); }); } this.Invoke((MethodInvoker) delegate { memoCode.Text = sql; }); } else { foreach (DBTool2.View_Product_Logs_IDRow dr in dtLogWeek) { try { adtProduct.UpdateQuery_ViewCountWeek(dr.Tong, dr.IDProduct); } catch (Exception) { } x++; this.Invoke((MethodInvoker) delegate { this.laMess1.Text = String.Format("Update Week {0}/{1} ViewCount= {2} ", x, dtLog.Count, dr.Tong); timeDelay = QT.Entities.Common.Obj2Int(this.txtTimeDelay.Text.Trim()); }); Thread.Sleep(timeDelay); } foreach (DBTool2.View_Product_Logs_IDRow dr in dtLog) { try { adtProduct.UpdateQuery_ViewCount(dr.Tong, dr.IDProduct); } catch (Exception) { } x++; this.Invoke((MethodInvoker) delegate { this.laMess1.Text = String.Format("Update Month {0}/{1} ViewCount= {2} ", x, dtLog.Count, dr.Tong); timeDelay = QT.Entities.Common.Obj2Int(this.txtTimeDelay.Text.Trim()); }); Thread.Sleep(timeDelay); } } this.Invoke((MethodInvoker) delegate { this.laMess1.Text = "Finish"; }); }