public ActionResult DetailCreate(Model.SubMedicineProject model) { string pId = (string)Session["pid"]; int pid = Convert.ToInt32(pId); model.ProjectId = pid; bllSubMedicine.Add(model); string sqlString = " ProjectId=" + pid; //select * from SubMedicineProject where ProjectId=projectId; //get detail List <Model.SubMedicineProject> subMedicineList = bllSubMedicine.GetModelList(sqlString); string content = ""; foreach (Model.SubMedicineProject t in subMedicineList) { content += t.CommonName + t.Dose + "," + t.Usage + " "; } content = content.Trim().Replace(' ', '+'); //get project Model.MedicineProject usingProjectModel = bllMedicine.GetModel(pid); usingProjectModel.ProjectContent = content; bllMedicine.Update(usingProjectModel); return(this.Json(new { result = 1, data = "" })); }
public ActionResult DetailDelete(int id) { Model.SubMedicineProject temp = bllSubMedicine.GetModel(id); bool r = bllSubMedicine.Delete(id); string pId = temp.ProjectId.Value.ToString(); string sqlString = " ProjectId=" + pId; List <Model.SubMedicineProject> subMedicineList = bllSubMedicine.GetModelList(sqlString); string content = ""; foreach (Model.SubMedicineProject t in subMedicineList) { content += t.CommonName + t.Dose + "," + t.Usage + " "; } content = content.Trim().Replace(' ', '+'); //get project Model.MedicineProject usingProjectModel = bllMedicine.GetModel(Convert.ToInt32(pId)); usingProjectModel.ProjectContent = content; bllMedicine.Update(usingProjectModel); return(this.Json(new { result = r?1:0, data = "" })); }
public ActionResult DetailEdit(int id, int status, Model.SubMedicineProject model) { int i = id; if (status == 1) { Model.SubMedicineProject m = bllSubMedicine.GetModel(id); if (m == null) { return(this.Json(new { result = 0, data = "" })); } else { return(this.Json(new { result = 1, data = m }, JsonRequestBehavior.AllowGet)); } } else { bool r = bllSubMedicine.Update(model); int projectId; if (model.ProjectId.HasValue) { projectId = model.ProjectId.Value; string sqlString = " ProjectId=" + projectId; //select * from SubMedicineProject where ProjectId=projectId; //get detail List <Model.SubMedicineProject> subMedicineList = bllSubMedicine.GetModelList(sqlString); string content = ""; foreach (Model.SubMedicineProject t in subMedicineList) { content += t.CommonName + t.Dose + "," + t.Usage + " "; } content = content.Trim().Replace(' ', '+'); //get project Model.MedicineProject usingProjectModel = bllMedicine.GetModel(projectId); usingProjectModel.ProjectContent = content; bllMedicine.Update(usingProjectModel); } return(this.Json(new { result = r?1:0, data = "" })); } }