/// <summary> /// 添加客户提交 /// </summary> /// <param name="cusandcar"></param> /// <returns></returns> public JsonResult AddCustomerSub(CustomerAndCar cusandcar) { ICustomerMgm customerMgm = new CustomerMgm(); ICarMgm carMgm = new CarMgm(); CustomerVO customer = new CustomerVO() { Name = cusandcar.Name, Sex = cusandcar.Sex, ICNo = cusandcar.ICNo, Birthday = cusandcar.Birthday, MobileNO = cusandcar.MobileNo, CreatorID = Emp.UserName, LastModifierID = Emp.UserName, CreatedDate = DateTime.Now, LastModifiedDate = DateTime.Now, }; CarVO car = new CarVO() { CarNo = cusandcar.Carno, Brand = cusandcar.Brand, CarModel = cusandcar.Carmodel, Capacity = cusandcar.Capacity, Color = cusandcar.Color, FrameNo = cusandcar.FrameNo, EngineNo = cusandcar.EngineNo, MaintainKM = cusandcar.Maintainkm, InsureDate = cusandcar.Insuredate, ASDate = cusandcar.Asdate, CreatorID = Emp.UserName, LastModifierID = Emp.UserName, CreatedDate = DateTime.Now, LastModifiedDate = DateTime.Now, }; ReturnedData data = new ReturnedData(); try { car.CustomerID = customerMgm.AddAllCustomer(customer, car); //carMgm.AddCar(car); data.Message = "客户添加成功"; data.Success = true; } catch (Exception ex) { data.Success = false; data.Message = "客户添加失败"; data.Error = ex.ToString(); } return Json(data, JsonRequestBehavior.AllowGet); }
/// <summary> /// 汽车修改提交 /// </summary> /// <param name="car"></param> /// <returns></returns> public JsonResult CarEdiSub(CarVO car) { ICarMgm carMgm = new CarMgm(); ReturnedData data = new ReturnedData(); try { car.LastModifierID = Emp.UserName; car.LastModifiedDate = DateTime.Now; carMgm.EditCar(car); data.Message = "车辆信息修改成功"; data.Success = true; } catch (Exception ex) { data.Success = false; data.Message = "车辆信息修改失败"; data.Error = ex.ToString(); } return Json(data, JsonRequestBehavior.AllowGet); }
/// <summary> /// 客户详细信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult CustomerDetails(int id) { var result = new CustomerAndCar(); if (id != -1) { ICustomerMgm couMgm = new CustomerMgm(); ICarMgm carMgm = new CarMgm(); CustomerVO customer = couMgm.GetCustomerByID(id); List<CarVO> car = new List<CarVO>(); if (customer != null) { car = carMgm.GetCarsByCustID(customer.CustomerID); result = GetcusAndcarObj(customer, car.FirstOrDefault()); } } return View(result); }
/// <summary> /// 删除客户 /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonResult DeleteCustomer(int id) { ICustomerMgm cusmgm = new CustomerMgm(); ICarMgm carmgm = new CarMgm(); ReturnedData data = new ReturnedData(); try { cusmgm.DelCustomer(id); data.Message = "客户删除成功"; data.Success = true; } catch (Exception ex) { data.Success = false; data.Message = "客户删除失败"; data.Error = ex.ToString(); } return Json(data, JsonRequestBehavior.AllowGet); }
/// <summary> /// 汽车信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult CusCarinfo(int id) { ////CarVO car = new CarVO(); ICarMgm carmgm = new CarMgm(); var result = carmgm.GetCarsByCustID(id); var car = new CarVO(); if (result.Count>0) { car = result.FirstOrDefault(); } car.CustomerID = id; return View(car); }