/// <summary> /// 添加用户 /// </summary> /// <param name="ctx">HTTP请求</param> private void AddUser(HttpContext ctx) { var vUser = Utils.UserInfo; var entity = new PiUserEntity { Code = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Code")), UserName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("UserName")), RealName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("RealName")), Gender = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Gender")), Mobile = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Mobile")), Birthday = PublicMethod.GetDateTime(WebCommon.StringHelper.GetRequestObject("Birthday")), Telephone = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Telephone")), Title = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Title")), Duty = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Duty")), QICQ = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("QICQ")), Email = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Email")), HomeAddress = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("HomeAddress")), Enabled = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Enabled")) == "on" ? 1 : 0, Description = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Description")), RoleId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vRoleId")), CompanyId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vCompanyId")), SubCompanyId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vSubCompanyId")), DepartmentId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vDepartmentId")), SubDepartmentId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vSubDepartmentId")), WorkgroupId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vWorkgroupId")) }; var pwd = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("UserPassword")); entity.UserPassword = pwd == string.Empty ? string.Empty : pwd; var vCompanyName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vCompanyName")); var vSubCompanyName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vSubCompanyName")); var vDepartmentName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vDepartmentName")); var vSubDepartmentName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vSubDepartmentName")); var vWorkgroupName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vWorkgroupName")); entity.CompanyName = vCompanyName == "请选择" ? string.Empty : vCompanyName; entity.SubCompanyName = vSubCompanyName == "请选择" ? string.Empty : vSubCompanyName; entity.DepartmentName = vDepartmentName == "请选择" ? string.Empty : vDepartmentName; entity.SubDepartmentName = vSubDepartmentName == "请选择" ? string.Empty : vSubDepartmentName; entity.WorkgroupName = vWorkgroupName == "请选择" ? string.Empty : vWorkgroupName; if (vUser != null) { entity.CreateBy = vUser.RealName; entity.CreateUserId = vUser.Id; } string statusCode; string statusMessage; //增加用户 var vReturnValue = RDIFrameworkService.Instance.UserService.AddUser(vUser, entity, out statusCode, out statusMessage); ctx.Response.Write(statusCode == StatusCode.OKAdd.ToString() ? new JsonMessage { Success = true, Data = "1", Message = statusMessage }.ToString() : new JsonMessage { Success = false, Data = "0", Message = statusMessage }.ToString()); }
private void AddProductInfo(HttpContext ctx, string jsonStr) { var jobj = JObject.Parse(jsonStr.Replace("\\", "")); if (jobj == null) { ctx.Response.Write("-1"); return; } string reutrnId = string.Empty; var vUser = Utils.UserInfo; var entityMain = new CASE_PRODUCTIN_MAINEntity { CODE = PublicMethod.GetString(jobj["CODE"]), INDATE = PublicMethod.GetDateTime(jobj["INDATE"]), INTYPE = PublicMethod.GetString(jobj["INTYPE"]), DEPOT = PublicMethod.GetString(jobj["DEPOT"]), CUSTODIAN = PublicMethod.GetString(jobj["CUSTODIAN"]), SUPPLIERNAME = PublicMethod.GetString(jobj["SUPPLIERNAME"]), CREATEBY = PublicMethod.GetString(jobj["CREATEBY"]) == "" ? vUser.UserName : PublicMethod.GetString(jobj["CREATEBY"]), CREATEUSERID = vUser.Id, CREATEON = PublicMethod.GetDateTime(jobj["CREATEON"]) ?? DateTime.Now, DESCRIPTION = PublicMethod.GetString(jobj["DESCRIPTION"]) }; var managerMain = new CASE_PRODUCTIN_MAINManager(this.dbHelper, vUser); reutrnId = managerMain.AddEntity(entityMain); if (!string.IsNullOrEmpty(reutrnId)) { var products = jobj["products"]; var subdatas = products.Select(data => new { FullName = data["FULLNAME"], UnitPrice = data["UNITPRICE"], State = data["STATE"], CategoryName = data["categoryName"], Category = data["CATEGORY"] }); foreach (var data in subdatas) { var entityDetail = new CASE_PRODUCTIN_DETAILEntity { CASE_PRODUCTIN_MAIN_ID = reutrnId, FULLNAME = PublicMethod.GetString(data.FullName), UNITPRICE = BusinessLogic.ConvertToNullableDecimal(data.UnitPrice), STATE = PublicMethod.GetString(data.State), CATEGORY = PublicMethod.GetString(data.Category), }; var managerDetail = new CASE_PRODUCTIN_DETAILManager(this.dbHelper, vUser); managerDetail.AddEntity(entityDetail); } ctx.Response.Write("1"); } else { ctx.Response.Write("0"); } }
/// <summary> /// 修改用户 /// </summary> /// <param name="ctx">HTTP请求</param> private void EditUser(HttpContext ctx) { var vUser = Utils.UserInfo; var vId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("id")); var entity = RDIFrameworkService.Instance.UserService.GetEntity(vUser, vId); if (entity == null) { ctx.Response.Write(new JsonMessage { Success = false, Data = "-1", Message = "更新失败,无更新的数据!" }.ToString()); return; } entity.UserName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("UserName")); entity.RealName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("RealName")); entity.Code = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Code")); entity.Gender = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Gender")); entity.Mobile = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Mobile")); entity.Birthday = PublicMethod.GetDateTime(WebCommon.StringHelper.GetRequestObject("Birthday")); entity.Telephone = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Telephone")); entity.Title = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Title")); entity.Duty = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Duty")); entity.QICQ = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("QICQ")); entity.Email = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Email")); var vCompanyName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vCompanyName")); var vSubCompanyName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vSubCompanyName")); var vDepartmentName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vDepartmentName")); var vSubDepartmentName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vSubDepartmentName")); var vWorkgroupName = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vWorkgroupName")); entity.CompanyName = vCompanyName == "请选择" ? string.Empty : vCompanyName; entity.SubCompanyName = vSubCompanyName == "请选择" ? string.Empty : vSubCompanyName; entity.DepartmentName = vDepartmentName == "请选择" ? string.Empty : vDepartmentName; entity.SubDepartmentName = vSubDepartmentName == "请选择" ? string.Empty : vSubDepartmentName; entity.WorkgroupName = vWorkgroupName == "请选择" ? string.Empty : vWorkgroupName; entity.HomeAddress = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("HomeAddress")); entity.Enabled = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Enabled")) == "on" ? 1 : 0; entity.Description = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Description")); entity.RoleId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vRoleId")); entity.CompanyId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vCompanyId")); entity.SubCompanyId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vSubCompanyId")); entity.DepartmentId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vDepartmentId")); entity.SubDepartmentId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vSubDepartmentId")); entity.WorkgroupId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vWorkgroupId")); if (vUser != null) { entity.ModifiedBy = vUser.RealName; entity.ModifiedUserId = vUser.Id; } try { string statusCode; string statusMessage; RDIFrameworkService.Instance.UserService.UpdateUser(vUser, entity, out statusCode, out statusMessage); ctx.Response.Write(statusCode == StatusCode.OKUpdate.ToString() ? new JsonMessage { Success = true, Data = "1", Message = statusMessage }.ToString() : new JsonMessage { Success = false, Data = "0", Message = statusMessage }.ToString()); } catch (Exception ex) { ctx.Response.Write(new JsonMessage { Success = false, Data = "-1", Message = "更新失败,错误信息为:" + ex.Message }.ToString()); } }
private void EditProductInfo(HttpContext ctx, string jsonStr, string keyId) { var jobj = JObject.Parse(jsonStr.Replace("\\", "")); if (jobj == null) { ctx.Response.Write("-1"); return; } var reutrnId = 0; var vUser = Utils.UserInfo; var managerMain = new CASE_PRODUCTIN_MAINManager(this.dbHelper, vUser); var entityMain = managerMain.GetEntity(keyId); if (entityMain == null) { ctx.Response.Write("-1"); return; } entityMain.CODE = PublicMethod.GetString(jobj["CODE"]); entityMain.INDATE = PublicMethod.GetDateTime(jobj["INDATE"]); entityMain.INTYPE = PublicMethod.GetString(jobj["INTYPE"]); entityMain.DEPOT = PublicMethod.GetString(jobj["DEPOT"]); entityMain.CUSTODIAN = PublicMethod.GetString(jobj["CUSTODIAN"]); entityMain.SUPPLIERNAME = PublicMethod.GetString(jobj["SUPPLIERNAME"]); entityMain.DESCRIPTION = PublicMethod.GetString(jobj["DESCRIPTION"]); reutrnId = managerMain.UpdateEntity(entityMain); if (reutrnId > 0) { var products = jobj["products"]; var subdatas = products.Select(data => new { Id = data["ID"], ReferId = data["CASE_PRODUCTIN_MAIN_ID"], FullName = data["FULLNAME"], UnitPrice = data["UNITPRICE"], State = data["STATE"], CategoryName = data["categoryName"], Category = data["CATEGORY"] }); var managerDetail = new CASE_PRODUCTIN_DETAILManager(this.dbHelper, vUser); foreach (var data in subdatas) { //TODO:情形一、新增的产品明细 if (string.IsNullOrEmpty(PublicMethod.GetString(data.Id))) { //增加 var entity = new CASE_PRODUCTIN_DETAILEntity { CASE_PRODUCTIN_MAIN_ID = entityMain.ID, FULLNAME = PublicMethod.GetString(data.FullName), UNITPRICE = BusinessLogic.ConvertToNullableDecimal(data.UnitPrice), STATE = PublicMethod.GetString(data.State), CATEGORY = PublicMethod.GetString(data.Category), }; managerDetail.AddEntity(entity); } //TODO:情形二、删除的产品明细、暂不处理.... //TODO:情形三、实行修改操作 var entityDetail = managerDetail.GetEntity(PublicMethod.GetString(data.Id)); if (entityDetail == null) { continue; } entityDetail.FULLNAME = PublicMethod.GetString(data.FullName); entityDetail.UNITPRICE = BusinessLogic.ConvertToNullableDecimal(data.UnitPrice); entityDetail.STATE = PublicMethod.GetString(data.State); entityDetail.CATEGORY = PublicMethod.GetString(data.Category); managerDetail.UpdateEntity(entityDetail); } ctx.Response.Write("1"); } else { ctx.Response.Write("0"); } }