public ActionResult Index(FormCollection forms) { //拼接条件 Expression <Func <cst_customer, bool> > expression = null; int curPage = int.Parse(forms["curPage"]); var cust_no1 = forms["cust_no"]; var cust_name1 = forms["cust_name"]; var cust_manager_name1 = forms["cust_manager_name"]; var cust_level1 = forms["cust_level"]; var cust_region1 = forms["cust_region"]; //存储搜索条件 Cst_Custom_ViewModel searchEntity = new Cst_Custom_ViewModel { cust_no = cust_no1, cust_name = cust_name1, cust_manager_name = cust_manager_name1, cust_level = cust_level1, cust_region = cust_region1 }; //进行条件拼接 //if (string.IsNullOrEmpty(cust_no1) && string.IsNullOrEmpty(cust_name1) // && string.IsNullOrEmpty(cust_manager_name1) && string.IsNullOrEmpty(cust_level1)) //{ expression = ExpressionUtils.True <cst_customer>(); //} if (!string.IsNullOrEmpty(cust_no1)) { expression = ExpressionUtils.And <cst_customer>(expression, f => f.cust_no.Contains(cust_no1)); } if (!string.IsNullOrEmpty(cust_name1)) { expression = ExpressionUtils.And <cst_customer>(expression, f => f.cust_name.Contains(cust_name1)); } if (!string.IsNullOrEmpty(cust_manager_name1)) { expression = ExpressionUtils.And <cst_customer>(expression, f => f.cust_manager_name.Contains(cust_manager_name1)); } if (!string.IsNullOrEmpty(cust_region1)) { expression = ExpressionUtils.And <cst_customer>(expression, f => f.cust_region == cust_region1); } if (!string.IsNullOrEmpty(cust_level1)) { var r = int.TryParse(cust_level1, out int i) ? i : -1; expression = ExpressionUtils.And <cst_customer>(expression, f => f.cust_level == i); } var compileExp = expression.Compile(); //最后使用拼接条件 ViewData["pagerHelper"] = new PageHelper <cst_customer>(new LinqHelper().Db.cst_customer.Where(compileExp).ToList(), curPage, 3); ViewData["region"] = new SelectList(new bas_dictService().GetDictsByType("地区"), "dict_value", "dict_item"); ViewData["level"] = new SelectList(new bas_dictService().GetDictsByType("客户等级"), "dict_value", "dict_item"); return(View(searchEntity)); }
/// <summary> /// 历史订单 /// </summary> /// <param name="id">客户编号</param> /// <returns></returns> public ActionResult OrderHistory(string id) { ViewData["pagerHelper"] = new PageHelper <orders>(new ordersService().GetOrdersByCustomerNo(id), 1, 3); return(View(new cst_customerService().GetCustomerByNo(id))); }
/// <summary> /// 交往记录 /// </summary> /// <param name="id">客户编号</param> /// <returns></returns> public ActionResult ContactRecord(string id) { ViewData["pagerHelper"] = new PageHelper <cst_activity>(new cst_activityService().GetActivityByCustomerId(id), 1, 3); return(View(new LinqHelper().Db.cst_customer.Where(c => c.cust_no == id).FirstOrDefault())); }
/// <summary> /// 联系人 /// </summary> /// <param name="id">客户编号</param> /// <returns></returns> public ActionResult LinkMan(int?id) { ViewData["pagerHelper"] = new PageHelper <cst_linkman>(new cst_linkmanService().GetLinkMansByCustomerId(id.Value), 1, 3); return(View(new cst_customerService().GetCustomerById(id.Value))); }
// // GET: /RightManager/ /// <summary> /// 权限 /// </summary> /// <returns></returns> public ActionResult Index() { ViewData["pagerHelper"] = new PageHelper <sys_user>(new sys_userService().GetAllUsers(), 1, 3); return(View()); }
public ActionResult Index(FormCollection forms) { int curPage = int.Parse(forms["curPage"]); Dictionary <string, object> dic = new Dictionary <string, object>(); //存储搜索条件,每次返回页面不会使条件消失 Chance_Plan_ViewModel search = new Chance_Plan_ViewModel { Chc_Cust_Name = forms["chc_cust_name"], Chc_Linkman = forms["chc_linkman"], Chc_Title = forms["chc_title"], Start_Pla_Date = forms["start_pla_date"], End_Pla_Date = forms["end_pla_date"], }; //如果没有输入条件,直接返回全部的客户计划 if (string.IsNullOrEmpty(forms["chc_cust_name"]) && string.IsNullOrEmpty(forms["chc_title"]) && string.IsNullOrEmpty(forms["chc_linkman"]) && (string.IsNullOrEmpty(forms["start_pla_date"]) || string.IsNullOrEmpty(forms["end_pla_date"]))) { var express = LinqHelper.GetExpress <sal_plan>(dic); var li = new LinqHelper().Db.sal_plan.Where(express).ToList(); ViewData["pagerHelper"] = new PageHelper <sal_plan>(li, curPage, 3); return(View(search)); } //只查询日期 if (!string.IsNullOrEmpty(forms["start_pla_date"]) && !string.IsNullOrEmpty(forms["end_pla_date"]) && string.IsNullOrEmpty(forms["chc_cust_name"]) && string.IsNullOrEmpty(forms["chc_title"]) && string.IsNullOrEmpty(forms["chc_linkman"])) { DateTime start_pla_date = Convert.ToDateTime(forms["start_pla_date"]); DateTime end_pla_date = Convert.ToDateTime(forms["end_pla_date"]); var li = new LinqHelper().Db.sal_plan.Where(p => p.pla_date >= start_pla_date && p.pla_date <= end_pla_date).ToList(); ViewData["pagerHelper"] = new PageHelper <sal_plan>(li, curPage, 3); return(View(search)); } //日期为空时 List <sal_plan> plans = new List <sal_plan>(); foreach (var key in forms.AllKeys) { dic.Add(key, forms[key]); } var expression = LinqHelper.GetExpress <sal_chance>(dic); plans = new LinqHelper().Db.sal_chance.Include(p => p.sal_plan).Where(expression).SelectMany(c => c.sal_plan).ToList(); if (string.IsNullOrEmpty(forms["start_pla_date"]) || string.IsNullOrEmpty(forms["end_pla_date"])) { ViewData["pagerHelper"] = new PageHelper <sal_plan>(plans, curPage, 3); } //查询日期和其他条件的情况 else { DateTime start_pla_date = Convert.ToDateTime(forms["start_pla_date"]); DateTime end_pla_date = Convert.ToDateTime(forms["end_pla_date"]); var li = plans.Where(p => p.pla_date >= start_pla_date && p.pla_date <= end_pla_date).ToList(); ViewData["pagerHelper"] = new PageHelper <sal_plan>(li, curPage, 3); } return(View(search)); }
/// <summary> /// 计划详细(归档) /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult PlanInfo(int?id) { ViewData["curSal"] = new sal_chanceService().GetSalById(id.Value); ViewData["pagerHelper"] = new PageHelper <sal_plan>(new sal_planService().GetPlanBySalId(id.Value), 0, 3); return(View()); }