public string GetHospitalDeptDetail(string callType, string xmlMessage) { string result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<" + callType + ">" + "<Result>False</Result>" + "<Description></Description></" + callType + ">"; string logID = Guid.NewGuid().ToString(); try { FileLogger.WriteLog(logID + "|Start:" + xmlMessage, 1, "", callType); if (Helper.CheckAuthCode(callType, xmlMessage)) { HospitalDepartment d = new HospitalDepartment(); result = d.GetDetail(xmlMessage); } } catch (Exception err) { result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<" + callType + ">" + "<Result>False</Result>" + "<Description>" + err.Message + "</Description></" + callType + ">"; } FileLogger.WriteLog(logID + "|End:" + result, 1, "", callType); return(result); }
public async Task <ActionResult> DeleteConfirmed(int id) { HospitalDepartment hospitalDepartment = await db.HospitalDepartments.FindAsync(id); db.HospitalDepartments.Remove(hospitalDepartment); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,DiseaseGroupId,HospitalBuildingId")] HospitalDepartment hospitalDepartment) { if (ModelState.IsValid) { db.Entry(hospitalDepartment).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.DiseaseGroupId = new SelectList(db.DiseaseGroups, "Id", "Name", hospitalDepartment.DiseaseGroupId); ViewBag.HospitalBuildingId = new SelectList(db.HospitalBuildings.ToList().Select(hd => new { hd.Id, Name = hd.HospitalBuildingName }), "Id", "Name"); return(View(hospitalDepartment)); }
// GET: HospitalDepartments/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HospitalDepartment hospitalDepartment = await db.HospitalDepartments.FindAsync(id); if (hospitalDepartment == null) { return(HttpNotFound()); } return(View(hospitalDepartment)); }
public string DeleteHospitalDept(string callType, string xmlMessage) { string result = "", id = ""; string logID = Guid.NewGuid().ToString(); try { FileLogger.WriteLog(logID + "|Start:" + xmlMessage, 1, "", callType); if (Helper.CheckAuthCode(callType, xmlMessage)) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlMessage); XmlNode vNode = doc.SelectSingleNode(callType + "/ID"); if (vNode == null || vNode.InnerText.Trim().Length == 0) { throw new Exception("ID不能为空"); } id = vNode.InnerText.Trim(); HospitalDepartment d = new HospitalDepartment(); if (d.Delete(xmlMessage) != "-1") { result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<" + callType + ">" + "<Result>True</Result>" + "<ID>" + id + "</ID>" + "<Description></Description></" + callType + ">"; } else { result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<" + callType + ">" + "<Result>False</Result>" + "<Description></Description></" + callType + ">"; } } } catch (Exception err) { result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<" + callType + ">" + "<Result>False</Result>" + "<Description>" + err.Message + "</Description></" + callType + ">"; } FileLogger.WriteLog(logID + "|End:" + result, 1, "", callType); return(result); }
// GET: HospitalDepartments/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HospitalDepartment hospitalDepartment = await db.HospitalDepartments.FindAsync(id); if (hospitalDepartment == null) { return(HttpNotFound()); } ViewBag.DiseaseGroupId = new SelectList(db.DiseaseGroups, "Id", "Name", hospitalDepartment.DiseaseGroupId); ViewBag.HospitalBuildingId = new SelectList(db.HospitalBuildings.ToList().Select(hd => new { hd.Id, Name = hd.HospitalBuildingName }), "Id", "Name"); return(View(hospitalDepartment)); }
public List <Doctor> ReadDoctorsInDepartment(HospitalDepartment department) { string query = string.Format("SELECT * FROM DoctorRepository WHERE Department={0}", (int)department); return(doctorReader.FetchDoctors(conString, query)); }
private void dbUpdateWorker_DoWork(object sender, DoWorkEventArgs e) { DbRecordChangesTask dbChangesTask = e.Argument as DbRecordChangesTask; try { using (MedicamentRemainsContext mc = new MedicamentRemainsContext()) { if (tableItem is Meter) { Meter record = dbChangesTask.DbRecord as Meter; switch (dbChangesTask.ChangesType) { case DbRecordChangesType.Create: dbUpdateWorker.ReportProgress(0, "Створення нової одиниці виміру..."); record.Name = record.Name.Trim(); mc.Meters.Add(record); break; case DbRecordChangesType.Update: dbUpdateWorker.ReportProgress(0, "Змінення одиниці виміру..."); record.Name = record.Name.Trim(); mc.Meters.Attach(record); mc.Entry <Meter>(record).State = System.Data.Entity.EntityState.Modified; break; case DbRecordChangesType.Remove: dbUpdateWorker.ReportProgress(0, "Видалення одиниці виміру..."); mc.Meters.Attach(record); mc.Meters.Remove(record); break; } } else if (tableItem is HospitalDepartment) { HospitalDepartment record = dbChangesTask.DbRecord as HospitalDepartment; switch (dbChangesTask.ChangesType) { case DbRecordChangesType.Create: dbUpdateWorker.ReportProgress(0, "Створення нового відділення..."); record.Name = record.Name.Trim(); mc.HospitalDepartments.Add(record); break; case DbRecordChangesType.Update: dbUpdateWorker.ReportProgress(0, "Змінення даних про відділення..."); record.Name = record.Name.Trim(); mc.HospitalDepartments.Attach(record); mc.Entry <HospitalDepartment>(record).State = System.Data.Entity.EntityState.Modified; break; case DbRecordChangesType.Remove: dbUpdateWorker.ReportProgress(0, "Видалення даних про відділення..."); mc.HospitalDepartments.Attach(record); mc.HospitalDepartments.Remove(record); break; } } else if (tableItem is MedicamentGroup) { MedicamentGroup record = dbChangesTask.DbRecord as MedicamentGroup; switch (dbChangesTask.ChangesType) { case DbRecordChangesType.Create: dbUpdateWorker.ReportProgress(0, "Створення нової группи медикаментів..."); record.Name = record.Name.Trim(); mc.MedicamentsGroups.Add(record); break; case DbRecordChangesType.Update: dbUpdateWorker.ReportProgress(0, "Змінення группи медикаментів..."); record.Name = record.Name.Trim(); mc.MedicamentsGroups.Attach(record); mc.Entry <MedicamentGroup>(record).State = System.Data.Entity.EntityState.Modified; break; case DbRecordChangesType.Remove: dbUpdateWorker.ReportProgress(0, "Видалення группи медикаментів..."); mc.MedicamentsGroups.Attach(record); mc.MedicamentsGroups.Remove(record); break; } } mc.SaveChanges(); if (tableItem is HospitalDepartment) { isDepartmentListUpdated = true; } dbUpdateWorker.ReportProgress(0, "Дані успішно збережені!"); } } catch (Exception ex) { dbUpdateWorker.ReportProgress(0, "Помилка: " + ex.Message); } Thread.Sleep(3000); }