private void CreateCaregoryDic() { var category = contactRepo.All().Select(c => c.職稱).Distinct().ToList(); int i = 1; jobTitleDic.Add(i.ToString(), "All"); i++; foreach (var item in category) { jobTitleDic.Add(i.ToString(), item); i++; } }
// GET: 客戶聯絡人 //public ActionResult Index() //{ // //var 客戶聯絡人 = db.客戶聯絡人.Include(客 => 客.客戶資料); // var 客戶聯絡人 = db.All().Include(客 => 客.客戶資料); // return View(客戶聯絡人.ToList()); //} public ActionResult Index(string SortBy, string Keyword) { var MyResult = db.All().AsQueryable(); if (!String.IsNullOrEmpty(Keyword)) { MyResult = MyResult.Where( m => m.姓名.Contains(Keyword) || m.職稱.Contains(Keyword) || m.Email.Contains(Keyword) || m.電話.Contains(Keyword) || m.手機.Contains(Keyword) || m.客戶資料.客戶名稱.Contains(Keyword) ); } if (String.IsNullOrEmpty(SortBy)) { SortBy = "+Price"; } if (SortBy.Equals("+Price")) { MyResult = MyResult.OrderBy(m => m.姓名); } else if (SortBy.Equals("-Price")) { MyResult = MyResult.OrderByDescending(m => m.姓名); } ViewBag.Keyword = Keyword; return(View(MyResult.Take(10))); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { PropertyInfo custProp = validationContext.ObjectType.GetProperty(this._field); var oCustId = custProp.GetValue(validationContext.ObjectInstance, null); int iCustId = Convert.ToInt32(oCustId); string sValue; sValue = Convert.ToString(value); 客戶聯絡人Repository custContactRepo = RepositoryHelper.Get客戶聯絡人Repository(); var data = custContactRepo.All().AsQueryable(); data = data.Where(p => p.客戶Id == iCustId && p.Email == sValue); if (data.Count() > 0) { return(new ValidationResult("Email Address重複!!")); } else { return(null); } // return base.IsValid(value, validationContext); }
// GET: 客戶資料/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var 客戶資料 = rep.Find(id.Value); 客戶資料.客戶聯絡人 = rep聯絡人.All().Where(x => x.客戶Id == id.Value).ToList(); if (客戶資料 == null) { return(HttpNotFound()); } var 客戶資料ViewModel = new ViewModels.客戶資料ViewModel { Id = 客戶資料.Id, 客戶分類 = (EnumModel.客戶分類)客戶資料.客戶分類, 客戶名稱 = 客戶資料.客戶名稱, 電話 = 客戶資料.電話, 統一編號 = 客戶資料.統一編號, 已刪除 = 客戶資料.已刪除, 地址 = 客戶資料.地址, Email = 客戶資料.Email, 傳真 = 客戶資料.傳真, 客戶聯絡人 = 客戶資料.客戶聯絡人 }; return(View(客戶資料ViewModel)); }
public ActionResult Index(客戶聯絡人ViewModel 客戶聯絡人) { var client = repo.All().Include(x => x.客戶資料); if (!string.IsNullOrEmpty(客戶聯絡人.搜尋姓名)) { client = repo.FindName(客戶聯絡人.搜尋姓名, client); } if (!string.IsNullOrEmpty(客戶聯絡人.篩選職稱)) { client = repo.GetPosition(客戶聯絡人.篩選職稱, client); } if (!string.IsNullOrEmpty(客戶聯絡人.sort_col)) { bool sort = 客戶聯絡人.isSort; if (sort == false) { if (客戶聯絡人.sort_col == "客戶名稱") { client = (from o in client orderby o.客戶資料.客戶名稱 select o); } else { client = client.OrderByField(客戶聯絡人.sort_col, true); } } else { if (客戶聯絡人.sort_col == "客戶名稱") { client = (from o in client orderby o.客戶資料.客戶名稱 descending select o); } else { client = client.OrderByField(客戶聯絡人.sort_col, false); } } if (ViewBag.isSort != sort) { ViewBag.isSort = sort; } } else { client = client.OrderBy(c => c.Id); ViewBag.isSort = true; } var orderClient = client.ToPagedList(客戶聯絡人.page == 0 ? 1 : 客戶聯絡人.page, pageSize); ViewBag.currentPage = 客戶聯絡人.page == 0 ? "1" : 客戶聯絡人.page.ToString(); ViewBag.搜尋姓名 = 客戶聯絡人.搜尋姓名; ViewBag.篩選職稱 = 客戶聯絡人.篩選職稱; ViewBag.職稱 = GetPositionSelect(); return(View(orderClient)); }
public override bool IsValid(object value) { //var Id = repo客戶聯絡人.Where(x => x.Email == value.GetType.Id).Select(x =>x.Id); var typeInfo = value.GetType(); var propertyInfo = typeInfo.GetProperties(); if (value == null) { return(true); } //string Email = (string)value; //是否為編輯狀態 string Email = propertyInfo.Where(p => p.Name == "Email").First().GetValue(value, null).ToString(); string Id = propertyInfo.Where(p => p.Name == "Id").First().GetValue(value, null).ToString(); if (Id == "0") { if (repo客戶聯絡人.All().Where(x => x.Email.Contains(Email)).Count() > 0) { return(false); } } return(base.IsValid(value)); }
public ActionResult Index(string 查詢條件_名稱, string 查詢條件_職稱) { var data = repo.All(查詢條件_名稱, 查詢條件_職稱); ViewData.Model = data; ViewBag.職稱清單 = Get職稱清單(); return(View()); }
public List <SelectListItem> SetJobTitleItems() { List <SelectListItem> items = new List <SelectListItem>(); items.Add(new SelectListItem { Text = "請選擇", Value = "" }); var category = customerContactRepo.All().Select(c => new SelectListItem { Text = c.職稱.ToString(), Value = c.職稱.ToString() }).Distinct().ToList(); foreach (var item in category) { items.Add(item); } return(items); }
// GET: 客戶聯絡人 public ActionResult Index() { //var 客戶聯絡人 = db.客戶聯絡人.Include(客 => 客.客戶資料) // .Where(客=>客.是否已刪除==false && 客.客戶資料.是否已刪除==false); var 客戶聯絡人 = repo.All().ToList(); return(View(客戶聯絡人)); }
// GET: 客戶聯絡人 public ActionResult Index() { var 客戶聯絡人 = CCRepo.All().Include(c => c.客戶資料); ViewBag.職稱 = new SelectList(Selector.GetJobTitle(), "Value", "Text");; return(View(客戶聯絡人.ToList())); }
public ActionResult 客戶聯絡人Excel() { 客戶聯絡人Repository repo = RepositoryHelper.Get客戶聯絡人Repository(); List <客戶聯絡人> items = repo.All().ToList(); var dt = ConvertToDataTable(items); ExportExcel(dt, "客戶聯絡人"); return(RedirectToAction("客戶聯絡人Excel", "File")); }
public ActionResult ExcelOutput() { var repodata = repo.All(); var data = from s1 in repodata select new { s1.職稱, s1.姓名, s1.Email, s1.手機, s1.電話, s1.客戶資料.客戶名稱 }; var l_ExcelClass = new ExcelClass(); DataTable l_datatable = l_ExcelClass.ToDataTable(data); string OutputPath = l_ExcelClass.ExcelOutput(l_datatable, " ContactPerson"); return(File(Server.MapPath(OutputPath), "application/vnd.ms-excel")); }
// GET: 客戶聯絡人 public ActionResult Index(string keyword) { var data = repo客戶聯絡人.All(); if (!string.IsNullOrEmpty(keyword)) { data = data.Where(p => p.職稱.Contains(keyword)); } return(View(data)); }
// GET: CustomerContact public ActionResult Index(string sName, string sSortby, int pageNo = 1) { var data = customerRepo.All(sName, sSortby).AsQueryable(); ViewBag.sName = sName; ViewBag.pageNo = pageNo; ViewBag.sSortby = sSortby; return(View(data.ToPagedList(pageNo, 5))); }
// GET: CustomerBankContactManage public ActionResult Index(客戶聯絡人搜尋ViewModel search_model, OrderViewModel order_model, int?客戶Id) { var 職稱 = 客戶聯絡人repo.All().Select(x => x.職稱).Distinct(); var 職稱種類 = new List <SelectListItem>(); foreach (var item in 職稱) { 職稱種類.Add(new SelectListItem() { Text = item, Value = item }); } ViewBag.職稱種類 = 職稱種類; var 客戶聯絡人 = 客戶聯絡人repo.Get客戶聯絡人(search_model: search_model, order_model: order_model); return(View(客戶聯絡人.ToList())); }
// GET: 客戶聯絡人 public ActionResult Index(string 職稱, int?page) { var data = repo.Get客戶聯絡人所有資料(職稱); ViewBag.職稱 = new SelectList(repo.All(), "職稱", "職稱"); // 計算出目前要顯示第幾頁的資料 ( 因為 page 為 Nullable<int> 型別 ) int currentPageIndex = page.HasValue ? page.Value - 1 : 0; // 透過 ToPagedList 這個 Extension Method 將原本的資料轉成 IPagedList<T> return(View(data.ToPagedList(currentPageIndex, PageSize))); }
// GET: 客戶聯絡人 public ActionResult Index(int?客戶Id) { //var 客戶聯絡人 = db.客戶聯絡人.Include(客 => 客.客戶資料).Where(p => p.是否已刪除 == false); var 客戶聯絡人 = repo.All(); if (客戶Id.HasValue) { 客戶聯絡人.Where(p => p.客戶Id == 客戶Id); } return(View(客戶聯絡人.ToList())); }
// GET: 客戶聯絡人 public ActionResult Index(string jobTitle) { var 客戶聯絡人 = 客戶聯絡人repo.All().AsQueryable(); if (!String.IsNullOrEmpty(jobTitle)) { 客戶聯絡人 = 客戶聯絡人repo.Where(p => p.職稱.Contains(jobTitle)); } return(View(客戶聯絡人.ToList())); }
// GET: 客戶聯絡人 public ActionResult Index(string sortOrder) { var data = custContactRepo.All(); var jobTitle = custContactRepo.GetJobTitle(); ViewBag.contactTitle = new SelectList(jobTitle); var customerName = custContactRepo.GetCustName(); ViewBag.custName = new SelectList(customerName); ViewBag.jobTitleSortParm = String.IsNullOrEmpty(sortOrder) ? "jobTitle_desc" : ""; ViewBag.nameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewBag.emailSortParm = String.IsNullOrEmpty(sortOrder) ? "email_desc" : ""; ViewBag.phoneNumSortParm = String.IsNullOrEmpty(sortOrder) ? "phone_desc" : ""; ViewBag.telNumSortParm = String.IsNullOrEmpty(sortOrder) ? "telNum_desc" : ""; ViewBag.customerNameSortParm = String.IsNullOrEmpty(sortOrder) ? "customerName_desc" : ""; switch (sortOrder) { case "jobTitle_desc": data = data.OrderByDescending(o => o.職稱); break; case "name_desc": data = data.OrderByDescending(o => o.姓名); break; case "email_desc": data = data.OrderByDescending(o => o.Email); break; case "phone_desc": data = data.OrderByDescending(o => o.手機); break; case "telNum_desc": data = data.OrderByDescending(o => o.電話); break; case "customerName_desc": data = data.OrderByDescending(o => o.客戶資料); break; default: data = data.OrderByDescending(o => o.客戶Id); break; } return(View(data.ToList())); }
public ActionResult Index(string keyword) { //排除顯示已刪除的聯絡人 var data = repo.All().AsQueryable(); if (!string.IsNullOrEmpty(keyword)) { data = data.Where(客戶聯絡人 => 客戶聯絡人.姓名.Contains(keyword)); } ViewBag.keyword = keyword; return(View(data.ToList())); }
// GET: Contactors public ActionResult Index(string search, string JobTitle, Contactor?sortItem, string order) { if (sortItem == null) { sortItem = 0; } var jtitle = repo.All().Select(c => c.職稱); ViewBag.JobTitle = new SelectList(jtitle); var contactors = repo.All(search, JobTitle); if (contactors.Count() == 0) { ViewBag.Message = "查無此聯絡人資料"; } contactors = contactors.Sort(sortItem.Value, order); return(View(contactors)); }
// GET: 客戶聯絡人 public ActionResult Index(string keyword, string ClientData) { //var data = repo.Include(w => w.客戶資料 ).ToList(); var data = repo.All().Include(w => w.客戶資料).ToList(); if (!String.IsNullOrEmpty(keyword)) { data = data.Where(w => w.姓名.Contains(keyword)).ToList(); } return(View(data)); }
public ActionResult ContactCount(int?cid) { 客戶聯絡人Repository repo = RepositoryHelper.Get客戶聯絡人Repository(); var 聯絡人 = repo.All(); 聯絡人 = 聯絡人.Where(r => r.客戶Id == cid); return(Json(new { isOK = true, count = 聯絡人.Count() }, JsonRequestBehavior.AllowGet)); }
//private 客戶資料Entities db = new 客戶資料Entities(); // GET: customerContact public ActionResult Index(string orderby, string qtype, string qname) { ViewBag.qtype = new SelectList(repo.SelectList(orderby), "職稱", "職稱", qtype); if (string.IsNullOrWhiteSpace(qtype) && string.IsNullOrWhiteSpace(qname)) { return(View("Index", repo.All(orderby).ToList())); } else { return(View("Index", repo.搜尋名稱(orderby, qtype, qname))); } }
public ActionResult Index(int Page = 1) { var dropdown = repo.All().Distinct(); SelectList selectlist = new SelectList(dropdown, "職稱", "職稱"); ViewBag.selectlist = selectlist; return(View(repo.All().OrderBy(p => p.Id).ToPagedList(Page, pageSize))); }
//動作過濾器 public override void OnActionExecuting(ActionExecutingContext filterContext) { filterContext.Controller.ViewBag.客戶聯絡人List = (from p in db聯絡人.All() select new 客戶聯絡人VM() { Id = p.Id, 職稱 = p.職稱, 手機 = p.手機, 電話 = p.電話, 姓名 = p.姓名, Email = p.Email }); base.OnActionExecuting(filterContext); }
public ActionResult Index(SortViewModel viewModel) { //客戶職稱 List <string> 職稱List = _客戶聯絡人Repository.All().Select(p => p.職稱).Distinct().OrderBy(p => p).ToList(); ViewBag.jobTitle = new SelectList(職稱List, viewModel.jobTitle); ViewBag.Keyword = viewModel.keyword; ViewBag.sortOrder = (viewModel.sortOrder == "ASC") ? "DESC" : "ASC"; var 客戶聯絡人 = _客戶聯絡人Repository.Sort(viewModel); var data = 客戶聯絡人.ToPagedList(viewModel.page, 5); return(View(data)); }
// GET: 客戶聯絡人 public ActionResult Index() { //var 客戶聯絡人 = db.客戶聯絡人.Include(客 => 客.客戶資料); var 客戶聯絡人 = repo.All().Include(p => p.客戶資料); List <SelectListItem> vlst職稱 = new List <SelectListItem>(); foreach (var v職稱 in 客戶聯絡人.Select(u => u.職稱).Distinct()) { if (!string.IsNullOrEmpty(v職稱)) { vlst職稱.Add(new SelectListItem() { Text = v職稱, Value = v職稱 }); } } ViewBag.lst職稱 = vlst職稱; return(View(客戶聯絡人.ToList())); }
public void Initialze() { contacts = new List <客戶聯絡人> { new 客戶聯絡人 { Id = 0, 姓名 = "test0", 是否已刪除 = false, 客戶資料 = new 客戶資料 { Id = 0, 客戶名稱 = "test0", Email = "*****@*****.**", 是否已刪除 = false } }, new 客戶聯絡人 { Id = 1, 姓名 = "test1", 是否已刪除 = false, 客戶資料 = new 客戶資料 { Id = 1, 客戶名稱 = "test1", Email = "*****@*****.**", 是否已刪除 = false } }, new 客戶聯絡人 { Id = 2, 姓名 = "test2", 是否已刪除 = false, 客戶資料 = new 客戶資料 { Id = 2, 客戶名稱 = "test2", Email = "*****@*****.**", 是否已刪除 = false } }, new 客戶聯絡人 { Id = 3, 姓名 = "test3", 是否已刪除 = false, 客戶資料 = new 客戶資料 { Id = 3, 客戶名稱 = "test3", Email = "*****@*****.**", 是否已刪除 = false } } }.AsQueryable(); mockDbSet = Substitute.For <DbSet <客戶聯絡人>, IDbSet <客戶聯絡人> >(); mockDbSet.Provider.Returns(contacts.Provider); mockDbSet.Expression.Returns(contacts.Expression); mockDbSet.ElementType.Returns(contacts.ElementType); mockDbSet.GetEnumerator().Returns(contacts.GetEnumerator()); mockDbSet.Find(Arg.Any <int>()).Returns(callinfo => { var idValues = callinfo.Arg <object[]>(); int id = (int)idValues[0]; return(contacts.SingleOrDefault(c => c.Id == id)); }); mockDbSet.Include("test").ReturnsForAnyArgs(mockDbSet); mockDBContext = Substitute.For <客戶資料DBEntities>(); mockDBContext.客戶聯絡人.Returns(mockDbSet); mockRepo = Substitute.For <客戶聯絡人Repository>(); mockRepo.All().Returns(contacts.Where(contact => contact.是否已刪除 == false)); mockRepo.UnitOfWork = Substitute.For <IUnitOfWork>(); }
public ActionResult DownloadXlsx() { var data = repoClientContactData.All().Select(x => new { x.客戶Id, x.職稱, x.姓名, x.Email, x.手機, x.電話 }); if (!data.Any()) { return(View("Index", repoClientContactData.SelectData())); } var table = CommonMethod.CreateDataTable(data); System.IO.MemoryStream stream = CommonMethod.ExportExcelFromDataTable(table, "客戶聯絡人"); FileContentResult fResult = new FileContentResult(stream.ToArray(), "application/x-xlsx"); fResult.FileDownloadName = "客戶聯絡人.xlsx"; return(fResult); }
public ActionResult DeleteConfirmed(int id) { //客戶資料 客戶資料 = db.客戶資料.Find(id); //客戶資料.是否已刪除 = true; ////db.客戶資料.Remove(客戶資料); //db.SaveChanges(); 客戶聯絡人Repository repoC = new 客戶聯絡人Repository(); repoC.DeleteRange(repoC.All().Where(c => c.客戶Id == id)); repoC.UnitOfWork.Commit(); 客戶銀行資訊Repository repoB = new 客戶銀行資訊Repository(); repoB.DeleteRange(repoB.All().Where(c => c.客戶Id == id)); repoB.UnitOfWork.Commit(); repo.Delete(repo.Find(id)); repo.UnitOfWork.Commit(); return RedirectToAction("Index"); }