public string WriteOffWaterUserByUserSerialNumber(string loginIdentifer, string userSerialNumber) { JavaScriptObject obj2 = new JavaScriptObject(); obj2.Add("Result", false); obj2.Add("Message", ""); try { ResMsg msg = CommonUtil.CheckLoginState(loginIdentifer, true); if (!msg.Result) { obj2["Message"] = msg.Message; return(JavaScriptConvert.SerializeObject(obj2)); } LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer); if ((userSerialNumber == null) || (userSerialNumber.Trim() == "")) { obj2["Message"] = "用户卡号不能为空"; return(JavaScriptConvert.SerializeObject(obj2)); } CardUser cu = CardUserModule.GetCardUserBySerialNumber(userSerialNumber); if (cu == null) { obj2["Message"] = "卡号为" + userSerialNumber + "的用户卡不存在"; return(JavaScriptConvert.SerializeObject(obj2)); } WaterUser wui = WaterUserModule.GetWaterUserById(cu.WaterUserId); if (wui == null) { obj2["Message"] = "卡号为" + userSerialNumber + "的用水户不存在"; return(JavaScriptConvert.SerializeObject(obj2)); } ResMsg msg1 = WaterUserModule.WriteOffWaterUserById(cu.WaterUserId); if (msg1.Result)//msg.Result { obj2["Result"] = true; } else { obj2["Message"] = msg.Message; } try { //添加日志 WaterUserLog log = new WaterUserLog(); log.WaterUserId = wui.id; log.LogUserId = loginUser.UserId; log.LogUserName = loginUser.LoginName; log.LogAddress = ToolsWeb.GetIP(context.Request); log.LogTime = loginUser.LastOperateTime; log.LogType = "注销"; log.LogContent = msg.Message; log.UserName = wui.UserName; log.Password = wui.Password; log.DistrictId = wui.DistrictId; log.TrueName = wui.TrueName; log.IdentityNumber = wui.IdentityNumber; log.Telephone = wui.Telephone; log.Address = wui.Address; log.WaterQuota = wui.WaterQuota; log.ElectricQuota = wui.ElectricQuota; log.Remark = wui.Remark; log.水价ID = wui.水价ID; log.电价ID = wui.电价ID; log.State = wui.State; WaterUserLogModule.Add(log); } catch { } } catch (Exception exception) { obj2["Message"] = exception.Message; } return(JavaScriptConvert.SerializeObject(obj2)); }
public string AddWaterUser(string loginIdentifer, string waterUserJson) { JavaScriptObject obj2 = new JavaScriptObject(); obj2.Add("Result", false); obj2.Add("Message", ""); try { ResMsg msg = CommonUtil.CheckLoginState(loginIdentifer, true); if (!msg.Result) { obj2["Message"] = msg.Message; return(JavaScriptConvert.SerializeObject(obj2)); } LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer); string message = msg.Message; JavaScriptObject obj3 = (JavaScriptObject)JavaScriptConvert.DeserializeObject(waterUserJson); if (obj3 == null) { obj2["Message"] = "参数waterUserJson格式不正确"; return(JavaScriptConvert.SerializeObject(obj2)); } WaterUser wui = new WaterUser(); wui.UserName = obj3["名称"].ToString(); wui.Password = ""; wui.TrueName = ""; wui.DistrictId = long.Parse(obj3["管理ID"].ToString()); wui.IdentityNumber = obj3["身份证号"].ToString(); wui.Telephone = obj3["电话"].ToString(); wui.Address = obj3["地址"].ToString(); wui.State = "正常"; wui.WaterQuota = decimal.Parse(obj3["用水定额"].ToString()); wui.ElectricQuota = decimal.Parse(obj3["用电定额"].ToString()); wui.水价ID = int.Parse(obj3["水价ID"].ToString()); wui.电价ID = int.Parse(obj3["电价ID"].ToString()); if (WaterUserModule.ExistsUserName(wui.DistrictId, wui.UserName)) { obj2["Message"] = "存在相同户名"; return(JavaScriptConvert.SerializeObject(obj2)); } if (WaterUserModule.ExistsIdentityNumber(wui.IdentityNumber)) { obj2["Message"] = "存在相同身份证号"; return(JavaScriptConvert.SerializeObject(obj2)); } if (WaterUserModule.ExistsTelephone(wui.Telephone)) { obj2["Message"] = "存在相同身份证号"; return(JavaScriptConvert.SerializeObject(obj2)); } msg = WaterUserModule.AddWaterUser(wui); if (msg.Result) { obj2["Result"] = true; } else { obj2["Message"] = msg.Message; } try { //添加日志 WaterUserLog log = new WaterUserLog(); log.WaterUserId = wui.id; log.LogUserId = loginUser.UserId; log.LogUserName = loginUser.LoginName; log.LogAddress = ToolsWeb.GetIP(context.Request); log.LogTime = loginUser.LastOperateTime; log.LogType = "添加"; log.LogContent = msg.Message; log.UserName = wui.UserName; log.Password = wui.Password; log.DistrictId = wui.DistrictId; log.TrueName = wui.TrueName; log.IdentityNumber = wui.IdentityNumber; log.Telephone = wui.Telephone; log.Address = wui.Address; log.WaterQuota = wui.WaterQuota; log.ElectricQuota = wui.ElectricQuota; log.Remark = wui.Remark; log.水价ID = wui.水价ID; log.电价ID = wui.电价ID; log.State = wui.State; WaterUserLogModule.Add(log); } catch { } } catch (Exception exception) { obj2["Message"] = exception.Message; } return(JavaScriptConvert.SerializeObject(obj2)); }