public void ProcessRequest(HttpContext context) { NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser; context.Response.ContentType = "text/plain"; string mu = context.Request.Form["measureUnit"]; NFMT.Common.ResultModel result = new NFMT.Common.ResultModel(); if (string.IsNullOrEmpty(mu)) { result.Message = "修改数据不能为空"; context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result)); context.Response.End(); } try { System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); NFMT.Data.Model.MeasureUnit measureUnit = serializer.Deserialize<NFMT.Data.Model.MeasureUnit>(mu); if (measureUnit == null) { result.Message = "数据错误"; context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result)); context.Response.End(); } NFMT.Data.BLL.MeasureUnitBLL bll = new NFMT.Data.BLL.MeasureUnitBLL(); result = bll.Update(user, measureUnit); if (result.ResultStatus == 0) { result.Message = "修改成功"; } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result)); }
public void ProcessRequest(HttpContext context) { NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser; context.Response.ContentType = "text/plain"; string muName = context.Request.Form["muName"]; string transformRate = context.Request.Form["transformRate"]; string baseId = context.Request.Form["baseId"]; int corpId = 0; int id = 0; string resultStr = "修改失败"; if (string.IsNullOrEmpty(context.Request.Form["id"])) { resultStr = "id未知"; context.Response.Write(resultStr); context.Response.End(); } if (!int.TryParse(context.Request.Form["id"], out id)) { resultStr = "id未知"; context.Response.Write(resultStr); context.Response.End(); } if (string.IsNullOrEmpty(muName)) { resultStr = "联系人姓名不能为空"; context.Response.Write(resultStr); context.Response.End(); } if (!string.IsNullOrEmpty(context.Request.Form["corpId"])) { if (!int.TryParse(context.Request.Form["corpId"], out corpId)) { resultStr = "联系人公司转换错误"; context.Response.Write(resultStr); context.Response.End(); } } NFMT.Data.BLL.MeasureUnitBLL muBLL = new NFMT.Data.BLL.MeasureUnitBLL(); NFMT.Common.ResultModel result = muBLL.Get(user, id); if (result.ResultStatus != 0) { resultStr = "获取数据错误"; context.Response.Write(resultStr); context.Response.End(); } NFMT.Data.Model.MeasureUnit contact = result.ReturnValue as NFMT.Data.Model.MeasureUnit; if (contact != null) { contact.MUName = muName; //contact.TransformRate = transformRate; //contact.BaseId = baseId; //contact.CompanyId = corpId; result = muBLL.Update(user, contact); resultStr = result.Message; } context.Response.Write(resultStr); context.Response.End(); }