// // 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 ValidateAddBuylead(string BuyleadName, string BuyleadCode, string BuyleadExpire) { var svBuylead = new BuyleadService(); svBuylead.ValidateInsert(BuyleadName, BuyleadCode, BuyleadExpire); return(Json(svBuylead.IsResult)); }
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 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; }
public ActionResult ValidateEditBuylead(string Upd_BuyleadName, string Chk_BuyleadName, string Upd_BuyleadCode, string Chk_BuyleadCode, string BuyleadExpire, int BuyleadID) { var svBuylead = new BuyleadService(); svBuylead.ValidateUpdate(Upd_BuyleadName, Chk_BuyleadName, Upd_BuyleadCode, Chk_BuyleadCode, BuyleadExpire, BuyleadID); return(Json(svBuylead.IsResult)); }
public SearchController() { svBuylead = new BuyleadService(); svCategory = new CategoryService(); svBizType = new Ouikum.BizType.BizTypeService(); svCompany = new CompanyService(); svAddress = new AddressService(); }
public BuyleadCenterController() { svBuylead = new BuyleadService(); svCategory = new CategoryService(); svBizType = new BizTypeService(); svCompany = new CompanyService(); svAddress = new AddressService(); }
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()); }
public bool MoveProduct(int oldcatelv1, int oldcatelv2, int oldcatelv3, int newcatelv1, int newcatelv2, int newcatelv3) { var svProduct = new ProductService(); var svBuylead = new BuyleadService(); svProduct.MoveProductInCateLV(oldcatelv1, oldcatelv2, oldcatelv3, newcatelv1, newcatelv2, newcatelv3); svBuylead.MoveBuyleadInCateLV(oldcatelv1, oldcatelv2, oldcatelv3, newcatelv1, newcatelv2, newcatelv3); return(IsResult); }
public bool MoveCategory(int oldcatelv1, int oldcatelv2, int newcatelv1, int newcatelv2, int newcatelv3) { var svProduct = new ProductService(); var svBuylead = new BuyleadService(); var svCategory = new CategoryService(); using (var trans = new TransactionScope()) { svProduct.MoveProductInCate(2, oldcatelv2, newcatelv2, newcatelv3); svProduct.MoveProductInCate(1, oldcatelv1, newcatelv1, newcatelv3); trans.Complete(); } using (var trans = new TransactionScope()) { svBuylead.MoveBuyleadInCate(2, oldcatelv2, newcatelv2, newcatelv3); svBuylead.MoveBuyleadInCate(1, oldcatelv1, newcatelv1, newcatelv3); trans.Complete(); } if (svProduct.IsResult) { var categoryNameLV1 = svCategory.SelectData <b2bCategory>("CategoryID,CategoryName", "CategoryID = " + newcatelv1).First(); var categoryNameLV2 = svCategory.SelectData <b2bCategory>("CategoryID,CategoryName", "CategoryID = " + newcatelv2).First(); var categoryNameLV3 = svCategory.SelectData <b2bCategory>("CategoryID,CategoryName", "CategoryID = " + newcatelv3).First(); using (var trans = new TransactionScope()) { var strParent = @"ParentCategoryPath = N'" + categoryNameLV1.CategoryName + " >> " + categoryNameLV2.CategoryName + " >> " + categoryNameLV3.CategoryName + "'"; UpdateByCondition <b2bCategory>("ParentCategoryID = " + newcatelv2 + " , " + strParent, " CategoryID = " + newcatelv3); trans.Complete(); } #region Update Product Count UpdateProductCount(3, newcatelv3); UpdateProductCount(2, oldcatelv2); UpdateProductCount(1, oldcatelv1); UpdateProductCount(3, newcatelv3); UpdateProductCount(2, newcatelv2); UpdateProductCount(1, newcatelv1); #endregion #region Update Buylead Count UpdateBuyleadCount(3, newcatelv3); UpdateBuyleadCount(2, oldcatelv2); UpdateBuyleadCount(1, oldcatelv1); UpdateBuyleadCount(3, newcatelv3); UpdateBuyleadCount(2, newcatelv2); UpdateBuyleadCount(1, newcatelv1); #endregion } return(IsResult); }
public ActionResult SaveIsShow(List <int> BuyleadID, List <int> CateLV1, List <int> CateLV2, List <int> CateLV3, int IsShow) { if (!CheckIsLogin()) { return(Redirect(res.Pageviews.PvMemberSignIn)); } var svBuylead = new BuyleadService(); svBuylead.SaveIsShow(BuyleadID, CateLV1, CateLV2, CateLV3, LogonCompID, IsShow); return(Json(new { IsResult = svBuylead.IsResult, MsgError = GenerateMsgError(svBuylead.MsgError) })); }
public void MyB2BStatus(int CompID) { var svProduct = new ProductService(); var svBuylead = new BuyleadService(); var svMessage = new MessageService(); var svQuotation = new QuotationService(); var svOrderPur = new OrderPurchaseService(); string sqlwhere = string.Empty; //string sqlwhere = svProduct.CreateWhereAction(ProductAction.All, CompID); var count = 0; //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; sqlwhere = svProduct.CreateWhereAction(ProductAction.All, CompID); count = svProduct.CountData <view_SearchProduct>("ProductID", sqlwhere); ViewBag.CountProduct = count; sqlwhere = svProduct.CreateWhereAction(ProductAction.All, CompID) + " AND RowFlag = 3"; count = svProduct.CountData <view_SearchProduct>("ProductID", sqlwhere); ViewBag.CountProductReject = count; sqlwhere = svProduct.CreateWhereAction(ProductAction.All, CompID) + " AND RowFlag IN (2)"; count = svProduct.CountData <view_SearchProduct>("ProductID", sqlwhere); ViewBag.CountProductWait = count; sqlwhere = svProduct.CreateWhereAction(ProductAction.All, CompID) + " AND RowFlag IN (4,5)"; count = svProduct.CountData <view_SearchProduct>("ProductID", sqlwhere); ViewBag.CountProductApprove = count; //sqlwhere = svBuylead.CreateWhereAction(BuyleadAction.All, CompID); //count = svProduct.CountData<b2bBuylead>("BuyleadID", sqlwhere); //ViewBag.CountBuylead = count; //sqlwhere = svBuylead.CreateWhereAction(BuyleadAction.All, CompID) + " AND RowFlag = 3 "; //count = svBuylead.CountData<b2bBuylead>("BuyleadID", sqlwhere); //ViewBag.CountBuyleadReject = count; //sqlwhere = svMessage.CreateWhereAction(MessageStatus.Inbox, CompID); //count = svMessage.CountData<emMessage>("MessageID", sqlwhere); //ViewBag.Inbox = count; sqlwhere = svMessage.CreateWhereAction(MessageStatus.UnRead, CompID); count = svMessage.CountData <emMessage>("MessageID", sqlwhere); ViewBag.UnRead = count; }
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)); }
public ActionResult DeleteBuylead(List <int> BuyleadID, List <int> CateLV1, List <int> CateLV2, List <int> CateLV3) { var svBuylead = new BuyleadService(); try { svBuylead.Delete(BuyleadID, CateLV1, CateLV2, CateLV3, LogonCompID); } catch (Exception ex) { svBuylead.MsgError.Add(ex); CreateLogFiles(ex); } return(Json(new { IsResult = svBuylead.IsResult, MsgError = GenerateMsgError(svBuylead.MsgError) })); }
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 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 void GetStatusByCompID(int CompID) { var svBuylead = new BuyleadService(); string sqlwhere = svBuylead.CreateWhereAction(BuyleadAction.Junk, CompID); var CountJunk = svBuylead.CountData <b2bBuylead>("BuyleadID", sqlwhere); ViewBag.CountJunk = CountJunk; sqlwhere = svBuylead.CreateWhereAction(BuyleadAction.BackEnd, CompID) + " AND ListNo = 0 "; var CountBuylead = svBuylead.CountData <b2bBuylead>("BuyleadID", sqlwhere); ViewBag.CountBuylead = CountBuylead; sqlwhere = svBuylead.CreateWhereAction(BuyleadAction.All, CompID); var CountAllitem = svBuylead.CountData <b2bBuylead>("BuyleadID", sqlwhere); ViewBag.CountAllitem = CountAllitem; sqlwhere += svBuylead.CreateWhereCause(0, "", 4); var CountBuyleadApprove = svBuylead.CountData <view_BuyLead>("BuyleadID", sqlwhere); ViewBag.CountBuyleadApprove = CountBuyleadApprove; }
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) })); }
public ActionResult AddBuylead(FormCollection form, List <string> BuyleadImgPath, List <string> BuyLeadImgOldfile) { var svBuylead = new BuyleadService(); b2bBuylead model = new b2bBuylead(); try { #region Set Buylead Model var date = form["BuyleadExpire"]; model.BuyleadName = form["BuyleadName"]; model.BuyleadCode = form["BuyleadCode"]; model.BuyleadType = DataManager.ConvertToInteger(form["BuyleadType"]); //model.BuyleadExpDate = DateTime.Parse(form["BuyleadExpire"]); var d = form["BuyleadExpire"]; DateTime t = DataManager.ConvertToDateTime(d); model.BuyleadExpDate = t; model.BuyleadKeyword = form["BuyleadKeyword"]; if (form["BuyleadDetail"] != "") { model.BuyleadDetail = form["BuyleadDetail"]; } model.Qty = DataManager.ConvertToDecimal(form["Qty"]); model.QtyUnit = form["QtyUnit"]; if (BuyleadImgPath != null) { model.BuyleadIMGPath = BuyleadImgPath[0]; } model.CompID = LogonCompID; model.CateLV1 = Convert.ToInt32(form["Catecode"].Substring(9, 4)); model.CateLV2 = Convert.ToInt32(form["Catecode"].Substring(14, 4)); model.CateLV3 = Convert.ToInt32(form["CateLV3"]); model.IsShow = true; model.IsJunk = false; #region Check ว่าเป็น OutSource Add หรือ User Add model.RowFlag = (LogonServiceType >= 9) ? (short)2 : (short)6; #endregion if (LogonServiceType >= 9) { model.CompCode = LogonCompCode; } #region Company Information model.BuyleadCompanyName = form["CompName"]; model.BuyleadContactPerson = form["ContactName"]; model.BuyleadContactPosition = form["Position"]; model.BuyleadTel = form["Phone"]; model.BuyleadEmail = form["Email"]; if (form["Mobile"] != "") { model.BuyleadMobilePhone = form["Mobile"]; } if (form["Fax"] != "") { model.BuyleadFax = form["Fax"]; } if (form["Address"] != "") { model.BuyleadAddressLine1 = form["Address"]; } model.DistrictID = Convert.ToInt32(form["District"]); model.ProvinceID = Convert.ToInt32(form["Province"]); if (form["Postal"] != "") { model.BuyleadPostelCode = form["Postal"]; } #endregion #endregion model.ContactCount = 0; model.ListNo = 0; model.ViewCount = 0; model.CreatedDate = DateTime.Now; model.ModifiedDate = DateTime.Now; model.CreatedBy = "sa"; model.ModifiedBy = "sa"; if (form["BuyleadID"] == null) { #region Insert Buylead And BuyleadImage svBuylead.InsertBuylead(model, LogonCompID); #endregion } else { #region Update Data if (Convert.ToInt32(form["RowFlag"]) == 3) { model.RowFlag = 2; } model.BuyleadID = Convert.ToInt32(form["BuyleadID"]); svBuylead.UpdateBuylead(model); #endregion } var Floder = 0; if (LogonCompID > 0) { Floder = LogonCompID; } else { Floder = 2; } #region Save Image Files if (BuyleadImgPath != null) { imgManager = new FileHelper(); imgManager.DirPath = "Buylead/" + Floder + "/" + model.BuyleadID; imgManager.DirTempPath = "Temp/Buylead/" + Floder; SaveFileImage( imgManager.DirTempPath, imgManager.DirPath, BuyleadImgPath, 150, 450); if (BuyLeadImgOldfile != null && (BuyleadImgPath[0] != BuyLeadImgOldfile[0])) { DeleteFileImage(imgManager.DirPath, BuyLeadImgOldfile, BuyleadImgPath); } } #endregion } catch (Exception ex) { CreateLogFiles(ex); } return(Json(new { IsResult = svBuylead.IsResult, MsgError = GenerateMsgError(svBuylead.MsgError), ID = model.BuyleadID })); }
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 }
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 })); }
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()); }