public JsonResult AddOrUpdate() { #region 权限控制 int[] iRangePage = { AddPageNodeId, EditPageNodeId, DetailPageNodeId }; int iCurrentPageNodeId = AddPageNodeId; int iCurrentButtonId = (int)EButtonType.Save; var tempNoAuth = Utits.IsOperateAuth(iRangePage, iCurrentPageNodeId, iCurrentButtonId); if (tempNoAuth.ErrorType != 1) { return(Json(tempNoAuth)); } #endregion #region AddOrUpdate Guid ID = RequestParameters.PGuid("ID"); Guid ddlOrgID = RequestParameters.PGuid("ddlOrgID"); string CustomerName = RequestParameters.Pstring("CustomerName"); int Age = RequestParameters.Pint("Age"); int CustomerGender = RequestParameters.Pint("CustomerGender"); string CustomerWedlock = RequestParameters.Pstring("CustomerWedlock"); string CustomerJG = RequestParameters.Pstring("CustomerJG"); string Address = RequestParameters.Pstring("Address"); string Company = RequestParameters.Pstring("Company"); string Phone = RequestParameters.Pstring("Phone"); string CustomerGSR = RequestParameters.Pstring("CustomerGSR"); DateTime?AdmissionDate = RequestParameters.PDateTime("AdmissionDate"); DateTime?DiagnosticDate = RequestParameters.PDateTime("DiagnosticDate"); string CustomerJJYW = RequestParameters.Pstring("CustomerJJYW"); string CustomerJJSW = RequestParameters.Pstring("CustomerJJSW"); int? CustomerYSLX_dic = RequestParameters.PintNull("CustomerYSLX_dic"); string CustomerYYBH = RequestParameters.Pstring("CustomerYYBH"); string CustomerSFWWYY = RequestParameters.Pstring("CustomerSFWWYY"); int? CustomerHLMC_dic = RequestParameters.PintNull("CustomerHLMC_dic"); string CustomerCardID = RequestParameters.Pstring("CustomerCardID"); int? CustomerType_dic = RequestParameters.PintNull("CustomerType_dic"); string CustomerSBKH = RequestParameters.Pstring("CustomerSBKH"); string CustomerMZ = RequestParameters.Pstring("CustomerMZ"); int? CustomerWHCD_dic = RequestParameters.PintNull("CustomerWHCD_dic"); string CustomerZW = RequestParameters.Pstring("CustomerZW"); int CustomerYLJSR = RequestParameters.Pint("CustomerYLJSR"); string CustomerZZDH = RequestParameters.Pstring("CustomerZZDH"); string CustomerYYZT = RequestParameters.Pstring("CustomerYYZT"); string CustomerSFBS = RequestParameters.Pstring("CustomerSFBS"); string CustomerSX = RequestParameters.Pstring("CustomerSX"); string CustomerZYBH = RequestParameters.Pstring("CustomerZYBH"); DateTime?CustomerYYSJ = RequestParameters.PDateTime("CustomerYYSJ"); DateTime?CustomerLYSJ = RequestParameters.PDateTime("CustomerLYSJ"); string CustomerLYYY = RequestParameters.Pstring("CustomerLYYY"); string CustomerYLBZ = RequestParameters.Pstring("CustomerYLBZ"); string CustomerXMPY = GetSpellCode(CustomerName); DateTime?CustomerBrith = RequestParameters.PDateTime("CustomerBrith"); Guid oldBednoID = RequestParameters.PGuid("oldBednoID"); Guid bednoID = RequestParameters.PGuid("bednoID"); string BedNumberName = RequestParameters.Pstring("BedNumberName"); string bednoText = RequestParameters.Pstring("bednoText"); string HeadImg = RequestParameters.Pstring("HeadImg"); string CustomerZZMM = RequestParameters.Pstring("CustomerZZMM"); string CustomerJYCD = RequestParameters.Pstring("CustomerJYCD"); string CustomerDlrXm = RequestParameters.Pstring("CustomerDlrXm"); string CustomerDlrTel = RequestParameters.Pstring("CustomerDlrTel"); string CustomerDlrDz = RequestParameters.Pstring("CustomerDlrDz"); string CustomerDlrGx = RequestParameters.Pstring("CustomerDlrGx"); string CustomerDlrYb = RequestParameters.Pstring("CustomerDlrYb"); string ddlCustomerHJDQ_dic = RequestParameters.Pstring("CustomerHJDQ_dic"); var cBll = new CustomerBll(); #region 判断 if (CustomerName.Length <= 0) { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "姓名不能为空."; return(Json(sRetrunModel)); } //var welfareCentreId = Utits.WelfareCentreID; //if (bednoID != Guid.Empty) //{ // bool isFlagValidation = false; // if (ID == Guid.Empty) // isFlagValidation = cBll.ValidationBedByCustomer(bednoID, welfareCentreId); // else // isFlagValidation = cBll.ValidationBedByCustomer(ID, bednoID, welfareCentreId); // if (!isFlagValidation) // { // var sRetrunModel = new ResultMessage(); // sRetrunModel.ErrorType = 0; // sRetrunModel.MessageContent = "床位已住人."; // return Json(sRetrunModel); // } //} #endregion var item = new tbCustomer(); item.ID = ID; ParamState = "1"; ParamID = item.ID.ToString(); item.Stage = (int)ECustomerType.RuYuan; item.OperateDate = DateTime.Now; item.CustomerName = CustomerName; item.BedNumber = bednoID == Guid.Empty ? "" : bednoText; item.BedID = bednoID; item.CustomerGender = CustomerGender; item.CustomerWedlock = CustomerWedlock; item.CustomerAge = Age; item.CustomerJG = CustomerJG; item.CustomerAddress = Address; item.CustomerCompany = Company; item.CustomerTel = Phone; item.CustomerGSR = CustomerGSR; item.AdmissionDate = AdmissionDate ?? DateTime.Now; item.DiagnosticDate = DiagnosticDate ?? DateTime.Now; item.CustomerCardID = CustomerCardID; item.CustomerType_dic = CustomerType_dic; item.CustomerSBKH = CustomerSBKH; item.CustomerMZ = CustomerMZ; item.CustomerWHCD_dic = CustomerWHCD_dic; item.CustomerZW = CustomerZW; item.CustomerYLJSR = CustomerYLJSR; item.CustomerZZDH = CustomerZZDH; item.CustomerYYZT = CustomerYYZT; item.CustomerSFBS = CustomerSFBS; item.CustomerSX = CustomerSX; item.CustomerXMPY = CustomerXMPY;//姓名拼音 item.CustomerZYBH = CustomerZYBH; item.CustomerYYSJ = CustomerYYSJ; item.CustomerLYSJ = CustomerLYSJ; item.CustomerLYYY = CustomerLYYY; item.CustomerYLBZ = CustomerYLBZ; item.CustomerJJYW = CustomerJJYW; item.CustomerJJSW = CustomerJJSW; item.CustomerYSLX_dic = CustomerYSLX_dic; item.CustomerYYBH = CustomerYYBH; item.CustomerSFWWYY = CustomerSFWWYY; item.CustomerHLMC_dic = CustomerHLMC_dic; item.CustomerBrith = CustomerBrith; item.BedNumberName = BedNumberName; item.CustomerHeadImg = HeadImg; item.CustomerZZMM = CustomerZZMM; item.CustomerJYCD = CustomerJYCD; item.CustomerDlrXm = CustomerDlrXm; item.CustomerDlrTel = CustomerDlrTel; item.CustomerDlrDz = CustomerDlrDz; item.CustomerDlrGx = CustomerDlrGx; item.CustomerDlrYb = CustomerDlrYb; item.CustomerHJDQ_dic = ddlCustomerHJDQ_dic; //item.WelfareCentreID = welfareCentreId; item.WelfareCentreID = ddlOrgID; bool IsFlag = cBll.AddOrUpdate(item, oldBednoID); //if (bednoID != oldBednoID) //{ // //BedStatus 1 有人住,0 没人住 // if (bednoID!=Guid.Empty) // { // var bedBll = new BedBll(); // bool IsBedFlag = bedBll.OperateBedStatus(bednoID,1); // } // if (oldBednoID != Guid.Empty) // { // var bedBll = new BedBll(); // bool IsBedFlag = bedBll.OperateBedStatus(oldBednoID, 0); // } //} if (IsFlag) { var cLog = new LogsBll(); cLog.Log(ParamID, ParamName, ParamState, Utits.CurrentUserID.ToString(), Utits.CurrentRealName.ToString(), Utits.WelfareCentreID.ToString(), Utits.ClientIPAddress.ToString()); var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 1; sRetrunModel.MessageContent = "操作成功."; return(Json(sRetrunModel)); } else { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "操作失败."; return(Json(sRetrunModel)); } #endregion }