public void CertifyCount(int?id)
 {
     #region Certify
     svCompany = new CompanyService();
     string sqlSelectCertify = "CompCertifyID,CompID,CompName,CertifyName,CertifyImgPath";
     string sqlWhereCertify  = "IsDelete = 0 AND CompID =" + id;
     var    certify          = svCompany.CountData <view_CompanyCertify>(sqlSelectCertify, sqlWhereCertify);
     ViewBag.CertifyCount = certify;
     #endregion
 }
        public ActionResult B2BToday()
        {
            var svProduct = new ProductService();
            var svBuylead = new BuyleadService();
            var svCompany = new CompanyService();

            var sqlWhere = svProduct.CreateWhereAction(ProductAction.FrontEnd);

            string CountProduct = svProduct.CountData <view_SearchProduct>("ProductID", sqlWhere).ToString("#,##0");

            sqlWhere  = svProduct.CreateWhereAction(ProductAction.FrontEnd);
            sqlWhere += " And CateLV1=7102";
            string Countsoftware = svProduct.CountData <view_SearchProduct>("ProductID", sqlWhere).ToString("#,##0");

            sqlWhere  = svCompany.CreateWhereAction(CompStatus.HaveProduct);
            sqlWhere += svCompany.CreateWhereServiceType(3);
            string CountSupplier = svCompany.CountData <b2bCompany>("CompID", sqlWhere).ToString("#,##0");

            return(Json(new { ProductAll = CountProduct, SupplierAll = CountSupplier, SoftwareAll = Countsoftware }));
        }
        public int DefaultWebsite(int id, string page)
        {
            svCompany = new CompanyService();
            string sqlWhere  = string.Empty;
            string sqlSelect = "CompID,CompName,CompCode,CompLevel,emCompID,LogoImgPath,CompWebsiteTemplate,ViewCount,ProductCount,CompHistory,IsOnline,CompAddrLine1,CompPhone,ProvinceName,CreatedDate";

            if (LogonRowFlag == 3)
            {
                sqlWhere = svCompany.CreateWhereAction(CompStatus.All, id);
            }
            else
            {
                sqlWhere = svCompany.CreateWhereAction(CompStatus.Online, id);
            }
            var countcompany = svCompany.CountData <view_Company>(sqlSelect, sqlWhere);

            if (countcompany > 0)
            {
                AddViewCount(id, "Supplier");
                ViewBag.LogonCompID = LogonCompID;
                var company = svCompany.SelectData <view_Company>(sqlSelect, sqlWhere).First();
                ViewBag.WebCompID       = company.CompID;
                ViewBag.WebCompName     = company.CompName;
                ViewBag.CompCode        = company.CompCode;
                ViewBag.WebCompLevel    = company.CompLevel;
                ViewBag.WebLogoImgPath  = company.LogoImgPath;
                ViewBag.Template        = company.CompWebsiteTemplate;
                ViewBag.WebEmCompID     = company.emCompID;
                ViewBag.PageAction      = page;
                ViewBag.title           = company.CompName + " | " + company.ProvinceName + " | " + res.Common.lblDomainShortName;
                ViewBag.ViewCount       = company.ViewCount;
                ViewBag.WebCompHistory  = company.CompHistory;
                ViewBag.IsOnline        = company.IsOnline;
                ViewBag.MetaDescription = company.CompName + " | " + company.CompAddrLine1 + " | " + company.ProvinceName + " | " + company.CompPhone;
                ViewBag.MetaKeyword     = ViewBag.title;
                ProductCount(ViewBag.WebCompID);
                BlogCount(ViewBag.WebCompID);
                if (ViewBag.WebCompLevel == 3)
                {
                    OrderCount(ViewBag.WebCompID);
                    CertifyCount(ViewBag.WebCompID);
                    JobCount(ViewBag.WebEmCompID);
                }

                SetStatusWebsite((int)company.CompID, company.CompName);

                var SettingMenu = svCompany.SelectData <b2bCompanyMenu>("*", "IsDelete = 0  and CompID = " + id, "ListNo ASC");
                if (SettingMenu.Count == 0)
                {
                    SettingMenu = svCompany.SelectData <b2bCompanyMenu>("*", "IsDelete = 0 and IsDefaultMenu = 1 and IsShow = 1", "ListNo ASC");
                }
                else
                {
                    var where = "IsDelete = 0 and ([IsDefaultMenu] = 1 ";
                    foreach (var list in SettingMenu)
                    {
                        where += " or (FromMenuID = " + list.FromMenuID + " AND CompID = " + id + " AND IsShow = 1)";
                    }
                    where += ")";
                    foreach (var list in SettingMenu)
                    {
                        where += "AND CompMenuID != " + list.FromMenuID;
                    }
                    SettingMenu = svCompany.SelectData <b2bCompanyMenu>("*", where, "ListNo ASC");
                }

                ViewBag.SettingMenu = SettingMenu;
            }
            return(countcompany);
        }
Esempio n. 4
0
        public ActionResult B2BToday()
        {
            var svProduct = new ProductService();
            var svBuylead = new BuyleadService();
            var svCompany = new CompanyService();

            string CountProduct, Countsoftware, CountCentral, CountWest, CountNorth, CountNortheast, CountSouth, CountEast, CountSupplier = "";

            var HomeCountProduct   = "HomeCountProduct";
            var HomeCountsoftware  = "HomeCountsoftware";
            var HomeCountCentral   = "HomeCountCentral";
            var HomeCountWest      = "HomeCountWest";
            var HomeCountNorth     = "HomeCountNorth";
            var HomeCountNortheast = "HomeCountNortheast";
            var HomeCountSouth     = "HomeCountSouth";
            var HomeCountEast      = "HomeCountEast";
            var HomeCountSupplier  = "HomeCountSupplier";

            var sqlWhere = svProduct.CreateWhereAction(ProductAction.FrontEnd);

            if (MemoryCache.Default[HomeCountProduct] != null)
            {
                CountProduct = (string)MemoryCache.Default[HomeCountProduct];
            }
            else
            {
                CountProduct = svProduct.CountData <view_SearchProduct>("ProductID", sqlWhere).ToString("#,##0");
                if (CountProduct != "" || CountProduct != null)
                {
                    MemoryCache.Default.Add(HomeCountProduct, CountProduct, DateTime.Now.AddHours(2));
                }
            }

            if (MemoryCache.Default[HomeCountsoftware] != null)
            {
                Countsoftware = (string)MemoryCache.Default[HomeCountsoftware];
            }
            else
            {
                sqlWhere      = svProduct.CreateWhereAction(ProductAction.FrontEnd);
                sqlWhere     += " And CateLV1=7102";
                Countsoftware = svProduct.CountData <view_SearchProduct>("ProductID", sqlWhere).ToString("#,##0");
                if (Countsoftware != "" || Countsoftware != null)
                {
                    MemoryCache.Default.Add(HomeCountsoftware, Countsoftware, DateTime.Now.AddHours(2));
                }
            }

            if (MemoryCache.Default[HomeCountCentral] != null)
            {
                CountCentral = (string)MemoryCache.Default[HomeCountCentral];
            }
            else
            {
                sqlWhere     = svProduct.CreateWhereAction(ProductAction.FrontEnd);
                sqlWhere    += " And RegionID=1";
                CountCentral = svProduct.CountData <view_SearchProduct>("ProductID", sqlWhere).ToString("#,##0");
                if (CountCentral != "" || CountCentral != null)
                {
                    MemoryCache.Default.Add(HomeCountCentral, CountCentral, DateTime.Now.AddHours(2));
                }
            }

            if (MemoryCache.Default[HomeCountWest] != null)
            {
                CountWest = (string)MemoryCache.Default[HomeCountWest];
            }
            else
            {
                sqlWhere  = svProduct.CreateWhereAction(ProductAction.FrontEnd);
                sqlWhere += " And RegionID=2";
                CountWest = svProduct.CountData <view_SearchProduct>("ProductID", sqlWhere).ToString("#,##0");
                if (CountWest != "" || CountWest != null)
                {
                    MemoryCache.Default.Add(HomeCountWest, CountWest, DateTime.Now.AddHours(2));
                }
            }

            if (MemoryCache.Default[HomeCountNorth] != null)
            {
                CountNorth = (string)MemoryCache.Default[HomeCountNorth];
            }
            else
            {
                sqlWhere   = svProduct.CreateWhereAction(ProductAction.FrontEnd);
                sqlWhere  += " And RegionID=3";
                CountNorth = svProduct.CountData <view_SearchProduct>("ProductID", sqlWhere).ToString("#,##0");
                if (CountNorth != "" || CountNorth != null)
                {
                    MemoryCache.Default.Add(HomeCountNorth, CountNorth, DateTime.Now.AddHours(2));
                }
            }

            if (MemoryCache.Default[HomeCountNortheast] != null)
            {
                CountNortheast = (string)MemoryCache.Default[HomeCountNortheast];
            }
            else
            {
                sqlWhere       = svProduct.CreateWhereAction(ProductAction.FrontEnd);
                sqlWhere      += " And RegionID=4";
                CountNortheast = svProduct.CountData <view_SearchProduct>("ProductID", sqlWhere).ToString("#,##0");
                if (CountNortheast != "" || CountNortheast != null)
                {
                    MemoryCache.Default.Add(HomeCountNortheast, CountNortheast, DateTime.Now.AddHours(2));
                }
            }

            if (MemoryCache.Default[HomeCountSouth] != null)
            {
                CountSouth = (string)MemoryCache.Default[HomeCountSouth];
            }
            else
            {
                sqlWhere   = svProduct.CreateWhereAction(ProductAction.FrontEnd);
                sqlWhere  += " And RegionID=5";
                CountSouth = svProduct.CountData <view_SearchProduct>("ProductID", sqlWhere).ToString("#,##0");
                if (CountSouth != "" || CountSouth != null)
                {
                    MemoryCache.Default.Add(HomeCountSouth, CountSouth, DateTime.Now.AddHours(2));
                }
            }

            if (MemoryCache.Default[HomeCountEast] != null)
            {
                CountEast = (string)MemoryCache.Default[HomeCountEast];
            }
            else
            {
                sqlWhere  = svProduct.CreateWhereAction(ProductAction.FrontEnd);
                sqlWhere += " And RegionID=6";
                CountEast = svProduct.CountData <view_SearchProduct>("ProductID", sqlWhere).ToString("#,##0");
                if (CountEast != "" || CountEast != null)
                {
                    MemoryCache.Default.Add(HomeCountEast, CountEast, DateTime.Now.AddHours(2));
                }
            }

            if (MemoryCache.Default[HomeCountSupplier] != null)
            {
                CountSupplier = (string)MemoryCache.Default[HomeCountSupplier];
            }
            else
            {
                sqlWhere      = svCompany.CreateWhereAction(CompStatus.HaveProduct);
                sqlWhere     += svCompany.CreateWhereServiceType(3);
                CountSupplier = svCompany.CountData <b2bCompany>("CompID", sqlWhere).ToString("#,##0");
                if (CountSupplier != "" || CountSupplier != null)
                {
                    MemoryCache.Default.Add(HomeCountSupplier, CountSupplier, DateTime.Now.AddHours(2));
                }
            }

            return(Json(new { ProductAll = CountProduct, SupplierAll = CountSupplier, SoftwareAll = Countsoftware, Central = CountCentral, West = CountWest, North = CountNorth, Northeast = CountNortheast, South = CountSouth, East = CountEast }));
        }
Esempio n. 5
0
        public ActionResult Contact(int?ToCompID, string ProductID, string type, string BuyleadID)
        {
            if (RedirectToProduction())
            {
                return(Redirect(UrlProduction));
            }

            CommonService svCommon = new CommonService();

            #region Company Info
            if (ToCompID > 0)
            {
                svCompany = new CompanyService();
                string sqlSelect    = "CompID,CompName,ContactEmail,CompPhone";
                string sqlWhere     = svCompany.CreateWhereAction(CompStatus.Online, ToCompID);
                var    countcompany = svCompany.CountData <view_Company>(sqlSelect, sqlWhere);
                if (countcompany > 0)
                {
                    var company = svCompany.SelectData <view_Company>(sqlSelect, sqlWhere).First();
                    ViewBag.Company  = company;
                    ViewBag.CompName = company.CompName;
                }
                else
                {
                    return(Redirect("~/Default/NotFound"));
                }
            }
            #endregion

            #region Load Feature
            var feature = new List <view_HotFeaProduct>();
            if (MemoryCache.Default["LoadFeatureMessage"] != null)
            {
                feature = (List <view_HotFeaProduct>)MemoryCache.Default["LoadFeatureMessage"];
                feature = feature.OrderBy(x => Guid.NewGuid()).ToList();
                feature = feature.OrderByDescending(m => m.HotPrice).ToList();
            }
            else
            {
                var svHotFeat      = new HotFeaProductService();
                var SQLSelect_Feat = "";

                SQLSelect_Feat = " ProductID,ProductName,CompID,ProductImgPath,ProRowFlag,CompRowFlag,ProvinceName,Price,Ispromotion,PromotionPrice,HotPrice";
                feature        = svHotFeat.SelectHotProduct <view_HotFeaProduct>(SQLSelect_Feat, "Rowflag = 3 AND Status = 'P' AND ProductID > 0 AND ProRowFlag in(4) AND CompRowFlag in(2,4) AND ProductDelete = 0", "NEWID(),HotPrice DESC", 1, 3);//""
                if (svHotFeat.TotalRow > 0)
                {
                    MemoryCache.Default.Add("LoadFeatureMessage", feature, DateTime.Now.AddMinutes(10));
                }
            }
            ViewBag.FeatProducts = feature;
            #endregion

            #region Product
            if (!string.IsNullOrEmpty(ProductID))
            {
                svProduct = new ProductService();

                #region Set Cookie ProductID
                Response.Cookies["MsgContactProID"].Value   = ProductID;
                Response.Cookies["MsgContactProID"].Expires = DateTime.Now.AddHours(1);
                #endregion

                string[] strProductID = ProductID.Split(',');
                string   WhereIN      = CreateWhereIN(strProductID, "ProductID");
                var      product      = svProduct.SelectData <b2bProduct>("ProductID,ProductName", WhereIN + " AND IsDelete = 0");
                ViewBag.ProductID = product;
                if (svProduct.TotalRow > 0)
                {
                    ViewBag.Title      = "ติดต่อผู้ขายสินค้า " + product.First().ProductName + ", " + ViewBag.CompName + " – B2Bthai.com";
                    ViewBag.PronameUrl = @Url.ReplaceUrl(product.First().ProductName);
                }
                ViewBag.chkProductID = 1;
            }
            else
            {
                ViewBag.chkProductID = 0;
                ViewBag.Title        = "ติดต่อบริษัท" + ViewBag.CompName + " – B2Bthai.com";
                Response.Cookies["MsgContactProID"].Value   = null;
                Response.Cookies["MsgContactProID"].Expires = DateTime.Now.AddHours(1);
            }
            #endregion

            #region Buylead
            if (!string.IsNullOrEmpty(BuyleadID))
            {
                svBuylead = new BuyleadService();

                #region Set Cookie ProductID
                Response.Cookies["MsgContactBuyID"].Value   = BuyleadID;
                Response.Cookies["MsgContactBuyID"].Expires = DateTime.Now.AddHours(1);
                #endregion

                string[] strBuyleadID = BuyleadID.Split(',');
                string   WhereIN      = CreateWhereIN(strBuyleadID, "BuyleadID");
                var      buylead      = svBuylead.SelectData <b2bBuylead>("BuyleadID,BuyleadName,BuyleadEmail,BuyleadCompanyName", WhereIN + " AND IsDelete = 0");
                ViewBag.BuyleadID = buylead;
                if (svBuylead.TotalRow > 0)
                {
                    ViewBag.Title      = "ติดต่อผู้ประกาศซื้อสินค้า " + buylead.First().BuyleadName + ", " + buylead.First().BuyleadCompanyName + " – B2Bthai.com";
                    ViewBag.BuynameUrl = @Url.ReplaceUrl(buylead.First().BuyleadName);
                }
                ViewBag.chkBuyleadID = 1;
            }
            else
            {
                ViewBag.chkBuyleadID = 0;
                ViewBag.Title        = "ติดต่อบริษัท" + ViewBag.CompName + " – B2Bthai.com";
                Response.Cookies["MsgContactBuyID"].Value   = null;
                Response.Cookies["MsgContactBuyID"].Expires = DateTime.Now.AddHours(1);
            }
            #endregion

            #region check message type
            if (type == "SendtoFriend")
            {
                ViewBag.chkSendToFriend = 1;
                ViewBag.Title           = "ส่งรายละเอียดให้เพื่อน " + ViewBag.CompName + " – B2Bthai.com";
            }
            else
            {
                ViewBag.chkSendToFriend = 0;
            }
            #endregion

            ViewBag.EnumServiceType = svCommon.SelectEnum(CommonService.EnumType.SearchByServiceType);
            GetStatusUser();
            ViewBag.MetaKeyword     = ViewBag.Title;
            ViewBag.MetaDescription = ViewBag.Title;
            return(View());
        }