Exemple #1
0
        private JavaScriptObject CardUserWaterLog(HttpRequest request)
        {
            string SerialNumber          = request["SerialNumber"] ?? "";
            string UserNo                = request["UserNo"] ?? "";
            string DeviceNo              = request["DeviceNo"] ?? "";
            string StartTime             = request["StartTime"] ?? "";
            string StartResidualWater    = request["StartResidualWater"] ?? "";
            string StartResidualElectric = request["StartResidualElectric"] ?? "";
            string EndTime               = request["EndTime"] ?? "";
            string EndResidualWater      = request["EndResidualWater"] ?? "";
            string EndResidualElectric   = request["EndResidualElectric"] ?? "";

            JavaScriptObject result = new JavaScriptObject();

            result.Add("Result", false);
            result.Add("Message", "");

            try
            {
                CardUser cu = CardUserModule.GetCardUserBySerialNumber(SerialNumber);
                if (cu == null)
                {
                    result["Message"] = "卡序列号" + SerialNumber + "的用水户不存在!";
                    return(result);
                }

                Device device = DeviceModule.GetDeviceByFullDeviceNo(DeviceNo);
                if (device == null)
                {
                    result["Message"] = "设备长编号" + DeviceNo + "不存在!";
                    return(result);
                }

                CardUserWaterLog cuwLog = new CardUserWaterLog();
                cuwLog.SerialNumber          = SerialNumber;
                cuwLog.WateUserId            = cu.WaterUserId;
                cuwLog.UserNo                = UserNo;
                cuwLog.DeviceId              = device.Id;
                cuwLog.DeviceNo              = DeviceNo;
                cuwLog.StartTime             = DateTime.Parse(StartTime);
                cuwLog.StartResidualWater    = decimal.Parse(StartResidualWater);
                cuwLog.StartResidualElectric = decimal.Parse(StartResidualElectric);
                cuwLog.EndTime               = DateTime.Parse(EndTime);
                cuwLog.EndResidualWater      = decimal.Parse(EndResidualWater);
                cuwLog.EndResidualElectric   = decimal.Parse(EndResidualElectric);
                cuwLog.WaterUsed             = decimal.Parse(EndResidualWater) - decimal.Parse(StartResidualWater);
                cuwLog.ElectricUsed          = decimal.Parse(EndResidualElectric) - decimal.Parse(StartResidualElectric);
                cuwLog.Duration              = Convert.ToDecimal((DateTime.Parse(EndTime) - DateTime.Parse(StartTime)).TotalSeconds);
                CardUserWaterLogModule.AddCardUserWaterLog(cuwLog);

                result["Result"] = true;
            }
            catch (Exception ex)
            {
                result["Message"] = "用户用水保存出错!";
                myLogger.Error(ex.Message);
            }

            return(result);
        }
        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));
        }