/// <summary> /// 添加客户的地址 /// </summary> /// <param name="cstmrAddr"></param> /// <returns></returns> public ActionResult Add(CustomerAddr cstmrAddr) { CustomerAddr retVal = null; ISession s = null; ITransaction trans = null; try { s = HibernateOper.GetCurrentSession(); trans = s.BeginTransaction(); //查找客户ID if (cstmrAddr.AddrCode != null && !cstmrAddr.AddrCode.Equals("")) { cstmrAddr.Addr = PojoUtil.GetAddrForCode(s, cstmrAddr.AddrCode); LocationUtil.Location loc = LocationUtil.GetLocation(cstmrAddr.Addr + cstmrAddr.Location); if (loc != null) { cstmrAddr.Lat = loc.lat; cstmrAddr.Lng = loc.lng; } } string openId = cstmrAddr.Cstmr.OpenId; cstmrAddr.Cstmr = PojoUtil.GetCust(s, openId); if (cstmrAddr.Cstmr == null) { if (openId == null || openId.Equals("")) { //客户不存在 throw new Exceptions.CstmrIsNotExistsException(); } Customer cstmr = new Customer(); cstmr.OpenId = openId; s.Save(cstmr); cstmrAddr.Cstmr = cstmr; } s.Save(cstmrAddr); trans.Commit(); retVal = cstmrAddr; } catch (Exception e) { if (trans != null) { trans.Rollback(); } throw e; } return(Json(retVal)); }
public ActionResult Update(Company company) { //根据地址码获取地址 company.Addr = PojoUtil.GetAddrForCode(HibernateOper, company.AddrCode); LocationUtil.Location loc = LocationUtil.GetLocation(company.Addr + company.Location); if (loc != null) { company.Lat = loc.lat; company.Lng = loc.lng; } return(Json(companyOper.Update(company))); }
public ActionResult Update(Garden garden) { //根据地址码获取地址 garden.Addr = PojoUtil.GetAddrForCode(HibernateOper, garden.AddrCode); LocationUtil.Location loc = LocationUtil.GetLocation(garden.Addr + garden.Location); if (loc != null) { garden.Lat = loc.lat; garden.Lng = loc.lng; } return(Json(gardenOper.Update(garden))); }
public ActionResult Update(Storehouse storehouse) { //根据地址码获取地址 storehouse.Addr = PojoUtil.GetAddrForCode(HibernateOper, storehouse.AddrCode); LocationUtil.Location loc = LocationUtil.GetLocation(storehouse.Addr + storehouse.Location); if (loc != null) { storehouse.Lat = loc.lat; storehouse.Lng = loc.lng; } return(Json(storehouseOper.Update(storehouse, delegate(object sender, ISession session) { //判断是否存在库存Code IsExistsCode(session, storehouse); } ))); }
public ActionResult Update(Department department) { //根据地址码获取地址 department.Addr = PojoUtil.GetAddrForCode(HibernateOper, department.AddrCode); LocationUtil.Location loc = LocationUtil.GetLocation(department.Addr + department.Location); if (loc != null) { department.Lat = loc.lat; department.Lng = loc.lng; } return(Json(departmentOper.Update(department, delegate(object sender, ISession session) { //判断是否存在部门Code IsExistsCode(session, department); } ))); }
public ActionResult Update(VendorInfo vendorInfo) { //根据地址码获取地址 vendorInfo.Addr = PojoUtil.GetAddrForCode(HibernateOper, vendorInfo.AddrCode); LocationUtil.Location loc = LocationUtil.GetLocation(vendorInfo.Addr + vendorInfo.Location); if (loc != null) { vendorInfo.Lat = loc.lat; vendorInfo.Lng = loc.lng; } return(Json(vendorInfoOper.Update(vendorInfo, delegate(object sender, ISession session) { //判断是否存在部门Code IsExistsCode(session, vendorInfo); } ))); }
public ActionResult Update(Employee employee) { //根据地址码获取地址 employee.Addr = PojoUtil.GetAddrForCode(HibernateOper, employee.AddrCode); LocationUtil.Location loc = LocationUtil.GetLocation(employee.Addr + employee.Location); if (loc != null) { employee.Lat = loc.lat; employee.Lng = loc.lng; } return(Json(employeeOper.Update(employee, delegate(object sender, ISession session) { //判断是否存在部门Code IsExistsCode(session, employee); } ))); }