public ActionResult System() { var Rate = new Rates(); var Quota = new Quotas(); var rate = Rate.GetLast(); if (rate == null) { rate = new Entity.T_Rate() { Rate_note = "暂未设置费率", }; } var quota = Quota.GetLast(); if (quota == null) { quota = new Entity.T_Quota() { Quota_note = "暂未设置基础配额" }; } ViewBag.rate = rate; ViewBag.quota = quota; return(View()); }
/// <summary> /// 更新基础配额信息 /// </summary> /// <param name="quota"></param> /// <returns></returns> public bool Update(Entity.T_Quota quota) { if (quota.Quota_id < 1) { return(Add(quota)); } return(Db.Updateable(quota).ExecuteCommand() > 0 ? true : false); }
public void Quota(FormCollection collection) { var msg = new Msg(); var Quota = new Quotas(); var quota = new Entity.T_Quota(); try { quota.Quota_cold_water_value = Convert.ToSingle(collection["cold_water_value"]); quota.Quota_hot_water_value = Convert.ToSingle(collection["hot_water_value"]); quota.Quota_electric_value = Convert.ToSingle(collection["electric_value"]); quota.Quota_is_active = Convert.ToBoolean(collection["is_active"]); quota.Quota_note = collection["note"]; /// 检查输入 if (quota.Quota_cold_water_value < 0 || quota.Quota_cold_water_value > 99999) { throw new Exception("冷水配额应在0~99999之间"); } if (quota.Quota_hot_water_value < 0 || quota.Quota_hot_water_value > 99999) { throw new Exception("热水配额应在0~99999之间"); } if (quota.Quota_electric_value < 0 || quota.Quota_electric_value > 99999) { throw new Exception("电力配额应在0~99999之间"); } /// 保存数据 if (Quota.Update(quota)) { msg.Message = "保存成功"; } else { throw new Exception("发生未知错误,保存失败"); } } catch (Exception ex) { msg.Code = -1; msg.Message = ex.Message; } finally { Response.Write(msg.ToJson()); Response.End(); } }
public bool Add(Entity.T_Quota quota) { return(Db.Insertable(quota).ExecuteCommand() > 0 ? true : false); }