public string UpdateNewFamilyInfo(string newLockId, string address, string familyName, string city, string ownerName, string ownerMobile, string ownerId, string ownerAddress, string homeStatus, string userId) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } NewLockManager managerNew = new NewLockManager(); Dictionary <string, string> ret = new Dictionary <string, string>(); if (string.Empty == newLockId) { ret.Add("ret", "1"); ret.Add("msg", "字段newLockId不允许为空!"); return(JSONHelper.ToJson(ret)); } //判断是否授权 if (managerNew.GetIsEnterprise(userId) == "2") { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权,请核对再操做!"); return(JSONHelper.ToJson(ret)); } //判断接口是否授权 if (!managerNew.GetIsInterfacePermissions("8", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } try { //字符串拼接 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("Address", address); dic.Add("FamilyName", familyName); dic.Add("City", city); dic.Add("EnterpriseHomeownerName", ownerName); dic.Add("EnterpriseHomeownerMobile", ownerMobile); dic.Add("EnterpriseHomeownerId", ownerId); dic.Add("EnterpriseHomeownerAddress", ownerAddress); dic.Add("EnterpriseHomeStatus", homeStatus); string sqlDate = string.Empty; string sqlDateE = string.Empty; string[] strArr = { "Address", "FamilyName", "City" }; foreach (KeyValuePair <string, string> array in dic) { if (array.Value != string.Empty) { if (((IList)strArr).Contains(array.Key)) { sqlDate += array.Key + "='" + array.Value + "',"; } else { if (array.Key == "EnterpriseHomeownerMobile" && !managerNew.IsTelephone(array.Value)) //手机号校验 { ret.Add("ret", "1"); ret.Add("msg", "房主手机号格式(ownerMobile)校验错误!"); return(JSONHelper.ToJson(ret)); } if (array.Key == "EnterpriseHomeownerId" && !managerNew.checkidcard(array.Value)) //身份证校验 { ret.Add("ret", "1"); ret.Add("msg", "房主身份证号(ownerId)格式校验错误!"); return(JSONHelper.ToJson(ret)); } if (array.Key == "EnterpriseHomeStatus" && array.Value != "1" && array.Value != "2") //房租类型校验 { ret.Add("ret", "1"); ret.Add("msg", "homeStatus参数值超出允许范围!"); return(JSONHelper.ToJson(ret)); } sqlDateE += array.Key + "='" + array.Value + "',"; } } } if (sqlDate != string.Empty) { sqlDate = sqlDate.Substring(0, sqlDate.Length - 1); string sql = "update Rent_NewLock_Process set " + sqlDate + " where NewLockID='" + newLockId + "'"; MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)); } if (sqlDateE != string.Empty) { sqlDateE = sqlDateE.Substring(0, sqlDateE.Length - 1); string sql = "update Enterprise_Homeowner_Info set " + sqlDateE + " where NewLockID='" + newLockId + "'"; MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)); } ret.Add("ret", "0"); ret.Add("msg", "修改成功!"); } catch (Exception ex) { ret.Add("ret", "1"); ret.Add("msg", ex.Message); } return(JSONHelper.ToJson(ret)); }
public string CreateHomeLock(string address, string familyName, string userId, string city, string ownerName, string ownerMobile, string ownerId, string ownerAddress, string homeStatus) { if (!authentication.ValideLockUser()) { return("{'headerError'}"); } Dictionary <string, string> ret = new Dictionary <string, string>(); try { NewLockManager manager = new NewLockManager(); //传值校验 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("address", address); dic.Add("familyName", familyName); dic.Add("userId", userId); dic.Add("city", city); dic.Add("ownerName", ownerName); dic.Add("ownerMobile", ownerMobile); dic.Add("ownerId", ownerId); dic.Add("ownerAddress", ownerAddress); dic.Add("homeStatus", homeStatus); string returnFiled = manager.checkIsNullFild(dic); if (returnFiled != string.Empty) { ret.Add("ret", "1"); ret.Add("msg", "字段" + returnFiled + "不允许为空!"); return(JSONHelper.ToJson(ret)); } if (manager.GetIsEnterprise(userId) == "2") { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权,请核对再操做!"); return(JSONHelper.ToJson(ret)); } //判断接口是否授权 if (!manager.GetIsInterfacePermissions("1", userId)) { ret.Add("ret", "1"); ret.Add("msg", "我公司暂无给贵公司授权该接口,请核对再操做!"); return(JSONHelper.ToJson(ret)); } if (!manager.checkidcard(ownerId)) //身份证格式校验 { ret.Add("ret", "1"); ret.Add("msg", "房主身份证号(ownerId)格式校验错误!"); return(JSONHelper.ToJson(ret)); } if (!manager.IsTelephone(ownerMobile)) //手机号格式校验 { ret.Add("ret", "1"); ret.Add("msg", "房主手机号格式(ownerMobile)校验错误!"); return(JSONHelper.ToJson(ret)); } if (homeStatus != "1" && homeStatus != "2") { ret.Add("ret", "1"); ret.Add("msg", "homeStatus参数值超出允许范围!"); return(JSONHelper.ToJson(ret)); } LogManager.WriteLog("Start......"); string deviceID = Guid.NewGuid().ToString("N"); string sql = string.Empty; //请求远程创建家庭接口 string familyReturn = manager.createHomeInfo(deviceID); LogManager.WriteLog("Start......" + familyReturn); Dictionary <string, object> returnInfo = new Dictionary <string, object>(); returnInfo = JSONHelper.FromJson <Dictionary <string, object> >(familyReturn); if (returnInfo["ret"].ToString() == "0") { string dateTime = DateTime.Now.ToString(); //信息记录 sql = "insert into Rent_NewLock_Process output inserted.NewLockId values('" + Guid.NewGuid().ToString() + "', '" + userId + "', '" + deviceID + "', '" + address + "', '','','true','','','','','" + dateTime + "','','" + familyName + "', '" + city + "')"; LogManager.WriteLog("SQL:" + sql); DataTable dt = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; sql = "select * from Rent_NewLock_Process where NewLockID='" + dt.Rows[0]["NewLockID"].ToString() + "'"; LogManager.WriteLog("SQL:" + sql); //锁房屋绑定 DataTable dtInfo = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0]; sql = "insert into Rent_Locks values('" + dtInfo.Rows[0]["DeviceID"].ToString() + "', 1, '0', 'NoConfiguration', '0', '" + dateTime + "', '0', '0', '" + dt.Rows[0]["NewLockID"].ToString() + "')"; LogManager.WriteLog("SQL:" + sql); MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)); //家庭信息创建 sql = "insert into Enterprise_Homeowner_Info values('" + Guid.NewGuid().ToString() + "', '" + ownerName + "', '" + ownerMobile + "', '" + ownerId + "', '" + ownerAddress + "', '" + homeStatus + "', '" + userId + "', '" + dt.Rows[0]["NewLockID"].ToString() + "', '" + dateTime + "', '', '', '')"; LogManager.WriteLog("SQL:" + sql); MySQLHelper.ExecuteNonQuery(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)); ret.Add("ret", "0"); ret.Add("msg", dt.Rows[0]["NewLockID"].ToString()); } else { ret.Add("ret", "1"); ret.Add("msg", returnInfo["msg"].ToString()); } } catch (Exception ex) { ret.Add("ret", "1"); ret.Add("msg", ex.Message); } return(JSONHelper.ToJson(ret)); }