using System; using System.Collections.Generic; using System.Linq; using MySystem.Models; namespace MySystem { public class RelationClass { public static string GetColInfo(string key) { using (Models.WebCMSEntities db = new Models.WebCMSEntities()) { Models.Col item = db.Col.FirstOrDefault(m => m.ColId == key); if (item != null) { return item.ColName; } } return ""; } public static string GetColInfo(int key) { using (BsModels.WebCMSEntities db = new BsModels.WebCMSEntities()) { BsModels.Col item = db.Col.FirstOrDefault(m => m.Id == key); if (item != null) { return item.ColName; } } return ""; } public static string GetMsgTemplateInfo(int key) { using (Models.WebCMSEntities db = new Models.WebCMSEntities()) { MsgTemplate item = db.MsgTemplate.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Title; } } return ""; } public static string GetMsgPlacardInfo(int key) { using (Models.WebCMSEntities db = new Models.WebCMSEntities()) { MsgPlacard item = db.MsgPlacard.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Title; } } return ""; } public static string GetUserLevelSetInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { UserLevelSet item = db.UserLevelSet.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Name; } } return ""; } public static string GetUserGroupList(string keys) { string[] IdList = keys.Split(','); List List = new List(); foreach (string key in IdList) { List.Add(int.Parse(key)); } string result = ""; using (WebCMSEntities db = new WebCMSEntities()) { var items = db.UserGroup.Select(m => new { m.Id, m.Name }).Where(m => List.Contains(m.Id)); foreach (var item in items) { result += item.Name + ","; } } return result.TrimEnd(','); } public static string GetColList(string keys) { string[] IdList = keys.Split(','); List List = new List(); foreach (string key in IdList) { List.Add(int.Parse(key)); } string result = ""; using (WebCMSEntities db = new WebCMSEntities()) { var items = db.Col.Select(m => new { m.Id, m.ColName }).Where(m => List.Contains(m.Id)); foreach (var item in items) { result += item.ColName + ","; } } return result.TrimEnd(','); } public static string GetProductFareTempInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { ProductFareTemp item = db.ProductFareTemp.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Name; } } return ""; } public static string GetMerchantClassInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { MerchantClass item = db.MerchantClass.FirstOrDefault(m => m.Id == key); if (item != null) { return item.ColName; } } return ""; } public static string GetMerchantColInfo(string key) { using (WebCMSEntities db = new WebCMSEntities()) { MerchantCol item = db.MerchantCol.FirstOrDefault(m => m.ColId == key); if (item != null) { return item.ColName; } } return ""; } public static string GetErpCompanysInfo(string key) { using (WebCMSEntities db = new WebCMSEntities()) { ErpCompanys item = db.ErpCompanys.FirstOrDefault(m => m.Name == key); if (item != null) { return item.Name; } } return ""; } public static string GetMerchantsInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { Merchants item = db.Merchants.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Name; } } return ""; } public static string GetOrderRefundReasonInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { OrderRefundReason item = db.OrderRefundReason.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Name; } } return ""; } public static string GetMerchantsList(string keys) { string[] IdList = keys.Split(','); List List = new List(); foreach (string key in IdList) { List.Add(int.Parse(key)); } string result = ""; using (WebCMSEntities db = new WebCMSEntities()) { var items = db.Merchants.Select(m => new { m.Id, m.Name }).Where(m => List.Contains(m.Id)); foreach (var item in items) { result += item.Name + ","; } } return result.TrimEnd(','); } public static string GetProductsList(string keys) { string[] IdList = keys.Split(','); List List = new List(); foreach (string key in IdList) { List.Add(int.Parse(key)); } string result = ""; using (WebCMSEntities db = new WebCMSEntities()) { var items = db.Products.Select(m => new { m.Id, m.ProductName }).Where(m => List.Contains(m.Id)); foreach (var item in items) { result += item.ProductName + ","; } } return result.TrimEnd(','); } public static string GetCouponsList(string keys) { string[] IdList = keys.Split(','); List List = new List(); foreach (string key in IdList) { List.Add(int.Parse(key)); } string result = ""; using (WebCMSEntities db = new WebCMSEntities()) { var items = db.Coupons.Select(m => new { m.Id, m.Name }).Where(m => List.Contains(m.Id)); foreach (var item in items) { result += item.Name + ","; } } return result.TrimEnd(','); } public static string GetKqProductBrandInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { KqProducts item = db.KqProducts.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Name; } } return ""; } public static string GetUsersInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { Users item = db.Users.FirstOrDefault(m => m.Id == key); if (item != null) { return item.RealName; } } return ""; } public static string GetMerchantInfoInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { MerchantInfo item = db.MerchantInfo.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Name; } } return ""; } public static string GetKqProductBrandList(string keys) { if (string.IsNullOrEmpty(keys)) { return ""; } string[] IdList = keys.Split(','); List List = new List(); foreach (string key in IdList) { List.Add(int.Parse(key)); } string result = ""; using (WebCMSEntities db = new WebCMSEntities()) { var items = db.KqProducts.Select(m => new { m.Id, m.Name }).Where(m => List.Contains(m.Id)); foreach (var item in items) { result += item.Name + ","; } } return result.TrimEnd(','); } public static string GetActivityInfoInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { ActivityInfo item = db.ActivityInfo.FirstOrDefault(m => m.Id == key); if (item != null) { return item.ActName; } } return ""; } public static string GetStoreHouseInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { StoreHouse item = db.StoreHouse.FirstOrDefault(m => m.Id == key); if (item != null) { return item.StoreName; } } return ""; } public static string GetUserBackKindInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { UserBackKind item = db.UserBackKind.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Name; } } return ""; } public static string GetPageUpdateInfoList(string keys) { string[] ModulePathList = keys.Split(','); List List = new List(); foreach (string key in ModulePathList) { List.Add(key); } string result = ""; using (WebCMSEntities db = new WebCMSEntities()) { var items = db.PageUpdateInfo.Select(m => new { m.ModulePath, m.Title }).Where(m => List.Contains(m.ModulePath)); foreach (var item in items) { result += item.Title + ","; } } return result.TrimEnd(','); } public static string GetTeamApplyInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { TeamApply item = db.TeamApply.FirstOrDefault(m => m.Id == key); if (item != null) { return item.TeamName; } } return ""; } public static string GetProfitObjectsActivesInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { ProfitObjectsActives item = db.ProfitObjectsActives.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Name; } } return ""; } public static string GetProfitObjectsActivesList(string keys) { if(string.IsNullOrEmpty(keys)) return ""; string[] IdList = keys.Split(','); List List = new List(); foreach (string key in IdList) { List.Add(int.Parse(key)); } string result = ""; using (WebCMSEntities db = new WebCMSEntities()) { var items = db.ProfitObjectsActives.Select(m => new { m.Id, m.Name }).Where(m => List.Contains(m.Id)); foreach (var item in items) { result += item.Name + ","; } } return result.TrimEnd(','); } public static string GetSysAdminRoleInfo(int key) { using (BsModels.WebCMSEntities db = new BsModels.WebCMSEntities()) { BsModels.SysAdminRole item = db.SysAdminRole.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Name; } } return ""; } public static string GetProductsInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { Products item = db.Products.FirstOrDefault(m => m.Id == key); if (item != null) { return item.ProductName; } } return ""; } public static string GetAppVideoInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { AppVideo item = db.AppVideo.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Name; } } return ""; } public static string GetPosCouponsInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { PosCoupons item = db.PosCoupons.FirstOrDefault(m => m.Id == key); if (item != null) { return item.ExchangeCode; } } return ""; } public static string GetPosMachinesTwoInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { PosMachinesTwo item = db.PosMachinesTwo.FirstOrDefault(m => m.Id == key); if (item != null) { return item.PosSn; } } return ""; } public static string GetStoreMachineApplyInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { StoreMachineApply item = db.StoreMachineApply.FirstOrDefault(m => m.Id == key); if (item != null) { return item.ApplyNo; } } return ""; } public static string GetKqProductsInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { KqProducts item = db.KqProducts.FirstOrDefault(m => m.Id == key); if (item != null) { return item.Name; } } return ""; } public static string GetSchoolSignInTaskInfo(int key) { using (WebCMSEntities db = new WebCMSEntities()) { SchoolSignInTask item = db.SchoolSignInTask.FirstOrDefault(m => m.Id == key); if (item != null) { return item.TaskName; } } return ""; } } }