예제 #1
0
        private void UpdateSauKhiCheckProduct(int count)
        {
            try
            {
                DBCom.ProductDataTable dt = new DBCom.ProductDataTable();
                this.productTableAdapter.FillBy_TongValidCompany(dt, CompanyID);

                DBComTableAdapters.CompanyTableAdapter adt = new DBComTableAdapters.CompanyTableAdapter();
                adt.Connection.ConnectionString = Server.ConnectionString;
                adt.UpdateQuery_LastCheckValid(DateTime.Now, dt.Rows.Count, CompanyID);
                UpdateLog(string.Format("{0}", count));
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        void download()
        {
            finish = false;
            this.Invoke((MethodInvoker) delegate
            {
                this.dataNavigator1.Visible = false;
                this.lamess.Visible         = true;
                lamess.Text = "Đang tải dữ liệu...";
            });
            if (_connection == "")
            {
                _connection = QT.Entities.Server.ConnectionString;
                this.productTableAdapter.Connection.ConnectionString     = _connection;
                this.viewProductTableAdapter.Connection.ConnectionString = _connection;
            }
            DBCom.ProductDataTable dt = new DBCom.ProductDataTable();
            if (chkViewAllWeb.Checked)
            {
                this.productTableAdapter.Product_SelectByCompanyID_Valid(dt, 0, this.chkValid.Checked, Common.Obj2Int(this.txtPage.Text), Common.Obj2Int(this.txtCount.Text));
            }
            else
            {
                this.productTableAdapter.Product_SelectByCompanyID_Valid(dt, _companyID, this.chkValid.Checked, Common.Obj2Int(this.txtPage.Text), Common.Obj2Int(this.txtCount.Text));
            }
            //String f = "", fcontent = "";

            //f = " <div style='float: left;'>"
            //    + "      <img width='50px' height='50px' src='{0}'></img>"
            //    + "</div>";

            //fcontent = "<div style='float: left;'>"
            //    + "  <p style='padding:0px; margin:0px;'>{0}</p>"
            //    + "  <p style='padding:0px; margin:0px;'>Giá {1}</p>"
            //    + "</div>";
            String image      = "";
            int    ImageWidth = 140;
            string ImagePath  = "";
            var    webClient  = new WebClient();

            byte[] imageBytes = null;
            int    i          = 0;

            foreach (DBCom.ProductRow dr in dt)
            {
                if (chkImage.Checked)
                {
                    image     = "";
                    ImagePath = dt.Rows[i]["ImagePath"].ToString();
                    image     = Common.GetImage(ImagePath, ImageWidth);
                    if (string.IsNullOrEmpty(image))
                    {
                        i++;
                        dr.Valid = false;
                        continue;
                    }
                    try
                    {
                        imageBytes      = webClient.DownloadData(image);
                        dr.ImageBit     = imageBytes;
                        dr.DisplayImage = "1";
                        dr.Valid        = true;
                        if (CompanyID != Common.GetIDCompany("quangtrung.vn"))
                        {
                            if ((dr.Price < 1000) || (dr.Price > 800000000))
                            {
                                dr.Valid = false;
                            }
                        }
                        else
                        {
                            if (dr.Status != 11)
                            {
                                dr.Valid = false;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        dr.ImageBit     = imageBytes404;
                        dr.DisplayImage = "0";
                        dr.Valid        = false;
                    }
                }
                else
                {
                    if (Common.Obj2Int(dt.Rows[i]["ImageWidth"].ToString()) > 100)
                    {
                        dr.Valid = true;
                    }
                    else
                    {
                        dr.Valid = false;
                    }
                }
                //if (dr.Status > 11)
                //{
                //    dr.Valid = false;
                //}
                //dr.DisplayImage = string.Format(f, image);
                //dr.DisplayContent = string.Format(fcontent, dr.Name, String.Format("{0:N0}", dr.Price));
                i++;
            }
            webClient.Dispose();

            this.Invoke((MethodInvoker) delegate
            {
                lamess.Text = "Đã tải xong dữ liệu";
                this.dBCom.Product.Clear();
                this.dBCom.Product.Merge(dt);
                this.dataNavigator1.Visible = true;
                this.lamess.Visible         = false;
                this.gridControl1.Focus();
            });

            finish = true;
            if (tDownload != null)
            {
                if (tDownload.IsAlive)
                {
                    tDownload.Abort();
                    tDownload.Join();
                    tDownload = null;
                }
            }
        }