public ActionResult VehicleDriverMapping(string id) { VehicleDriverMappingViewModel vd = new VehicleDriverMappingViewModel(); var vehicle = ApplicationConfigHelper.GetVehicleList().FirstOrDefault(m => m.ID.ToString() == id); vd.VID = vehicle.ID; vd.VehicleNo = vehicle.CarNo; //var driver = ApplicationConfigHelper.GetDriverList(); DriverSearchCondition ds = new DriverSearchCondition(); ds.VehicleID = id; //int pagesize = 17; var response = new DriverService().GetAllDriver(new GetDriverByConditionRequest() { SearchCondition = ds, PageIndex = vd.PageIndex, PageSize = UtilConstants.PAGESIZE, }); if (response.IsSuccess) { vd.Driver = response.Result.DriverCollection; vd.PageIndex = response.Result.PageIndex; vd.PageCount = response.Result.PageCount; } return(View(vd)); }
//查询 public IEnumerable <Driver> GetCRMDriverByConditionNoPaging(DriverSearchCondition SearchCondition) { string sqlWhere = this.GenGetDriverWhere(SearchCondition); DbParam[] dbParams = new DbParam[] { new DbParam("@Where", DbType.String, sqlWhere, ParameterDirection.Input) }; return(this.ExecuteDataTable("Proc_GetDriverByConditionNoPaging", dbParams).ConvertToEntityCollection <Driver>()); }
public IEnumerable <Driver> GetAllDrivers(DriverSearchCondition ds, int PageIndex, int PageSize, out int RowCount) { string Where = SqlWhere(ds); int tempRowCount = 0; DbParam[] dbParams = new DbParam[] { new DbParam("@Where", DbType.String, Where, ParameterDirection.Input), new DbParam("@PageIndex", DbType.Int32, PageIndex, ParameterDirection.Input), new DbParam("@PageSize", DbType.Int32, PageSize, ParameterDirection.Input), new DbParam("@RowCount", DbType.Int32, tempRowCount, ParameterDirection.Output) }; DataTable dt = this.ExecuteDataTable("Proc_GetAllDrivers", dbParams); RowCount = (int)dbParams[3].Value; return(dt.ConvertToEntityCollection <Driver>()); }
public ActionResult Index(string CarNo) { DriverIndexViewModel di = new DriverIndexViewModel(); di.Driver = new Driver(); DriverSearchCondition sc = new DriverSearchCondition(); di.SearchCondition = sc; if (!string.IsNullOrEmpty(CarNo)) { sc.DriverCarNo = CarNo; var response = new DriverService().GetDriverView(new VehicleMappingDriverRequest() { VehicleNo = CarNo }); di.CRMDriverCollection = response.Result.DriverCollection; di.PageIndex = response.Result.PageIndex; di.PageCount = response.Result.PageCount; } else { var result = new DriverService().GetDriverByCondition(new GetDriverByConditionRequest() { SearchCondition = di.SearchCondition, PageSize = UtilConstants.PAGESIZE, PageIndex = 0, }); if (result.IsSuccess) { di.CRMDriverCollection = result.Result.DriverCollection; di.UserID = base.UserInfo.ID.ToString(); di.PageIndex = result.Result.PageIndex; di.PageCount = result.Result.PageCount; } } //else //{ // di.SearchCondition = new DriverSearchCondition(); //} return(View(di)); }
private string SqlWhere(DriverSearchCondition ds) { StringBuilder sb = new StringBuilder(); if (!string.IsNullOrEmpty(ds.DriverName)) { IEnumerable <string> numbers = Enumerable.Empty <string>(); if (ds.DriverName.IndexOf("\n") > 0) { numbers = ds.DriverName.Split('\n').Select(s => { return(s.Trim()); }); } if (ds.DriverName.IndexOf(',') > 0) { numbers = ds.DriverName.Split(',').Select(s => { return(s.Trim()); }); } if (numbers != null && numbers.Any()) { numbers = numbers.Where(c => !string.IsNullOrEmpty(c)); } if (numbers != null && numbers.Any()) { sb.Append(" and DriverName in ( "); foreach (string s in numbers) { sb.Append("'").Append(s).Append("',"); } sb.Remove(sb.Length - 1, 1); sb.Append(" ) "); } else { sb.Append(" and DriverName like '%" + ds.DriverName.Trim() + "%' "); } } if (!string.IsNullOrEmpty(ds.VehicleID)) { sb.Append("and VID ='" + ds.VehicleID.Trim() + " ' "); } return(sb.ToString()); }
public ActionResult VehicleDriverMapping(VehicleDriverMappingViewModel vd) { DriverSearchCondition ds = new DriverSearchCondition(); ds.DriverName = vd.DriverName; var response = new DriverService().GetAllDrivers(new GetDriverByConditionRequest() { SearchCondition = ds, PageIndex = vd.PageIndex, PageSize = UtilConstants.PAGESIZE }); if (response.IsSuccess) { vd.Driver = response.Result.DriverCollection; vd.PageIndex = response.Result.PageIndex; vd.PageCount = response.Result.PageCount; } return(View(vd)); }
private string GenGetDriverWhere(DriverSearchCondition SearchCondition) { StringBuilder sb = new StringBuilder(); //司机姓名 if (!string.IsNullOrEmpty(SearchCondition.DriverName)) { sb.Append(" AND Driver.DriverName like '%").Append(SearchCondition.DriverName.Trim()).Append("%' "); } //物流公司 if (!string.IsNullOrEmpty(SearchCondition.DriverLogisticsCompany)) { sb.Append(" AND Driver.DriverLogisticsCompany like '%").Append(SearchCondition.DriverLogisticsCompany.Trim()).Append("%' "); } //联系电话 if (!string.IsNullOrEmpty(SearchCondition.DriverPhone)) { sb.Append(" AND Driver.DriverPhone like '%").Append(SearchCondition.DriverPhone.Trim()).Append("%' "); } //开始为虹迪服务日期 if (!string.IsNullOrEmpty(SearchCondition.StartServeForRunbowTime)) { sb.Append(" and Driver.DriverStartServeForRunbowDate>='").Append(SearchCondition.StartServeForRunbowTime).Append("'"); //sb.Append(" AND CRM_Driver.DriverStartServeForRunbowDate='").Append(SearchCondition.DriverStartServeForRunbowDate).Append("' "); } if (!string.IsNullOrEmpty(SearchCondition.EndServeForRunbowTime)) { sb.Append(" and Driver.DriverStartServeForRunbowDate<='").Append(SearchCondition.EndServeForRunbowTime).Append("'"); //sb.Append(" AND CRM_Driver.DriverStartServeForRunbowDate='").Append(SearchCondition.DriverStartServeForRunbowDate).Append("' "); } //身份证号码 if (!string.IsNullOrEmpty(SearchCondition.DriverIDCard)) { sb.Append(" AND Driver.DriverIDCard like '%").Append(SearchCondition.DriverIDCard.Trim()).Append("%' "); } //驾驶证档案号 if (!string.IsNullOrEmpty(SearchCondition.DriverCardNo)) { sb.Append(" AND Driver.DriverCardNo like '%").Append(SearchCondition.DriverCardNo.Trim()).Append("%' "); } //是否在服务中 if (!string.IsNullOrEmpty(SearchCondition.DriverIsServing)) { sb.Append(" AND Driver.DriverIsServing='").Append(SearchCondition.DriverIsServing.Trim()).Append("' "); } //驾照类型 if (!string.IsNullOrEmpty(SearchCondition.DriverCardType)) { sb.Append(" AND Driver.DriverCardType='").Append(SearchCondition.DriverCardType.Trim()).Append("' "); } //登记证签发地 if (!string.IsNullOrEmpty(SearchCondition.DriverRegistrationCardSignedAddress)) { sb.Append(" AND Driver.DriverRegistrationCardSignedAddress like '%").Append(SearchCondition.DriverRegistrationCardSignedAddress.Trim()).Append("%' "); } //服务区域 if (!string.IsNullOrEmpty(SearchCondition.DriverServiceArea)) { sb.Append(" AND Driver.DriverServiceArea like '%").Append(SearchCondition.DriverServiceArea.Trim()).Append("%' "); } //驾驶车辆牌号 if (!string.IsNullOrEmpty(SearchCondition.DriverCarNo)) { sb.Append(" AND Driver.DriverCarNo like '%").Append(SearchCondition.DriverCarNo.Trim()).Append("%' "); } //主要行驶路线 if (!string.IsNullOrEmpty(SearchCondition.DriverMainRoute)) { sb.Append(" AND Driver.DriverMainRoute like '%").Append(SearchCondition.DriverMainRoute).Append("%' "); } return(sb.ToString()); }