//备份 /* * public string upLoadData(UpLoadTerBind ut, string DeptId) * { * ISqlMapper NewMap = SqlMapper.Instance(); * NewMap.BeginTransaction(); * try * { * IMappedStatement im = NewMap.GetMappedStatement("CarType.SelectCarType"); * string aa = GetSql("CarType.SelectCarType", null, im); * * CarType ct = (CarType)ExecuteQueryForObjectTrans("CarType.SelectCarType", ut.CarType, NewMap); * CarInfo ci = (CarInfo)ExecuteQueryForObjectTrans("CarInfo.SelectCarInfo", ut.CarNo, NewMap); * * if (ct == null) * { * ct = new CarType(); * ct.TypeId = System.Guid.NewGuid().ToString(); * ct.TypeName = ut.CarType; * ct.DeptId = DeptId; * ct.TypeIsdel = "0"; * ExecuteInsertTrans("CarType.InsertCarType", ct, NewMap); * } * if(ci==null) * { * ci = new CarInfo(); * ci.CarId = System.Guid.NewGuid().ToString(); * ci.CarNo = ut.CarNo; * ci.TypeId = ct.TypeId; * ci.Businessdivisionid = DeptId; * if (ci.Businessdivisionid != null || ci.Businessdivisionid.Trim() != "") * { * GDAL.Basic.DeptInfoDao deptInfoBll = new GDAL.Basic.DeptInfoDao(); * DeptInfo di = deptInfoBll.GetDeptInfo(ci.Businessdivisionid); * ci.CarDeptcode = di.Businessdivisioncode; * } * ExecuteInsertTrans("CarInfo.InsertCarInfo", ci, NewMap); * } * * TerminalInfo ti = (TerminalInfo)ExecuteQueryForObjectTrans("TerminalInfo.SelectTerminalInfoByTerNo", ut.TerNo, NewMap); * if (ti == null) * { * NewMap.CommitTransaction(); * return "不存在终端号:"+ut.TerNo; * * } * else if ( ti.CarId !=null && ti.CarId.Trim() != "") * { * NewMap.CommitTransaction(); * return "已经被绑定:" + ti.TerNo; * } * else * { * ti.CarId = ci.CarId; * ExecuteUpdate("TerminalInfo.BindTerCar", ti); * NewMap.CommitTransaction(); * return "true"; * } * } * catch (Exception e) * { * NewMap.RollBackTransaction(); * return "false"; * } * } */ public string upLoadData(UpLoadTerBind ut, string DeptId) { ISqlMapper NewMap = SqlMapper.Instance(); try { NewMap.BeginTransaction(); //不加是否有这个车辆的判断 //CarInfo ci = (CarInfo)ExecuteQueryForObjectTrans("CarInfo.SelectCarInfo", ut.CarNo, NewMap); CarInfo ci = null; if (ci == null) { ci = new CarInfo(); ci.CarId = System.Guid.NewGuid().ToString(); ci.CarNo = ut.CarNo; if (ut.CarType != null && ut.CarType != "") { ci.TypeId = ut.CarType; //ct.TypeId; } //终端所属企业 ci.Businessdivisionid = (ut.BusinessDivisionId == "" || ut.BusinessDivisionId == null) ? DeptId : ut.BusinessDivisionId; if (ci.Businessdivisionid != null && ci.Businessdivisionid.Trim() != "") { GDAL.Basic.DeptInfoDao deptInfoBll = new GDAL.Basic.DeptInfoDao(); DeptInfo di = deptInfoBll.GetDeptInfoById(ci.Businessdivisionid); ci.CarDeptcode = di.Businessdivisioncode; } //++++++++++++++++++++++++++++++++++++++++++++++++ //新添加 //++++++++++++++++++++++++++++++++++++++++++++++++ if (ut.CarAdminName != null && ut.CarAdminName.Trim().Length > 0) { ci.CarAdminName = ut.CarAdminName; } if (ut.CarAdminCardId != null && ut.CarAdminCardId.Trim().Length > 0) { ci.CarAdminCardid = ut.CarAdminCardId; } ci.CarColor = ut.CarColor; ci.OwerAddress = ut.OwerAddress; ci.OwerPhone = ut.OwerPhone; ci.InstallName = ut.InstallName; ci.InstallAddress = ut.InstallAddress; ci.InstallPhone = ut.InstallPhone; ci.InstallPlace = ut.InstallPlace; ci.InstallTime = ut.InstallTime; ci.EntryName = ut.EntryName; ci.EntryPhone = ut.EntryPhone; ci.SafeOrder = ut.SafeOrder; ci.LoanMoney = ut.LoanMoney; ci.LoanYear = ut.LoanYear; ci.CarModel = ut.CarModel; ci.EngineNumber = ut.EngineNumber; ci.CarFrame = ut.CarFrame; ci.Description = ut.Description; ci.ContractNum = ut.ContractNum; //++++++++++++++++++++++++++++++++++++++++++++++++ ExecuteInsertTrans("CarInfo.InsertCarInfo", ci, NewMap); //添加用户自定义信息数据 //if (ut.FieldValuesList.Count > 0) //{ // foreach (FieldValues fv in ut.FieldValuesList) // { // //修正车辆ID属性 // fv.CarId = ci.CarId; // //保存 // ExecuteInsertTrans("FieldValues.InsertFieldValues", fv, NewMap); // } //} } TerminalInfo ti = (TerminalInfo)ExecuteQueryForObjectTrans("TerminalInfo.SelectTerminalInfoByTerNo", ut.TerNo, NewMap); if (ti == null) { NewMap.CommitTransaction(); return("不存在终端号:" + ut.TerNo); } else if (ti.CarId != null && ti.CarId.Trim() != "") { NewMap.CommitTransaction(); return("已经被绑定:" + ti.TerNo); } else { ti.CarId = ci.CarId; ExecuteUpdate("TerminalInfo.BindTerCar", ti); NewMap.CommitTransaction(); return("true"); } } catch (Exception e) { NewMap.RollBackTransaction(); return("false"); } }
public string upLoadData(UpLoadTerBind ut, string DeptId) { Hashtable htTerType = new Hashtable(); ProductsInfo pi = new ProductsInfo(); ProductsInfoDao _iProductsInfoDao = new ProductsInfoDao(); IList <ProductsInfo> lpt = _iProductsInfoDao.GetProductsInfoPage(pi); for (int n = 0; n < lpt.Count; n++) { if (!htTerType.ContainsKey(lpt[n].ProName)) { htTerType.Add(lpt[n].ProName, lpt[n].ProId); } } ISqlMapper NewMap = SqlMapper.Instance(); NewMap.BeginTransaction(); try { TerminalInfo ti = (TerminalInfo)ExecuteQueryForObjectTrans("TerminalInfo.SelectTerminalInfoByTerNo", ut.TerNo, NewMap); if (ti == null) { ti = new TerminalInfo(); ti.TerGuid = System.Guid.NewGuid().ToString(); ti.TerNo = ut.TerNo; ti.TerTypeid = htTerType[ut.TerType].ToString(); ti.TerSimcard = ut.SimCard; ti.TerInnettime = ut.TerInnettime; ti.DeptId = DeptId; if (DeptId != null && DeptId != "") { GDAL.Basic.DeptInfoDao deptInfoBll = new Basic.DeptInfoDao(); DeptInfo di = deptInfoBll.GetDeptInfoById(DeptId); ti.TerDeptcode = di.Businessdivisioncode; } ExecuteInsertTrans("TerminalInfo.InsertTerminalInfo", ti, NewMap); object count = ExecuteQueryForObjectTrans("OldterPostbacktimes.SelectOldterPostbacktimesCount", ut.TerNo, NewMap); if ((int)count == 0) { OldterPostbacktimes opt = new OldterPostbacktimes(); opt.Id = System.Guid.NewGuid().ToString(); opt.TerNo = ut.TerNo; opt.Updatetime = DateTime.Now; opt.Postbacktimes = 0; ExecuteInsertTrans("OldterPostbacktimes.InsertOldterPostbacktimes", opt, NewMap); } NewMap.CommitTransaction(); return("true"); } else { NewMap.RollBackTransaction(); return("false"); } } catch (Exception e) { NewMap.RollBackTransaction(); return("false"); } }