public ActionResult Detail(int?ID)
        {
            if (RedirectToProduction())
            {
                return(Redirect(UrlProduction));
            }
            GetStatusUser();
            #region รายละเอียดประกาศซื้อ
            svBuylead = new BuyleadService();
            var Buyleads = svBuylead.SelectData <view_BuyLead>("*", "BuyleadID = " + ID, null, 1, 0);

            if (svBuylead.TotalRow == 0)
            {
                return(Redirect("~/Default/NotFound"));
            }

            var buylead = Buyleads.First();
            ViewBag.BuyleadDetail = buylead;
            if (buylead.ProvinceName == "กรุงเทพมหานคร")
            {
                buylead.ProvinceName = "กรุงเทพ";
            }
            ViewBag.Title = buylead.BuyleadName + " | " + buylead.ProvinceName;

            if (!string.IsNullOrEmpty(buylead.BuyleadKeyword))
            {
                ViewBag.Title += buylead.BuyleadKeyword.Replace("~", " ");
            }
            ViewBag.Title          += " | " + res.Product.lblBuyleadList + " | " + res.Common.lblDomainShortName;
            ViewBag.MetaKeyword     = ViewBag.Title;
            ViewBag.MetaDescription = ViewBag.Title;
            #endregion

            //#region ผู้ขายสินค้าประเภทนี้
            //ViewBag.Buyer = svBuylead.SelectData<view_PurchaseComp>("*", "CateLV3 IN (" + buylead.CateLV3 + ") AND RowFlag IN(2,4) AND ProductCount > 0", "CompID", 1, 7);
            //#endregion

            //#region สินค้าที่เกี่ยวข้องกับประกาศซื้อ
            //var svProduct = new ProductService();
            //SqlWhere = svProduct.CreateWhereAction(ProductAction.FrontEnd, 0);
            //SqlWhere += " AND (CateLV3  = " + buylead.CateLV3 + ") AND (ProductImgPath <> '') ";
            //ViewBag.ProductOther = svProduct.SelectData<view_Product>("ProductID,ProductImgPath,CompID,ProductName,CateLV3,IsDelete,RowFlag,CompRowFlag,IsShow,IsJunk", SqlWhere, "ProductID", 1, 7);
            //#endregion

            #region ประกาศซื้อใกล้เคียง
            SqlWhere           = svBuylead.CreateWhereAction(BuyleadAction.FrontEnd);
            SqlWhere          += " AND CateLV3 = " + buylead.CateLV3 + " AND BuyleadID != " + ID;
            ViewBag.BuyerOther = svBuylead.SelectData <view_BuyLead>("*", SqlWhere, "BuyleadID", 1, 5);
            #endregion

            CommonService svCommon = new CommonService();
            ViewBag.EnumServiceType      = svCommon.SelectEnum(CommonService.EnumType.SearchByServiceType);
            ViewBag.EnumSearchByPurchase = svCommon.SelectEnum(CommonService.EnumType.SearchByPurchase);
            AddViewCount((int)ID, "Buylead");
            return(View());
        }
Exemplo n.º 2
0
        public void List_DoloadData(BuyleadAction action)
        {
            ViewBag.PageSize = 19;
            var svBuylead = new BuyleadService();

            sqlSelect = "BuyleadID,BuyleadName,BuyleadIMGPath,Remark,RowFlag,CompID,CateLV1,CateLV2,CateLV3,RowVersion";
            sqlWhere  = svBuylead.CreateWhereAction(action) + " AND ListNo = 0 ";

            sqlOrderBy = " ModifiedDate DESC ";

            #region DoWhereCause
            sqlWhere += svBuylead.CreateWhereCause(LogonCompID, ViewBag.TextSearch, (int)ViewBag.PStatus,
                                                   (int)ViewBag.CateLevel, (int)ViewBag.CateID);

            if (!string.IsNullOrEmpty(ViewBag.Period))
            {
                sqlWhere += SQLWhereDateTimeFromPeriod(ViewBag.Period, "ModifiedDate");
            }
            #endregion

            var Buyleads = svBuylead.SelectData <b2bBuylead>(sqlSelect, sqlWhere, sqlOrderBy, (int)ViewBag.PageIndex, (int)ViewBag.PageSize);
            ViewBag.Buyleads    = Buyleads;
            ViewBag.LogonCompID = LogonCompID;
            ViewBag.TotalRow    = svBuylead.TotalRow;
            ViewBag.TotalPage   = svBuylead.TotalPage;
        }
Exemplo n.º 3
0
        //
        // GET: /Admin/ApproveBuylead/
        public void List_DoloadData(BuyleadAction action)
        {
            var    svBuylead = new BuyleadService();
            string sqlSelect, sqlWhere, sqlOrderBy = "";

            sqlSelect = "BuyleadID,BuyleadName,BuyleadEmail,RowFlag,CompID,CompName,RowVersion,Remark,CateLV1,CateLV2,CateLV3,Modifieddate,CreatedDate,AdminCode,CompCode,CreatedBy,ModifiedBy,CategoryType";
            sqlWhere  = svBuylead.CreateWhereAction(action) + " ";

            sqlOrderBy = " CreatedDate DESC ";

            #region DoWhereCause
            sqlWhere += svBuylead.CreateWhereCause(0, "", (int)ViewBag.PStatus);
            sqlWhere += svBuylead.CreateWhereSearchBy(ViewBag.TextSearch, ViewBag.SearchType);

            if (!string.IsNullOrEmpty(ViewBag.Period))
            {
                sqlWhere += SQLWhereDateTimeFromPeriod(ViewBag.Period, "CreatedDate");
            }
            #endregion

            var Buyleads = svBuylead.SelectData <view_SearchBuylead>(sqlSelect, sqlWhere, sqlOrderBy, (int)ViewBag.PageIndex, (int)ViewBag.PageSize);
            ViewBag.Buyleads    = Buyleads;
            ViewBag.LogonCompID = LogonCompID;
            ViewBag.TotalRow    = svBuylead.TotalRow;
            ViewBag.TotalPage   = svBuylead.TotalPage;
        }
        public ActionResult Reject(List <int> ID, List <int> CateLV1, List <int> CateLV2, List <int> CateLV3, string Remark)
        {
            var svBuylead = new BuyleadService();

            try
            {
                svBuylead.RejectBuylead(ID, CateLV1, CateLV2, CateLV3, Remark, LogonCompCode);
                if (svBuylead.IsResult)
                {
                    for (var i = 0; i < ID.Count(); i++)
                    {
                        var Buylead = svBuylead.SelectData <b2bBuylead>("BuyleadID, BuyleadCode, BuyleadName, BuyleadCompanyName, BuyleadContactPerson, BuyleadEmail, RowFlag, Remark", "BuyleadID = N'" + ID[i] + "'");
                        if (Buylead.Count > 0)
                        {
                            var model = Buylead.First();
                            SendEmailApproveBuylead(model);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CreateLogFiles(ex);
            }
            return(Json(new { IsResult = svBuylead.IsResult, MsgError = "" }));
        }
        public ActionResult GetBuyleadName(string query)
        {
            svBuylead = new BuyleadService();

            SqlWhere  = svBuylead.CreateWhereAction(BuyleadAction.FrontEnd, 0);
            SqlWhere += svBuylead.CreateWhereCause(0, query, 0, 1, 0, 0, 0, 0);
            SqlWhere += " AND (convert(nvarchar(20), BuyleadExpDate,112) > '" + DateTime.Today.ToString("yyyyMMdd", new System.Globalization.CultureInfo("en-US")) + "')";

            var b2bBuyleads = svBuylead.SelectData <view_BuyLead>("BuyleadName", SqlWhere, "BuyleadName");
            var BuyleadName = b2bBuyleads.Select(it => it.BuyleadName).ToList();

            return(Json(BuyleadName));
        }
Exemplo n.º 6
0
        public ActionResult BuyleadGetByID(int ID)
        {
            if (!CheckIsLogin())
            {
                return(Redirect(res.Pageviews.PvMemberSignIn));
            }

            var svBuylead = new BuyleadService();

            sqlSelect = @"BuyleadID,BuyleadCode,BuyleadName,BuyleadIMGPath,ModifiedDate, CreatedDate,RowFlag,ListNo,
           IsShow,CateLV1,CateLV2,CateLV3,CompID,CategoryName,ViewCount,BuyleadDetail";
            sqlWhere  = "BuyleadID=" + ID;
            var Buylead = svBuylead.SelectData <view_BuyLead>(sqlSelect, sqlWhere, null, 0, 0).First();

            Buylead.ModifiedDate = DataManager.ConvertToDateTime(Buylead.ModifiedDate);
            Buylead.CreatedDate  = DataManager.ConvertToDateTime(Buylead.CreatedDate);

            ViewBag.BuyleadGetByID = Buylead;
            return(PartialView("UC/QuickBuyleadDetail"));
        }
        public ActionResult Delete(List <int> ID, List <int> CateLV1, List <int> CateLV2, List <int> CateLV3, List <int> CompID)
        {
            var svBuylead = new BuyleadService();
            var svCompany = new CompanyService();
            var compid    = CompID;
            var products  = svBuylead.SelectData <b2bBuylead>("BuyleadID,CompID", svBuylead.SQLWhereListInt(ID, "BuyleadID"));

            try
            {
                foreach (var item in products)
                {
                    svBuylead.Delete(ID, CateLV1, CateLV2, CateLV3, (int)item.CompID);
                    var imgManager = new FileHelper();
                    svCompany.UpdateBuyleadCount((int)item.CompID);
                    imgManager.DeleteFilesInDir("Buylead/" + item.CompID + "/" + item.BuyleadID);
                }
            }
            catch (Exception ex)
            {
                svBuylead.MsgError.Add(ex);
                CreateLogFiles(ex);
            }
            return(Json(new { IsResult = svBuylead.IsResult, MsgError = GenerateMsgError(svBuylead.MsgError) }));
        }
Exemplo n.º 8
0
        public ActionResult Channel2(string ID, string Comp)
        {
            if (RedirectToProduction())
            {
                return(Redirect(UrlProduction));
            }

            GetStatusUser();
            ViewBag.EnumServiceType = svCommon.SelectEnum(CommonService.EnumType.SearchByServiceType);
            ViewBag.QtyUnits        = svCommon.SelectEnum(CommonService.EnumType.QtyUnits);
            string SqlSelect, SqlWhere = "";

            #region Prepare Edit Buylead

            int BuyleadID = Convert.ToInt32(ID);
            int CompID    = Convert.ToInt32(Comp);
            if (LogonCompID > 0)
            {
                if (BuyleadID > 0)
                {
                    if (CompID != LogonCompID)
                    {
                        return(Redirect(res.Pageviews.PvMemberSignIn));
                    }
                    var Buylead = svBuylead.SelectData <b2bBuylead>(" * ", "BuyleadID=" + ID, null, 1, 1).First();
                    ViewBag.Buylead     = Buylead;
                    ViewBag.BuyleadCode = Buylead.BuyleadCode;
                    ViewBag.Catename    = svCategory.SearchCategoryByID((int)Buylead.CateLV3);
                }
                else
                {
                    #region query Company
                    var svCompany = new CompanyService();
                    var QueryComp = svCompany.SelectData <view_Company>("*", "CompID=" + LogonCompID, "", 1, 1, false).First();
                    ViewBag.QueryComp   = QueryComp;
                    ViewBag.BuyleadCode = GenCode(LogonCompID);
                    #endregion
                }
            }
            else
            {
                if (BuyleadID > 0)
                {
                    RememberURL();
                    if (!CheckIsLogin())
                    {
                        return(Redirect(res.Pageviews.PvMemberSignIn));
                    }
                }
                else
                {
                    ViewBag.BuyleadCode = GenCode(0);
                }
            }
            #endregion
            //switch (res.Common.lblWebsite)
            //{
            //    case "B2BThai": sqlwherein = " AND CategoryType IN (1,2)"; break;
            //    case "AntCart": sqlwherein = " AND CategoryType IN (3)"; break;
            //    case "myOtopThai": sqlwherein = " AND CategoryType IN (5)"; break;
            //    case "AppstoreThai": sqlwherein = " AND CategoryType IN (6)"; break;
            //    default: sqlwherein = ""; break;
            //}
            #region Category

            var cates1 = svCategory.GetCategoryByLevel(1);
            var cates2 = svCategory.GetCategoryByLevel(2);
            var cates3 = svCategory.GetCategoryByLevel(3);
            ViewBag.Category = cates1;
            #endregion

            #region query District And Province
            ViewBag.QueryDistrict = svAddress.ListDistrictByProvinceID(0);
            ViewBag.QueryProvince = svAddress.GetProvinceAll();
            #endregion

            #region FindCateAll
            ViewBag.SelectCateLV1 = cates1;
            ViewBag.SelectCateLV2 = cates2;
            ViewBag.SelectCateLV3 = cates3;
            #endregion

            #region query Buylead

            #region Set ViewBag
            ViewBag.BuyleadID      = BuyleadID;
            ViewBag.CompID         = CompID;
            ViewBag.CateID         = 0;
            ViewBag.ProvinceID     = 0;
            ViewBag.CreatedDate    = 0;
            ViewBag.BuyleadExpDate = 0;
            ViewBag.BuyleadType    = 0;
            ViewBag.PageIndex      = 1;
            ViewBag.PageSize       = 20;
            #endregion
            #endregion

            return(View());
        }
Exemplo n.º 9
0
        public void List_DoloadData(BuyleadAction action)
        {
            ViewBag.Title = res.Product.lblBuyleadList;
            string sqlSelect, sqlWhere, sqlOrderBy = "";
            var    svBuylead = new BuyleadService();

            sqlSelect = "BuyleadID,Qty,QtyUnit,ModifiedDate,BuyleadName,BuyleadNameEng,BuyleadExpDate,BuyleadType,CompBuyleadCount,CompID,CompName,CompLevel,BizTypeName,BizTypeOther,BuyleadImgPath,CateLV3,CategoryName,LogoImgPath";

            #region DoWhereCause
            sqlWhere  = svBuylead.CreateWhereAction(action);
            sqlWhere += svBuylead.CreateWhereCause(0, ViewBag.txtSearch, 0, 1, (int)ViewBag.CateID, (int)ViewBag.BuyleadType, 0, (int)ViewBag.ProvinceID);
            //var sqlwherein = "";
            //switch (res.Common.lblWebsite)
            //{
            //    case "B2BThai": sqlwherein = " AND CategoryType IN (1,2)"; break;
            //    case "AntCart": sqlwherein = " AND CategoryType IN (3)"; break;
            //    case "myOtopThai": sqlwherein = " AND CategoryType IN (5)"; break;
            //    case "AppstoreThai": sqlwherein = " AND CategoryType IN (6) "; break;
            //    default: sqlwherein = ""; break;
            //}
            //sqlWhere += sqlwherein;

            if (ViewBag.BuyleadExpDate != 0)
            {
                sqlWhere += " ";
            }
            else if (ViewBag.BuyleadNotExpDate != 0)
            {
                sqlWhere += " AND (convert(nvarchar(20), BuyleadExpDate,112) > '" + DateTime.Today.ToString("yyyyMMdd", new System.Globalization.CultureInfo("en-US")) + "')";
            }
            #endregion

            #region Order By
            if (ViewBag.BuyleadNotExpDate != 0)
            {
                sqlOrderBy = "CreatedDate DESC";
            }
            else
            {
                sqlOrderBy = "BuyleadExpDate DESC";
            }
            //if (ViewBag.CreatedDate != 0)
            //    if (ViewBag.CreatedDate == 1)
            //        sqlOrderBy = "CreatedDate DESC";
            #endregion

            #region query
            var Buyleads = svBuylead.SelectData <view_BuyLead>(sqlSelect, sqlWhere, sqlOrderBy, (int)ViewBag.PageIndex, (int)ViewBag.PageSize);
            ViewBag.Buyleads = Buyleads;
            if (ViewBag.txtSearch != "")
            {
                ViewBag.Title += ViewBag.txtSearch;
            }
            if (svBuylead.TotalRow > 0)
            {
                if ((int)ViewBag.CateID > 0)
                {
                    ViewBag.Title += " | " + Buyleads.First().CategoryName;
                }
                if ((int)ViewBag.ProvinceID > 0)
                {
                    ViewBag.Title += " | " + Buyleads.First().ProvinceName;
                }
            }
            ViewBag.Title          += " | " + res.Common.lblDomainShortName;
            ViewBag.MetaKeyword     = ViewBag.Title;
            ViewBag.MetaDescription = ViewBag.Title;
            ViewBag.TotalRow        = svBuylead.TotalRow;
            //if (svBuylead.TotalRow.ToString().Length > 2)
            //    ViewBag.TotalRow = String.Format("{0:0,0}", svBuylead.TotalRow);

            ViewBag.TotalPage = svBuylead.TotalPage;
            if (svBuylead.TotalPage.ToString().Length > 2)
            {
                ViewBag.TotalPage = String.Format("{0:0,0}", svBuylead.TotalPage);
            }
            #endregion

            //#region Buyer
            //string CateLV3 = string.Empty;
            //if (ViewBag.Buyleads != null)
            //{
            //    if (Buyleads.Count > 0)
            //    {
            //        for (int x = 0; x < Buyleads.Count; x++)
            //        {
            //            CateLV3 += Buyleads[x].CateLV3 + ",";
            //        }
            //        CateLV3 = CateLV3.Substring(0, CateLV3.Length - 1);
            //        var Buyer = svBuylead.SelectData<view_PurchaseComp>("*", "CateLV3 IN (" + CateLV3 + ") AND RowFlag IN(2,4) AND ProductCount > 0 ", "CompID",0,0);
            //        ViewBag.Buyer = Buyer;
            //    }
            //}
            //#endregion
        }
Exemplo n.º 10
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());
        }