/// <summary> /// 根据SQL,获取实体数组 /// </summary> /// <param name="SQLString"></param> /// <returns></returns> public ArrayList myGetInfo(string SQLString) { ArrayList al = new ArrayList(); //执行查询语句 if (this.ExecQuery(SQLString) == -1) { this.Err = "获得注射信息时,执行SQL语句出错!" + this.Err; this.ErrCode = "-1"; return(null); } try { while (this.Reader.Read()) { #region 将结果转化为实体 Neusoft.HISFC.Models.Nurse.Seat info = new Neusoft.HISFC.Models.Nurse.Seat(); info.ID = this.Reader[0].ToString(); //诊台代码 info.Name = this.Reader[1].ToString(); //诊台名称 info.PRoom.InputCode = this.Reader[2].ToString(); //输入码 info.PRoom.ID = this.Reader[3].ToString(); //诊室代码 info.PRoom.Name = this.Reader[4].ToString(); //诊室名称 info.PRoom.IsValid = this.Reader[5].ToString(); //1有效/0无效 info.PRoom.Memo = this.Reader[6].ToString(); //备注 info.Oper.ID = this.Reader[7].ToString(); //操作员 info.Oper.OperTime = Neusoft.FrameWork.Function.NConvert.ToDateTime(this.Reader[8]); //操作时间 info.CurrentCount = Neusoft.FrameWork.Function.NConvert.ToInt32(this.Reader[9]); #endregion al.Add(info); } } //抛出错误 catch (Exception ex) { this.Err = "获得诊台信息时出错!" + ex.Message; this.ErrCode = "-1"; return(null); } this.Reader.Close(); this.ProgressBarValue = -1; return(al); }
/// <summary> /// 插入一条新的诊台信息 /// </summary> /// <param name="info"></param> /// <returns></returns> public int Insert(Neusoft.HISFC.Models.Nurse.Seat info) { string sql = ""; if (this.Sql.GetSql("Nurse.Seat.Insert", ref sql) == -1) { return(-1); } try { sql = string.Format(sql, info.ID, info.Name, info.PRoom.InputCode, info.PRoom.ID, info.PRoom.Name, info.PRoom.IsValid, info.Memo, info.Oper.ID, info.Oper.OperTime); } catch (Exception e) { this.Err = "转换出错!" + e.Message; this.ErrCode = e.Message; return(-1); } return(this.ExecNoQuery(sql)); }
/// <summary> /// 保存操作结果 /// </summary> /// <return>0 success, -1 fail</return> public int Save() { this.neuSpread1.StopCellEditing(); if (this.neuSpread1_Sheet1.RowCount <= 0) { MessageBox.Show("没有要保存的数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(-1); } if (this.Valid() == -1) { return(-1); } Neusoft.FrameWork.Management.PublicTrans.BeginTransaction(); //Neusoft.FrameWork.Management.Transaction SQLCA = new Neusoft.FrameWork.Management.Transaction(Neusoft.FrameWork.Management.Connection.Instance); //SQLCA.BeginTransaction(); this.seatMgr.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); try { for (int i = 0; i < this.neuSpread1_Sheet1.RowCount; i++) { #region 界面生成实体 Neusoft.HISFC.Models.Nurse.Seat info = new Neusoft.HISFC.Models.Nurse.Seat(); info.ID = this.neuSpread1_Sheet1.Cells[i, 0].Tag.ToString(); info.Name = this.neuSpread1_Sheet1.GetValue(i, 0).ToString(); info.PRoom.InputCode = this.neuSpread1_Sheet1.GetValue(i, 1).ToString(); info.PRoom.ID = this.neuSpread1_Sheet1.Cells[i, 2].Tag.ToString(); info.PRoom.Name = this.neuSpread1_Sheet1.GetValue(i, 2).ToString(); //状态 string strTemp = "1"; if (this.neuSpread1_Sheet1.GetValue(i, 3).ToString().Trim() == "停用") { strTemp = "0"; } info.PRoom.IsValid = strTemp; //备注 string strMemo = this.neuSpread1_Sheet1.Cells[i, 4].Text.Trim(); if (strMemo == null) { strMemo = ""; } info.Memo = strMemo; //操作信息 info.Oper.ID = this.seatMgr.Operator.ID; info.Oper.OperTime = this.seatMgr.GetDateTimeFromSysDateTime(); #endregion if (!Neusoft.FrameWork.Function.NConvert.ToBoolean(info.PRoom.IsValid)) { Neusoft.HISFC.BizLogic.Nurse.Assign assMgr = new Neusoft.HISFC.BizLogic.Nurse.Assign(); assMgr.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); if (assMgr.ExistPatient(info.ID, assMgr.GetSysDateTime())) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(info.Name + " 有患者,不能将状态改为无效", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.neuSpread1_Sheet1.SetValue(i, 3, "在用"); return(-1); } //if (this.seatMgr.QuerySeatByConsoleID(info.ID) < 0) //{ // Neusoft.FrameWork.Management.PublicTrans.RollBack(); // MessageBox.Show(this.seatMgr.Err); // return -1; //} //if (this.seatMgr.QuerySeatByConsoleID(info.ID) > 0) //{ // Neusoft.FrameWork.Management.PublicTrans.RollBack(); // MessageBox.Show("该诊台正在使用不能置成无效"); // return -1; //} } if (this.seatMgr.Insert(info) == -1) { if (this.seatMgr.Update(info) == -1) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("保存失败!" + this.seatMgr.Err, "提示"); return(-1); } } } } catch (Exception e) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show("保存失败!" + e.Message, "提示"); return(-1); } Neusoft.FrameWork.Management.PublicTrans.Commit(); MessageBox.Show("保存成功!", "提示"); this.SetFp(); return(0); }