using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using AIMSModel; using DevComponents.DotNetBar.SuperGrid; using AIMSExtension; using AIMSBLL; using System.Drawing.Drawing2D; using DCSoftDotfuscate; using System.Net; namespace AIMS.OremrUserControl { public partial class ucPlanOperationRoomCard : UserControl { public DateTime PlanOperationTime; public int OperationRoomId; public string OperationRoomName; public OperationRoom operationRoom; public List operationRooms; public SuperGridControl dgvDetail; //手术间对应患者列表 public DataTable pDataTable; public ucPlanOperationRoomCard() { InitializeComponent(); } //private void SetWindowRegion() //{ // GraphicsPath FormPath = new GraphicsPath(); // Rectangle rect = new Rectangle(0, 4, this.Width, this.Height - 4); // FormPath = GetRoundedRectPath(rect, 10); // this.Region = new Region(FormPath); //} //private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius) //{ // int diameter = radius; // Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter)); // GraphicsPath path = new GraphicsPath(); // //左上角 // path.AddArc(arcRect, 180, 90); // //右上角 // arcRect.X = rect.Right - diameter; // path.AddArc(arcRect, 270, 90); // //右下角 // arcRect.Y = rect.Bottom - diameter; // path.AddArc(arcRect, 0, 90); // //左下角 // arcRect.X = rect.Left; // path.AddArc(arcRect, 90, 90); // path.CloseFigure(); // return path; //} //protected override void OnResize(System.EventArgs e) //{ // this.Region = null; // SetWindowRegion(); //} public ucPlanOperationRoomCard(OperationRoom _operationRoom, List _operationRooms) { InitializeComponent(); operationRooms = _operationRooms; operationRoom = _operationRoom; this.labelName.Text = _operationRoom.Name; this.OperationRoomId = _operationRoom.Id.Value; if (RoomCardManage.IsAllowAns == false) { tsDelAnes.Visible = false; } if (RoomCardManage.IsAllowNur == false) { tsDelNs1.Visible = false; tsDelNs2.Visible = false; } if (!RoomCardManage.IsAllowPat ) { tsUpdateRoom.Visible = false; tsDel.Visible = false; } } public void RaiseDataSavedEvent() { RoomCardManage.OnDataSaved.Invoke(this, operationRoom, false, 0); } public void RaiseDataSavedEvent2(OperationRoom opeRoom) { RoomCardManage.OnDataSaved.Invoke(this, opeRoom, false, 0); } public void UcPlanOperationRoomCard_Click(object sender, EventArgs e) { ucPlanOperationRoomCard operationRoomClicked = GetParentRoomCards(sender as Control); ShowDetial(operationRoomClicked); } public void ShowDetial(ucPlanOperationRoomCard operationRoomClicked) { if (operationRoomClicked != null) { if (operationRoomClicked != RoomCardManage.lastSelectOpeRoom) { if (RoomCardManage.lastSelectOpeRoom != null) RoomCardManage.lastSelectOpeRoom.panelExMain.Style.BackColor1.Color = System.Drawing.SystemColors.Control; operationRoomClicked.panelExMain.Style.BackColor1.Color = Color.Khaki; RoomCardManage.lastSelectOpeRoom = operationRoomClicked; RoomCardManage.IsFillAll = true; } if (RoomCardManage.SelectIds != null && RoomCardManage.SelectDgv.Name == "dgvApplyOrDoctor") { if (RoomCardManage.SelectIds.Count > 0) { RoomCardManage.CallObjectEvent(RoomCardManage.SelectDgv, "OnCellDoubleClick", new DataGridViewCellEventArgs(1, RoomCardManage.SelectDgv.CurrentRow.Index)); } else FillRoomDetail(); } else FillRoomDetail(); } else { if (RoomCardManage.lastSelectOpeRoom != null) { FillRoomDetail(); } } } public ucPlanOperationRoomCard GetParentRoomCards(Control control) { if (control.Parent is ucPlanOperationRoomCard) { return control.Parent as ucPlanOperationRoomCard; } else { return GetParentRoomCards(control.Parent); } } //撤销排程 private void tsDel_Click(object sender, EventArgs e) { if (pDataTable.Rows.Count <= 0) return; if (pDataTable.Rows.Count > 0) { string patientname = ""; foreach (DataRow item in pDataTable.Rows) { if (!"1,2,3,4,5".Contains(item["StateId"].ToString())) patientname += item["PatientName"] + " "; } if (patientname != "") { MessageBox.Show("患者:" + patientname.Trim() + " 已手术 无法撤销!"); } } //AnesthesiaDoctor = null, TourNurse = null, InstrumentNurse = null, string DoctorNuresName = " PlanOperationTime = null,OperationRoomId = null, PlanOrder=null , State = 2 "; if (BOperationApply.SaveDoctorByRommTime(DoctorNuresName, PlanOperationTime, operationRoom.Id.Value) > 0) { foreach (DataRow item in pDataTable.Rows) { if ("1,2,3,4,5".Contains(item["StateId"].ToString())) { string OperationApplyId = item["ApplyId"].ToString(); BApplyPersonDuty.Delete(" PersonDutyId in(5,6,7,8,9,10) and OperationApplyId=" + OperationApplyId, null); } } BOperationApply.UpdteOperationOrder(PlanOperationTime, operationRoom.Id.Value); dgvDetail.PrimaryGrid.Rows.Clear(); lblNurse2.Text = "巡回护士"; lblNurse2.ForeColor = Color.Gray; lblNurse.Text = "洗手护士"; lblNurse.ForeColor = Color.Gray; lblAnesDoctors.Text = "麻醉医生"; lblAnesDoctors.ForeColor = Color.Gray; lblOpeDoctors.Text = "手术医生"; lblOpeDoctors.ForeColor = Color.Gray; RaiseDataSavedEvent(); MessageBox.Show(operationRoom.Name + "全部撤销成功!"); } } private void tsDelAnes_Click(object sender, EventArgs e) { if (pDataTable.Rows.Count <= 0) return; foreach (DataRow item in pDataTable.Rows) { string OperationApplyId = item["ApplyId"].ToString(); BApplyPersonDuty.Delete(" PersonDutyId in(5) and OperationApplyId=" + OperationApplyId, null); } lblAnesDoctors.Text = "麻醉医生"; lblAnesDoctors.ForeColor = Color.Gray; RoomCardManage.IsFillAll = true; RaiseDataSavedEvent(); MessageBox.Show("全部撤销麻醉成功!"); } private void tsDelNs1_Click(object sender, EventArgs e) { if (pDataTable.Rows.Count <= 0) return; foreach (DataRow item in pDataTable.Rows) { string OperationApplyId = item["ApplyId"].ToString(); BApplyPersonDuty.Delete(" PersonDutyId in(6) and OperationApplyId=" + OperationApplyId, null); } lblNurse.Text = "洗手护士"; lblNurse.ForeColor = Color.Gray; RoomCardManage.IsFillAll = true; RaiseDataSavedEvent(); MessageBox.Show("全部撤销洗手护士成功!"); } private void tsDelNs2_Click(object sender, EventArgs e) { if (pDataTable.Rows.Count <= 0) return; foreach (DataRow item in pDataTable.Rows) { string OperationApplyId = item["ApplyId"].ToString(); BApplyPersonDuty.Delete(" PersonDutyId in(7) and OperationApplyId=" + OperationApplyId, null); } lblNurse2.Text = "巡回护士"; lblNurse2.ForeColor = Color.Gray; RoomCardManage.IsFillAll = true; RaiseDataSavedEvent(); MessageBox.Show("全部撤销巡回护士成功!"); } public void LoadInfo(DataTable _dt) { pDataTable = _dt; labTabindex.Text = pDataTable.Rows.Count.ToString(); DrawRoomText(); if (_dt.Rows.Count == 0) { lblAnesDoctors.ForeColor = Color.Black; lblNurse.ForeColor = Color.Black; lblOpeDoctors.ForeColor = Color.Black; labelName.ForeColor = Color.Black; lblNurse2.ForeColor = Color.Black; labTabindex.ForeColor = Color.Black; } } public void FillRoomDetail() { dgvDetail.PrimaryGrid.Rows.Clear(); foreach (DataRow item in pDataTable.Rows) { dgvDetail.PrimaryGrid.Rows.Add(createGridRow(item)); } } private GridRow createGridRow(DataRow item) { string sOperationDoctor = item["OperationDoctor"].ToString(); string sAnesthesiaDoctor = item["AnesthesiaDoctor"].ToString(); string sInstrumentNurse = item["InstrumentNurse"].ToString(); string sTourNurse = item["TourNurse"].ToString(); GridRow grNew = new GridRow(item["ApplyId"].ToString(), item["PlanOrder"].ToString(), string.Format("{0}{1}", item["PatientName"].ToString(), ""), item["MdrecNo"].ToString(), item["ApplyDepName"].ToString() + "-" + item["SickBed"].ToString(), sOperationDoctor, item["ApplyOperationInfoName"].ToString(), DateTime.Parse(item["OrderOperationTime"].ToString()).ToString("HH:mm"), sAnesthesiaDoctor, sInstrumentNurse, sTourNurse, item["OperationRemark"].ToString(), "Χ", item["StateId"].ToString()); if (item["Contagion"].ToString() != "" && item["Contagion"].ToString() != "无" && item["Contagion"].ToString() != "未报") { grNew.CellStyles.Default.Background.Color1 = Color.Purple; } else if (item["OperationType"].ToString() == "日间") { grNew.CellStyles.Default.Background.Color1 = Color.DeepSkyBlue; } else if (item["OperationType"].ToString() == "急诊") { grNew.CellStyles.Default.Background.Color1 = Color.Red; } else { grNew.CellStyles.Default.Background.Color1 = Color.White; } return grNew; } Dictionary lstAnseDoctors; Dictionary lstNurse; Dictionary lstNurse2; /// /// 绘制手术间医生信息 /// public void DrawRoomText() { List lstOpeDoctors = new List(); lstAnseDoctors = new Dictionary(); lstNurse = new Dictionary(); lstNurse2 = new Dictionary(); bool isPassed = false; lblNurse2.Text = "巡回护士"; lblNurse2.ForeColor = Color.Gray; lblNurse.Text = "洗手护士"; lblNurse.ForeColor = Color.Gray; lblAnesDoctors.Text = "麻醉医生"; lblAnesDoctors.ForeColor = Color.Gray; lblOpeDoctors.Text = "手术医生"; lblOpeDoctors.ForeColor = Color.Gray; foreach (DataRow item in pDataTable.Rows) { string sOperationDoctor = item["OperationDoctor"].ToString(); if (!string.IsNullOrWhiteSpace(sOperationDoctor)) { sOperationDoctor.Split(',').ToList().ForEach(d => { if (!lstOpeDoctors.Contains(d)) lstOpeDoctors.Add(d); }); } string sAnesthesiaDoctor = item["AnesthesiaDoctor"].ToString(); if (!string.IsNullOrWhiteSpace(sAnesthesiaDoctor)) { List Anesthesia = sAnesthesiaDoctor.Split(',').ToList(); List AnesthesiaId = item["AnesthesiaDoctorId"].ToString().Split(',').ToList(); if (Anesthesia.Count > 0 && AnesthesiaId.Count > 0) { for (int i = 0; i < AnesthesiaId.Count; i++) { if (!lstAnseDoctors.ContainsKey(int.Parse(AnesthesiaId[i]))) lstAnseDoctors.Add(int.Parse(AnesthesiaId[i]), Anesthesia[i]); } } } string sInstrumentNurse = item["InstrumentNurse"].ToString(); if (!string.IsNullOrWhiteSpace(sInstrumentNurse)) { List Instrument = sInstrumentNurse.Split(',').ToList(); List InstrumentId = item["InstrumentNurseId"].ToString().Split(',').ToList(); if (Instrument.Count > 0 && InstrumentId.Count > 0) { for (int i = 0; i < InstrumentId.Count; i++) { if (!lstNurse.ContainsKey(int.Parse(InstrumentId[i]))) lstNurse.Add(int.Parse(InstrumentId[i]), Instrument[i]); } } } string sTourNurse = item["TourNurse"].ToString(); if (!string.IsNullOrWhiteSpace(sTourNurse)) { List Tour = sTourNurse.Split(',').ToList(); List TourId = item["TourNurseId"].ToString().Split(',').ToList(); if (Tour.Count > 0 && TourId.Count > 0) { for (int i = 0; i < TourId.Count; i++) { if (!lstNurse2.ContainsKey(int.Parse(TourId[i]))) lstNurse2.Add(int.Parse(TourId[i]), Tour[i]); } } } if (lstOpeDoctors.Count > 0) { lblOpeDoctors.Text = ""; lstOpeDoctors.ForEach(s => { lblOpeDoctors.Text += s + ","; }); lblOpeDoctors.Text = lblOpeDoctors.Text.TrimEnd(','); if (isPassed == true) lblOpeDoctors.ForeColor = Color.Red; else lblOpeDoctors.ForeColor = Color.Blue; } else { lblOpeDoctors.Text = "手术医生"; lblOpeDoctors.ForeColor = Color.Gray; } SetAnseDoctorsText(isPassed); SetNurse1Text(isPassed); SetNurse2Text(isPassed); if (int.Parse(item["StateId"].ToString()) >= 4) { lblAnesDoctors.ForeColor = Color.Red; lblNurse.ForeColor = Color.Red; lblOpeDoctors.ForeColor = Color.Red; labelName.ForeColor = Color.Red; lblNurse2.ForeColor = Color.Red; labTabindex.ForeColor = Color.Red; } else { lblAnesDoctors.ForeColor = Color.Black; lblNurse.ForeColor = Color.Black; lblOpeDoctors.ForeColor = Color.Black; labelName.ForeColor = Color.Black; lblNurse2.ForeColor = Color.Black; labTabindex.ForeColor = Color.Black; } } } private void SetAnseDoctorsText(bool isPassed) { if (lstAnseDoctors.Count > 0) { lblAnesDoctors.Text = ""; tsDelAnes.DropDownItems.Clear(); foreach (var ans in lstAnseDoctors) { ToolStripItem tspAnes = new ToolStripMenuItem(ans.Value); tspAnes.Tag = ans.Key; tspAnes.Click += TspAnes_Click; tsDelAnes.DropDownItems.Add(tspAnes); lblAnesDoctors.Text += ans.Value + ","; } lblAnesDoctors.Text = lblAnesDoctors.Text.TrimEnd(','); if (isPassed == true) lblAnesDoctors.ForeColor = Color.Red; else lblAnesDoctors.ForeColor = Color.Blue; } else { lblAnesDoctors.Text = "麻醉医生"; lblAnesDoctors.ForeColor = Color.Gray; tsDelAnes.DropDownItems.Clear(); } } private void SetNurse1Text(bool isPassed) { if (lstNurse.Count > 0) { lblNurse.Text = ""; tsDelNs1.DropDownItems.Clear(); foreach (var ins in lstNurse) { ToolStripItem tspIns = new ToolStripMenuItem(ins.Value); tspIns.Tag = ins.Key; tspIns.Click += TspNurse1_Click; tsDelNs1.DropDownItems.Add(tspIns); lblNurse.Text += ins.Value + ","; } lblNurse.Text = lblNurse.Text.TrimEnd(','); if (isPassed == true) lblNurse.ForeColor = Color.Red; else lblNurse.ForeColor = Color.Blue; } else { lblNurse.Text = "洗手护士"; lblNurse.ForeColor = Color.Gray; tsDelNs1.DropDownItems.Clear(); } } private void SetNurse2Text(bool isPassed) { if (lstNurse2.Count > 0) { lblNurse2.Text = ""; tsDelNs2.DropDownItems.Clear(); foreach (var ins2 in lstNurse2) { ToolStripItem tspNurse2 = new ToolStripMenuItem(ins2.Value); tspNurse2.Tag = ins2.Key; tspNurse2.Click += TspNurse2_Click; tsDelNs2.DropDownItems.Add(tspNurse2); lblNurse2.Text += ins2.Value + ","; } lblNurse2.Text = lblNurse2.Text.TrimEnd(','); if (isPassed == true) lblNurse2.ForeColor = Color.Red; else lblNurse2.ForeColor = Color.Blue; } else { lblNurse2.Text = "巡回护士"; lblNurse2.ForeColor = Color.Gray; tsDelNs2.DropDownItems.Clear(); } } private void TspAnes_Click(object sender, EventArgs e) { if (pDataTable.Rows.Count <= 0) return; int dict = int.Parse((sender as ToolStripItem).Tag.ToString()); foreach (DataRow item in pDataTable.Rows) { string OperationApplyId = item["ApplyId"].ToString(); BApplyPersonDuty.Delete(" PersonId='" + dict + "' and PersonDutyId in(5) and OperationApplyId=" + OperationApplyId, null); } lstAnseDoctors.Remove(dict); SetAnseDoctorsText(false); RaiseDataSavedEvent(); MessageBox.Show("撤销麻醉医生成功!"); } private void TspNurse1_Click(object sender, EventArgs e) { if (pDataTable.Rows.Count <= 0) return; int dict = int.Parse((sender as ToolStripItem).Tag.ToString()); foreach (DataRow item in pDataTable.Rows) { string OperationApplyId = item["ApplyId"].ToString(); BApplyPersonDuty.Delete(" PersonId='" + dict + "' and PersonDutyId in(6) and OperationApplyId=" + OperationApplyId, null); } lstNurse.Remove(dict); SetNurse1Text(false); RaiseDataSavedEvent(); MessageBox.Show("撤销洗手护士成功!"); } private void TspNurse2_Click(object sender, EventArgs e) { if (pDataTable.Rows.Count <= 0) return; int dict = int.Parse((sender as ToolStripItem).Tag.ToString()); foreach (DataRow item in pDataTable.Rows) { string OperationApplyId = item["ApplyId"].ToString(); BApplyPersonDuty.Delete(" PersonId='" + dict + "' and PersonDutyId in(7) and OperationApplyId=" + OperationApplyId, null); } lstNurse2.Remove(dict); SetNurse2Text(false); RaiseDataSavedEvent(); MessageBox.Show("撤销巡回护士成功!"); } private void ucPlanOperationRoomCard_Load(object sender, EventArgs e) { foreach (OperationRoom opeRoom in operationRooms) { if (opeRoom.Id == operationRoom.Id) continue; #region 全部 ToolStripItem toolStripItem1 = new ToolStripMenuItem(opeRoom.Name); toolStripItem1.Tag = opeRoom; toolStripItem1.Click += ToolStripItem1_Click; tsUpdateRoom.DropDownItems.Add(toolStripItem1); #endregion } } private void ToolStripItem1_Click(object sender, EventArgs e) { if (pDataTable.Rows.Count <= 0) return; OperationRoom opeRoom = (sender as ToolStripItem).Tag as OperationRoom; if (BOperationApply.SaveRoomOrderByTime(opeRoom.Id.Value, PlanOperationTime, operationRoom.Id.Value) > 0) { //刷新当前间台次 BOperationApply.UpdteOperationOrder(PlanOperationTime, operationRoom.Id.Value); //更新转入手术间台次 BOperationApply.UpdteOperationOrder(PlanOperationTime, opeRoom.Id.Value); dgvDetail.PrimaryGrid.Rows.Clear(); lblNurse2.Text = "巡回护士"; lblNurse2.ForeColor = Color.Gray; lblNurse.Text = "洗手护士"; lblNurse.ForeColor = Color.Gray; lblAnesDoctors.Text = "麻醉医生"; lblAnesDoctors.ForeColor = Color.Gray; lblOpeDoctors.Text = "手术医生"; lblOpeDoctors.ForeColor = Color.Gray; RaiseDataSavedEvent(); RaiseDataSavedEvent2(opeRoom); MessageBox.Show(operationRoom.Name + "-->" + opeRoom.Name + "换手术间成功!"); } } } }