private void btnOk_Click(object sender, System.EventArgs e) { int iDays = ((TimeSpan)(dateTimePicker1.Value - DateManager.ServerDateTimeByDBType(InstanceForm._database))).Days; if (MessageBox.Show(this, "停止日期与当前日期相差:【" + iDays + "天】\r\r您确认停止医嘱吗?", "停医嘱", MessageBoxButtons.YesNo) == DialogResult.No) { return; } //Modify By Tany 2010-06-08 是否使用密码确认 0=使用 1=不使用 if (new SystemCfg(6023).Config == "0") { string dlgvalue = DlgPW.Show(); string pwStr = dlgvalue; //YS.Password; bool bOk = InstanceForm._currentUser.CheckPassword(pwStr); if (!bOk) { FrmMessageBox.Show("你没有通过权限确认,不能发送医嘱!", new Font("宋体", 12f), Color.Red, "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } int num = 0; if (radBt1.Checked == true) { num = -1; } else { num = Convert.ToInt16(this.numericUpDown1.Value); } if (this.OrderID == Guid.Empty) { myQuery.StopOrders(YS_ID, this.dateTimePicker1.Value, num, GroupID, OrderID, BinID, BabyID, 0);//停一组 } else { myQuery.StopOrders(YS_ID, this.dateTimePicker1.Value, num, GroupID, OrderID, BinID, BabyID, 2);//停一条 } IsStop = true; MessageBox.Show("停医嘱成功!"); string binSql = "select * from vi_zy_vinpatient_bed where inpatient_id='" + BinID + "' and baby_id=" + BabyID; DataTable binTb = FrmMdiMain.Database.GetDataTable(binSql); string msg_wardid = InstanceForm._currentDept.WardId; long msg_deptid = 0; long msg_empid = 0; string msg_sender = FrmMdiMain.CurrentDept.DeptName + ":" + FrmMdiMain.CurrentUser.Name; string msg_msg = binTb.Rows[0]["bed_no"].ToString().Trim() + " 床 " + binTb.Rows[0]["name"].ToString().Trim() + " 有停医嘱,请处理!"; TrasenFrame.Classes.WorkStaticFun.SendMessage(true, SystemModule.住院护士站, msg_wardid, msg_deptid, msg_empid, msg_sender, msg_msg); this.Close(); }
private void btOK_Click(object sender, System.EventArgs e) { this.mznr = this.textBox1.Text.ToString().Trim(); if (textBox2.Text.Trim() != "") { this.mznr = this.mznr + "下行" + this.textBox2.Text.ToString(); } if (lbStop.Text == "√") { //Modify By Tany 2010-06-08 是否使用密码确认 0=使用 1=不使用 if (new SystemCfg(6023).Config == "0") { string dlgvalue = DlgPW.Show(); string pwStr = dlgvalue; //YS.Password; bool bOk = InstanceForm._currentUser.CheckPassword(pwStr); if (!bOk) { FrmMessageBox.Show("你没有通过权限确认,不能发送医嘱!", new Font("宋体", 12f), Color.Red, "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } int num = 0; if (this.radBt1.Checked == true) { num = -1; } else { num = Convert.ToInt16(this.numUD.Value); } //停医嘱 try { myQuery.StopOrders(FrmMdiMain.Database, DateManager.ServerDateTimeByDBType(FrmMdiMain.Database).ToString(), this.YS_ID, this.BinID, this.BabyID, num); MessageBox.Show("停医嘱成功!"); } catch (System.Exception err) { MessageBox.Show("" + err.ToString().Trim(), "错误:", MessageBoxButtons.OK, MessageBoxIcon.Error); myQuery.SaveLog(this.DeptID, this.YS_ID, "停医嘱错误", this.Text.Trim() + ",病人:" + this.BinID.ToString() + "," + this.BabyID.ToString() + ",错误:" + err.ToString(), 1, 41); } } flag = true; this.Close(); }
private void btnOk_Click(object sender, EventArgs e) { int iSelectRows = 0; int GroupID = -999; DataTable myTb = (DataTable)dataGrid_LongOrder.DataSource; if (myTb == null) { return; } if (myTb.Rows.Count == 0) { return; } #region 效性判断 if (radBt2.Checked) { if (!Convertor.IsNumeric(numericUpDown1.Value.ToString())) { MessageBox.Show("请输入有效的末日次数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); numericUpDown1.Focus(); return; } } for (int i = 0; i <= myTb.Rows.Count - 1; i++) { if (myTb.Rows[i]["选"].ToString() == "True") { iSelectRows += 1; //如果组号与上一条医嘱相同,则不判断 if (GroupID == Convert.ToInt32(myTb.Rows[i]["嘱号"])) { continue; } if (radBt3.Checked) { if (!Convertor.IsNumeric(myTb.Rows[i]["末日次数"].ToString())) { MessageBox.Show("请输入有效的末日次数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); dataGrid_LongOrder.Focus(); dataGrid_LongOrder.CurrentCell = new DataGridCell(i, 13); return; } } GroupID = Convert.ToInt32(myTb.Rows[i]["嘱号"]); } } #endregion if (iSelectRows == 0) { MessageBox.Show(this, "对不起,没有选择医嘱!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int iDays = ((TimeSpan)(dateTimePicker1.Value - DateManager.ServerDateTimeByDBType(InstanceForm._database))).Days; if (MessageBox.Show(this, "停止日期与当前日期相差:【" + iDays + "天】\r\r您确认停止医嘱吗?", "停医嘱", MessageBoxButtons.YesNo) == DialogResult.No) { return; } if (MessageBox.Show(this, "您确认停止医嘱吗?", "停医嘱", MessageBoxButtons.YesNo) == DialogResult.No) { return; } //Modify By Tany 2010-06-08 是否使用密码确认 0=使用 1=不使用 if (new SystemCfg(6023).Config == "0") { string dlgvalue = DlgPW.Show(); string pwStr = dlgvalue; //YS.Password; bool bOk = InstanceForm._currentUser.CheckPassword(pwStr); if (!bOk) { FrmMessageBox.Show("你没有通过权限确认,不能发送医嘱!", new Font("宋体", 12f), Color.Red, "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } int num = 0; try { GroupID = -999; for (int i = 0; i <= myTb.Rows.Count - 1; i++) { //如果是选择发送 if (myTb.Rows[i]["选"].ToString() == "False") { continue; } //如果组号与上一条医嘱相同,则不执行 if (GroupID == Convert.ToInt32(myTb.Rows[i]["嘱号"])) { continue; } if (radBt1.Checked == true) { num = -1; } else if (radBt2.Checked) { num = Convert.ToInt16(this.numericUpDown1.Value); } else { num = Convert.ToInt32(myTb.Rows[i]["末日次数"]); } GroupID = Convert.ToInt32(myTb.Rows[i]["嘱号"]); myQuery.StopOrders(YS_ID, this.dateTimePicker1.Value, num, GroupID, Guid.Empty, BinID, BabyID, 0);//停一组 } MessageBox.Show("停医嘱成功!"); string binSql = "select * from vi_zy_vinpatient_bed where inpatient_id='" + BinID + "' and baby_id=" + BabyID; DataTable binTb = FrmMdiMain.Database.GetDataTable(binSql); string msg_wardid = InstanceForm._currentDept.WardId; long msg_deptid = 0; long msg_empid = 0; string msg_sender = FrmMdiMain.CurrentDept.DeptName + ":" + FrmMdiMain.CurrentUser.Name; string msg_msg = binTb.Rows[0]["bed_no"].ToString().Trim() + " 床 " + binTb.Rows[0]["name"].ToString().Trim() + " 有停医嘱,请处理!"; TrasenFrame.Classes.WorkStaticFun.SendMessage(true, SystemModule.住院护士站, msg_wardid, msg_deptid, msg_empid, msg_sender, msg_msg); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Close(); } }
private void btnOk_Click(object sender, System.EventArgs e) { if (cmbWard.Text == "") { MessageBox.Show("没有选择病区,请选择转到的病区", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cmbDept.Text == "") { MessageBox.Show("没有选择科室,请选择转到的科室", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //Modify By tany 2010-01-08 原来判断开单医生的科室,现在判断病人所在科室 if (this.Dept_Br == Convert.ToInt64(this.cmbDept.SelectedValue)) { FrmMessageBox.Show("不允许本科室转本科室!请重新选择科室。", new Font("宋体", 12f), Color.Red, "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // if(myQuery.SexName(this.BinID)=="男") // { // //选择转出的科室如果是妇科和产科,则提示不能转(302表示妇产科) // if(Convert.ToInt64(this.cmbDept.SelectedValue) == 302) // { // MessageBox.Show("该病人是男性,不能转去妇产科,请重新选择科室","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning); // return; // } // } #region 权限确认 //Modify By Tany 2010-06-08 是否使用密码确认 0=使用 1=不使用 if (new SystemCfg(6023).Config == "0") { string dlgvalue = DlgPW.Show(); string pwStr = dlgvalue; //YS.Password; bool bOk = InstanceForm._currentUser.CheckPassword(pwStr); if (!bOk) { FrmMessageBox.Show("你没有通过权限确认,不能发送医嘱!", new Font("宋体", 12f), Color.Red, "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } #endregion //写停医嘱记录 string er = ""; long Order_Num = myQuery.GetYzNum(this.BinID, this.DeptID); long OrderNumCount = Order_Num + 1; int num = 0; SystemCfg cfg6045 = new SystemCfg(6045); DataTable babyTb; //Modify By Tany 2011-03-07 婴儿和大人一起停医嘱并转科 //add by zouchihua 2012-5-15 if (cfg6045.Config.Trim() == "0") { babyTb = FrmMdiMain.Database.GetDataTable("select * from zy_inpatient_baby where inpatient_id='" + BinID + "'"); } else { babyTb = FrmMdiMain.Database.GetDataTable("select * from zy_inpatient_baby where inpatient_id='" + BinID + "' and flag in(1,3,4)"); } //Modify By Tany 2011-03-07 婴儿和大人一起转科,对方科室也必须是产科 if (babyTb != null && babyTb.Rows.Count > 0) { if (!myFunc.IsFCK(cmbWard.SelectedValue.ToString().Trim())) { FrmMessageBox.Show("带婴儿的病人不允许转到非妇产科室!请重新选择科室。", new Font("宋体", 12f), Color.Red, "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } //生成数据库访问对象 FrmMdiMain.Database.BeginTransaction(); try { //构成SQL语句,并执行,默认婴儿ID为0,医嘱录入人为医生本人,默认病人科室为医生科室,中草药剂量默认为1,操作员为医生本人 //武汉中心医院转科、出院、死亡医嘱存储到临时医嘱 Moidify by jchl string OrderID = PubStaticFun.NewGuid().ToString();//Modify BY Tany 2014-12-04 转科的Order_id不用查询来取,直接赋值公用就行//Convert.ToString(FrmMdiMain.Database.GetDataResult(sSql)); string sSql = "INSERT INTO ZY_ORDERRECORD(" + "order_id,Group_ID,Inpatient_ID,Dept_ID,Ward_ID,MNGTYPE,nType,Order_Doc," + "HOItem_ID,xmly,Order_context,Num,Dosage,Unit,book_date," + "Order_bDate,First_times,Order_Usage,frequency," + "Operator,Delete_Bit,status_flag,baby_id,dept_br,exec_dept,serial_no,jgbm)" + " VALUES('" + OrderID + "'," + OrderNumCount.ToString() + ",'" + BinID.ToString() + "'," + this.DeptID.ToString() + ",'" + this.WardID + "',1,0," + this.YS_ID.ToString() + "," + "-1,2,'" + "转:【" + this.cmbJgbm.Text + "】" + this.cmbDept.Text.Trim() + "',0,1,'',GetDate()," + "'" + this.dateTimePicker1.Value.ToString() + "',1,'','1'," + "" + this.YS_ID.ToString() + ",0,1," + "0" + "," + (Dept_Br == 0 ? DeptID.ToString() : Dept_Br.ToString()) + "," + this.DeptID.ToString() + ",0," + FrmMdiMain.Jgbm + ") "; FrmMdiMain.Database.DoCommand(sSql); //获取转科医嘱order_id //武汉中心医院转科、出院、死亡医嘱存储到临时医嘱 Moidify by jchl[mngtype=0->mngtype=1] //sSql = "select order_id from zy_orderrecord where inpatient_id='" + this.BinID.ToString() + "' and mngtype=1 and HOItem_ID=-1 and order_context like '%转%'and Order_bDate='" + this.dateTimePicker1.Value.ToString() + "' "; //string OrderID = Convert.ToString(FrmMdiMain.Database.GetDataResult(sSql)); string tran_type = "0"; if (chk_trantype.Checked == false) { tran_type = "1"; } string sSql0 = "insert into zy_transfer_dept(" + "id,Inpatient_id,S_dept_id,D_dept_id,Transfer_date,Book_date,Operator,description,Baby_id,finish_bit,order_id,CANCEL_BIT,jgbm,Trans_type) " + "values('" + PubStaticFun.NewGuid() + "','" + BinID.ToString() + "'," + (Dept_Br == 0 ? DeptID.ToString() : Dept_Br.ToString()) + "," + this.cmbDept.SelectedValue.ToString() + ",'" + this.dateTimePicker1.Value.ToString() + "'," + "GetDate()," + this.YS_ID.ToString() + ",'转',0,0,'" + OrderID + "',0 ," + FrmMdiMain.Jgbm + "," + tran_type + ")"; FrmMdiMain.Database.DoCommand(sSql0); //Modify By Tany 2011-03-07 婴儿和大人一起停医嘱 if (babyTb != null && babyTb.Rows.Count > 0) { for (int i = 0; i < babyTb.Rows.Count; i++) { string sSql1 = ""; if (chk_trantype.Checked)//正常转科 { sSql1 = "insert into zy_transfer_dept(" + "id,Inpatient_id,S_dept_id,D_dept_id,Transfer_date,Book_date,Operator,description,Baby_id,finish_bit,order_id,CANCEL_BIT,jgbm,Trans_type) " + "values('" + PubStaticFun.NewGuid() + "','" + BinID.ToString() + "'," + (Dept_Br == 0 ? DeptID.ToString() : Dept_Br.ToString()) + "," + this.cmbDept.SelectedValue.ToString() + ",'" + this.dateTimePicker1.Value.ToString() + "'," + "GetDate()," + this.YS_ID.ToString() + ",'转'," + Convert.ToInt64(babyTb.Rows[i]["baby_id"]) + ",0,'" + OrderID + "',0 ," + FrmMdiMain.Jgbm + ",0)"; } else { //非正常转科 sSql1 = "insert into zy_transfer_dept(" + "id,Inpatient_id,S_dept_id,D_dept_id,Transfer_date,Book_date,Operator,description,Baby_id,finish_bit,order_id,CANCEL_BIT,jgbm,Trans_type) " + "values('" + PubStaticFun.NewGuid() + "','" + BinID.ToString() + "'," + (Dept_Br == 0 ? DeptID.ToString() : Dept_Br.ToString()) + "," + this.cmbDept.SelectedValue.ToString() + ",'" + this.dateTimePicker1.Value.ToString() + "'," + "GetDate()," + this.YS_ID.ToString() + ",'转'," + Convert.ToInt64(babyTb.Rows[i]["baby_id"]) + ",0,'" + OrderID + "',0 ," + FrmMdiMain.Jgbm + ",1)"; } FrmMdiMain.Database.DoCommand(sSql1); } } if (this.radBt1.Checked == true) { num = -1; } else { num = Convert.ToInt16(this.numUD.Value); } if (this.lbStop.Text == "√") { //停医嘱 myQuery.StopOrders(FrmMdiMain.Database, this.dateTimePicker1.Value.ToString(), this.YS_ID, this.BinID, 0, num); //停账单 myQuery.StopOrders_ZD(FrmMdiMain.Database, this.dateTimePicker1.Value.ToString(), this.YS_ID, this.BinID, 0, num, 0); //Modify By Tany 2011-03-07 婴儿和大人一起停医嘱 if (babyTb != null && babyTb.Rows.Count > 0) { for (int i = 0; i < babyTb.Rows.Count; i++) { //停医嘱 myQuery.StopOrders(FrmMdiMain.Database, this.dateTimePicker1.Value.ToString(), this.YS_ID, this.BinID, Convert.ToInt64(babyTb.Rows[i]["baby_id"]), num); //停账单 myQuery.StopOrders_ZD(FrmMdiMain.Database, this.dateTimePicker1.Value.ToString(), this.YS_ID, this.BinID, Convert.ToInt64(babyTb.Rows[i]["baby_id"]), num, 0); } } } FrmMdiMain.Database.CommitTransaction(); MessageBox.Show("转科申请成功!"); outType = true; string msg_wardid = InstanceForm._currentDept.WardId; long msg_deptid = 0; long msg_empid = 0; string msg_sender = FrmMdiMain.CurrentDept.DeptName + ":" + FrmMdiMain.CurrentUser.Name; string msg_msg = lblBedNo.Text + " 床 " + lblName.Text + " 有转科医嘱,请处理!"; TrasenFrame.Classes.WorkStaticFun.SendMessage(true, SystemModule.住院护士站, msg_wardid, msg_deptid, msg_empid, msg_sender, msg_msg); } catch (System.Exception err) { FrmMdiMain.Database.RollbackTransaction(); MessageBox.Show("转科申请失败!请重试!\n" + err.ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Error); er = err.ToString(); this.Close(); } finally { if (er.Trim() == "") { myQuery.SaveLog(this.DeptID, this.YS_ID, "开转科医嘱", this.BinID.ToString() + ":从" + this.DeptID.ToString() + "转到" + this.cmbDept.SelectedValue.ToString() + ",末日次数:" + num.ToString(), 0, 41); } else { myQuery.SaveLog(this.DeptID, this.YS_ID, "转科医嘱失败", this.BinID.ToString() + ":" + er.Trim() + " ⊙从" + this.DeptID.ToString() + "转到" + this.cmbDept.SelectedValue.ToString() + ",末日次数:" + num.ToString(), 1, 41); } } //发消息通知护士站 if (this.chk_hsz.Checked) { long warddept = (this.DeptID); myQuery.InformHS(warddept, " 请为 " + this.lblBedNo.Text.Trim() + "床 " + this.lblName.Text.Trim() + " 办理转科手续"); } Ts_zyys_main.frmMain.outflag = true; this.Close(); }
private void butusc_Click(object sender, EventArgs e) { #region 权限确认 try { string dlgvalue = DlgPW.Show(); string pwStr = dlgvalue; //YS.Password; bool bOk = InstanceForm.BCurrentUser.CheckPassword(pwStr); if (!bOk) { FrmMessageBox.Show("你没有通过权限确认!", new Font("宋体", 12f), Color.Red, "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Warning); Cursor = Cursors.Default; return; } } catch (System.Exception err) { MessageBox.Show(err.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion #region 如果是删除盘点帐存表 try { if (MessageBox.Show("删除 [" + InstanceForm.BCurrentDept.DeptName + "] 盘点帐存表的操作不可恢复,您确定要这样做吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } DataTable tab = (DataTable)dataGridView1.DataSource; InstanceForm.BDatabase.BeginTransaction(); for (int xxx = 0; xxx <= tab.Rows.Count - 1; xxx++) { //仓库id int deptid = Convert.ToInt32(tab.Rows[xxx]["deptid"]); string ssql = "select * from yf_pdcs where bdelete=0 and shbz=0 and deptid=" + deptid + ""; DataTable tb = InstanceForm.BDatabase.GetDataTable(ssql); if (tb.Rows.Count != 0) { throw new Exception("盘点录入操作已经开始了,您现在不能取消帐存表数据"); } ssql = "delete yf_pdtemp where shbz=0 and deptid=" + deptid + ""; int iii = InstanceForm.BDatabase.DoCommand(ssql); //if (iii == 0) throw new Exception("没有可删除的帐存数据,可能还没有生成"); string str_old = "删除盘点帐存表"; SystemLog systemLog = new SystemLog(-1, InstanceForm.BCurrentDept.DeptId, InstanceForm.BCurrentUser.EmployeeId, "删除盘点帐存表", str_old, DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase), 0, "主机名:" + System.Environment.MachineName, 8); systemLog.Save(); systemLog = null; } InstanceForm.BDatabase.CommitTransaction(); MessageBox.Show("删除成功"); bool b = BegionPd(); return; } catch (System.Exception err) { InstanceForm.BDatabase.RollbackTransaction(); MessageBox.Show(err.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion }
private void butsc_Click(object sender, EventArgs e) { //当前科室名称 string deptname = InstanceForm.BCurrentDept.DeptName.Trim(); //日期 string sDate = DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase).ToString(); #region 权限确认 try { string dlgvalue = DlgPW.Show(); string pwStr = dlgvalue; //YS.Password; bool bOk = InstanceForm.BCurrentUser.CheckPassword(pwStr); if (!bOk) { FrmMessageBox.Show("你没有通过权限确认!", new Font("宋体", 12f), Color.Red, "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Warning); Cursor = Cursors.Default; return; } } catch (System.Exception err) { MessageBox.Show(err.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion string sql = string.Format(@" select ID,b.YWMC from YK_DJ_TEMP a left join YK_YWLX b on a.YWLX = b.YWLX where a.SHBZ !=1 and a.DEPTID ={0} union select ID,b.YWMC from YK_DJ a left join YK_YWLX b on a.YWLX = b.YWLX where a.SHBZ !=1 and a.DEPTID ={0}", InstanceForm.BCurrentDept.DeptId); DataTable dt = InstanceForm.BDatabase.GetDataTable(sql); if (dt != null && dt.Rows.Count > 0) { string ywmc = string.Empty; foreach (DataRow tmpRow in dt.Rows) { if (!ywmc.Contains(tmpRow[1].ToString().Trim())) { ywmc += tmpRow[1].ToString().Trim() + ","; } } ywmc = ywmc.Remove(ywmc.Length - 1, 1); ywmc = ywmc[ywmc.Length - 1].ToString().Trim() == "单" ? ywmc : ywmc + "单据"; MessageBox.Show(string.Format("存在未审核的{0},请处理!", ywmc)); return; } sql = string.Format(@"select a.ID,B.YWMC from YF_DJ a left join Yf_YWLX b on a.YWLX = b.YWLX where (a.YWLX = '016' or a.YWLX = '015') and a.SHBZ !=1 and a.DEPTID ={0} ", InstanceForm.BCurrentDept.DeptId); dt = InstanceForm.BDatabase.GetDataTable(sql); if (dt != null && dt.Rows.Count > 0) { string ywmc = string.Empty; foreach (DataRow tmpRow in dt.Rows) { if (!ywmc.Contains(tmpRow[1].ToString().Trim())) { ywmc += tmpRow[1].ToString().Trim() + ","; } } ywmc = ywmc.Remove(ywmc.Length - 1, 1); ywmc = ywmc[ywmc.Length - 1].ToString().Trim() == "单" ? ywmc : ywmc + "单据"; MessageBox.Show(string.Format("存在未审核的{0},请处理!", ywmc)); return; } if (_menuTag.Function_Name == "Fun_ts_yp_pdlr_sczcb_yf") { #region 发药明细表的数据 string stext = this.Text.Trim(); //上传发药明细表的数据 this.Cursor = Cursors.WaitCursor; this.Text = "正在上传处方发药明细....."; try { this.Cursor = PubStaticFun.WaitCursor(); int err_code = -1; string err_text = ""; InstanceForm.BDatabase.BeginTransaction(); ParameterEx[] parameters = new ParameterEx[8]; parameters[0].Text = "@djrq"; parameters[0].Value = Convert.ToDateTime(sDate).ToShortDateString(); parameters[1].Text = "@djsj"; parameters[1].Value = Convert.ToDateTime(sDate).ToLongTimeString(); parameters[2].Text = "@djy"; parameters[2].Value = InstanceForm.BCurrentUser.EmployeeId; parameters[3].Text = "@deptid"; parameters[3].Value = InstanceForm.BCurrentDept.DeptId; parameters[4].Text = "@endrq"; parameters[4].Value = Convert.ToDateTime(sDate).ToShortDateString(); parameters[5].Text = "@err_code"; parameters[5].ParaDirection = ParameterDirection.Output; parameters[5].DataType = System.Data.DbType.Int32; parameters[5].ParaSize = 100; parameters[6].Text = "@err_text"; parameters[6].ParaDirection = ParameterDirection.Output; parameters[6].ParaSize = 100; parameters[7].Text = "@jgbm"; parameters[7].Value = InstanceForm._menuTag.Jgbm; InstanceForm.BDatabase.DoCommand("SP_YF_fymx_dj", parameters, 30); err_code = Convert.ToInt32(parameters[5].Value); err_text = Convert.ToString(parameters[6].Value); //更新处方上传日期 string rq = sDate; string ssql = "update yp_yjks set cfscrq='" + rq + "' where deptid=" + InstanceForm.BCurrentDept.DeptId + ""; InstanceForm.BDatabase.DoCommand(ssql); InstanceForm.BDatabase.CommitTransaction(); this.Text = "上传处方记录成功"; } catch (System.Exception err) { InstanceForm.BDatabase.RollbackTransaction(); MessageBox.Show("在上传发药明细时发生错误" + err.Message); return; } finally { this.Cursor = Cursors.Arrow; } #endregion } #region 系统对账 //系统对账 this.Text = "正在进行系统对账....."; try { this.Cursor = PubStaticFun.WaitCursor(); ParameterEx[] parameters = new ParameterEx[2]; parameters[0].Text = "@jsrq"; parameters[1].Text = "@deptid"; parameters[0].Value = sDate; //该参数暂时无用 parameters[1].Value = InstanceForm.BCurrentDept.DeptId; DataTable tb = InstanceForm.BDatabase.GetDataTable("SP_YF_XTDZ", parameters, 60); tb.TableName = "myTb"; DataRow[] row = tb.Select("数量差值<> 0"); if (row.Length != 0) { throw new Exception("系统检测到帐务数据不平,请到 [系统对帐] 菜单重新进行系统对帐后再进行当前操作"); } } catch (System.Exception err) { MessageBox.Show("出错" + err.Message); return; } finally { this.Cursor = Cursors.Arrow; } #endregion #region 生成帐存表 if (MessageBox.Show("您确定要生成 [" + deptname + "] 盘点帐存表吗?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } try { this.Cursor = TrasenClasses.GeneralClasses.PubStaticFun.WaitCursor(); DataTable tb = (DataTable)dataGridView1.DataSource; sDate = DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase).ToString(); //插入当前帐面数量到盘点临时表 InstanceForm.BDatabase.BeginTransaction(); for (int xxx = 0; xxx <= tb.Rows.Count - 1; xxx++) { //仓库id int deptid = Convert.ToInt32(tb.Rows[xxx]["deptid"]); string tablename = ""; string tbName_kcmx = ""; if (YpConfig.是否药库(deptid, InstanceForm.BDatabase) == true) { tablename = "yk_kcph"; tbName_kcmx = "yk_kcmx"; } else { tablename = "yf_kcph"; tbName_kcmx = "yf_kcmx"; } string ssql = "select kcid ncount,djsj from yf_pdtemp where deptid=" + deptid + " and shbz=0 and bdelete=0 "; DataTable tbtemp = InstanceForm.BDatabase.GetDataTable(ssql); if (tbtemp.Rows.Count > 0) { throw new Exception("[" + deptname + "] 帐存数据已生成,不能再次生成!"); } ssql = "insert into yf_pdtemp(id,kcid,jgbm,ggid,cjid,KWID,jhj,ypph,kcl,zxdw,dwbl,djsj,djy,bdelete,deptid,ypxq,yppch)" + "select dbo.FUN_GETGUID(newid(),getdate()),id,jgbm,ggid,cjid,KWID,jhj,ypph,kcl,zxdw,dwbl,'" + sDate + "'," + InstanceForm.BCurrentUser.EmployeeId + ", bdelete,deptid,ypxq,yppch from " + tablename + " where deptid=" + deptid + ""; InstanceForm.BDatabase.DoCommand(ssql); } InstanceForm.BDatabase.CommitTransaction(); MessageBox.Show("盘点帐存表生成成功,接下来您可以进行盘存单的录入操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); bool b = BegionPd(); return; } catch (System.Exception err) { InstanceForm.BDatabase.RollbackTransaction(); MessageBox.Show(err.Message); } finally { this.Cursor = Cursors.Arrow; } #endregion }
private void butjk_Click(object sender, EventArgs e) { if (dataGridView1.DataSource == null) { return; } try { if (Jkid != Guid.Empty) { MessageBox.Show("已点击交账,不能重复操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (dtpjsrq2.Value > DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase)) { MessageBox.Show("统计时间不能大于当前系统时间", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (yjjrow == 0 && fpbrow == 0) { MessageBox.Show("没有需要交款的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #region 权限确认 try { string dlgvalue = DlgPW.Show(); string pwStr = dlgvalue; //YS.Password; bool bOk = InstanceForm.BCurrentUser.CheckPassword(pwStr); if (!bOk) { FrmMessageBox.Show("你没有通过权限确认,不能交帐!", new Font("宋体", 12f), Color.Red, "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Warning); Cursor = Cursors.Default; return; } } catch (System.Exception err) { MessageBox.Show(err.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion string sDate = DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase).ToString(); int _yjjrow = 0; int _fpbrow = 0; DataTable tb = (DataTable)dataGridView1.DataSource; DataRow[] rows = tb.Select("sfy>0"); try { butjk.Enabled = false; buttj.Enabled = false; InstanceForm.BDatabase.BeginTransaction(); for (int i = 0; i <= rows.Length - 1; i++) { int sfy = Convert.ToInt32(Convertor.IsNull(rows[i]["sfy"], "0")); string sfyxm = Fun.SeekEmpName(sfy, InstanceForm.BDatabase); string ksrq = Scjksj(sfy).ToString(); string jsrq = dtpjsrq2.Value.ToString(); long yxzs = 0; long zfzs = 0; decimal fpje = Convert.ToDecimal(Convertor.IsNull(rows[i]["刷卡消费"], "0")) + Convert.ToDecimal(Convertor.IsNull(rows[i]["银联卡消费"], "0")); decimal xjzf = 0; decimal zpzf = 0; decimal ylkzf = Convert.ToDecimal(Convertor.IsNull(rows[i]["银联卡消费"], "0")); decimal ybzf = 0; decimal cwjz = Convert.ToDecimal(Convertor.IsNull(rows[i]["刷卡消费"], "0")); decimal qfgz = 0; decimal yhje = Convert.ToDecimal(Convertor.IsNull(rows[i]["优惠金额"], "0"));; decimal zfje = 0; string fpd = ""; string zffpd = ""; if ((fpje - xjzf - zpzf - ylkzf - ybzf - cwjz - qfgz - yhje) != 0) { MessageBox.Show("消费总额,与各支付项不等,请检查数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //缴款日期为收费结束日期,新增加操作日期 string ssql = "select dbo.FUN_GETGUID(newid(),getdate()) "; Jkid = new Guid(InstanceForm.BDatabase.GetDataResult(ssql).ToString()); ssql = "insert into mz_jkb(jkid,jgbm,ksrq,jsrq,jkrq,jky,yxfpzs,fpje,zfzs,zfje,xjzf,zpzf,ylkzf,ybzf,cwjz,qfgz,yhje,sffpd,ZFFPH,czrq)values('" + Jkid + "'," + _menuTag.Jgbm + ",'" + ksrq + "','" + jsrq + "','" + jsrq + "'," + sfy + "," + yxzs + "," + fpje + "," + zfzs + "," + (-1) * zfje + "," + xjzf + "," + zpzf + "," + ylkzf + "," + ybzf + "," + cwjz + "," + qfgz + "," + yhje + ",'" + fpd + "','" + zffpd + "','" + sDate + "')"; int x = InstanceForm.BDatabase.DoCommand(ssql); if (x == 0) { throw new Exception("插入交款记录时失败"); } if (Jkid == Guid.Empty || Jkid == null) { throw new Exception("交款id为零,请和管理员联系"); } //ssql = "update mz_fpb set jkid='" + Jkid + "' where (BGHPBZ <> 2 or ZJE > 0) and sfy=" + sfy + " and sfrq>='" + ksrq + "' and sfrq<='" + jsrq + "' and bscbz=0 and isnull(jkid,dbo.FUN_GETEMPTYGUID())=dbo.FUN_GETEMPTYGUID()"; ssql = string.Format(@"update mz_fpb set jkid='{0}' where ZJE>0 and sfy= {1} and sfrq>='{2}' and sfrq<='{3}' and bscbz=0 and isnull(jkid,dbo.FUN_GETEMPTYGUID())=dbo.FUN_GETEMPTYGUID()", Jkid, sfy, ksrq, jsrq); x = InstanceForm.BDatabase.DoCommand(ssql); _fpbrow = _fpbrow + x; ssql = "update mz_skjl set jkid='" + Jkid + "' where ZJE > 0 and sfy=" + sfy + " and sfrq>='" + ksrq + "' and sfrq<='" + jsrq + "' and bscbz=0 and isnull(jkid,dbo.FUN_GETEMPTYGUID())=dbo.FUN_GETEMPTYGUID()"; x = InstanceForm.BDatabase.DoCommand(ssql); ssql = "update yy_kdjb_je set jkid='" + Jkid + "' where CRJE > 0 and dzrq>='" + ksrq + "' and dzrq<='" + jsrq + "' and dzy=" + sfy + " and bdzbz=1 and bzfbz=0 and isnull(jkid,dbo.FUN_GETEMPTYGUID())=dbo.FUN_GETEMPTYGUID() "; x = InstanceForm.BDatabase.DoCommand(ssql); _yjjrow = _yjjrow + x; rows[i]["缴款日期"] = sDate; rows[i]["jkid"] = Jkid;//add by wangzhi 2014-08-05 } if (_fpbrow != fpbrow) { throw new Exception("统计的发票记录为" + fpbrow + "条,交款更新影响到" + _fpbrow + "行。请刷新后重试"); } if (_yjjrow != yjjrow) { throw new Exception("统计的预交款记录为" + yjjrow + "条,交款更新影响到" + _yjjrow + "行。请刷新后重试"); } InstanceForm.BDatabase.CommitTransaction(); MessageBox.Show("交账成功"); } catch (System.Exception err) { butjk.Enabled = true; buttj.Enabled = true; Jkid = Guid.Empty; InstanceForm.BDatabase.RollbackTransaction(); throw new Exception(err.Message); } } catch (System.Exception err) { MessageBox.Show(err.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void btnOk_Click(object sender, System.EventArgs e) { if (this.BabyID == 0 && (txtXY.Text.Trim() == "" || Convertor.IsNull(txtXY.Tag, "") == "")) { MessageBox.Show("出院诊断不完整!"); return; } #region//Add by Zouchihua 2011-11-18 判断病人的当前科室是不是属于本院区,获得病人所在科室机构编码 string[] rtnSql = ts_zyhs_classes.BaseFunc.GetBrzt(BinID); //Modify by zouchihfua 2011-11-16 病人所在科室机构编码 //string[] rtnSql = ts_zyhs_classes.BaseFunc.GetBrzt(BinID); int BrJgbm = Convert.ToInt32(rtnSql[1]); #endregion //Modify By Tany 2010-06-08 是否使用密码确认 0=使用 1=不使用 if (new SystemCfg(6023).Config == "0") { string dlgvalue = DlgPW.Show(); string pwStr = dlgvalue; //YS.Password; bool bOk = InstanceForm._currentUser.CheckPassword(pwStr); if (!bOk) { FrmMessageBox.Show("你没有通过权限确认,不能提交该医嘱!", new Font("宋体", 12f), Color.Red, "Sorry!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (this.BabyID == 0 && ybjklx == 40 && yblx >= 0) { //医保病人必须有医保诊断 if (string.IsNullOrEmpty(Convertor.IsNull(lblYbjbbm.Tag, ""))) { MessageBox.Show("医保病人:未找到西医诊断的医保编码,请重新选择西医诊断!"); return; } } //出院医嘱提醒 modify by jchl 2015-09-30 OutHosp.isZg(lblZyh.Text.Trim(), FrmMdiMain.Database); string er = ""; long Order_Num = myQuery.GetYzNum(this.BinID, this.DeptID); long OrderNumCount = Order_Num + 1; int num = 0;//末日次数 FrmMdiMain.Database.BeginTransaction(); try { //构成SQL语句,并执行,默认婴儿ID为0,医嘱录入人为医生本人,默认病人科室为医生科室,中草药剂量默认为1,操作员为医生本人 //武汉中心医院转科、出院、死亡医嘱存储到临时医嘱 Moidify by jchl string sSql = "INSERT INTO ZY_ORDERRECORD(" + "order_id,Group_ID,Inpatient_ID,Dept_ID,Ward_ID,MNGTYPE,nType,Order_Doc," + "HOItem_ID,xmly,Order_context,Num,Dosage,Unit,book_date," + "Order_bDate,First_times,Order_Usage,frequency," + "Operator,Delete_Bit,status_flag,baby_id,dept_br,exec_dept,serial_no,jgbm)" + " VALUES('" + PubStaticFun.NewGuid() + "'," + OrderNumCount.ToString() + ",'" + BinID.ToString() + "'," + this.DeptID.ToString() + ",'" + this.WardID + "',1,0," + this.YS_ID.ToString() + "," + "-1,2,'病人死亡',0,1,'',GetDate(),'" + this.dTimePicker1.Value.ToString() + "',1,'','1'," + "" + this.YS_ID.ToString() + ",0,1," + "0" + "," + this.DeptID.ToString() + "," + this.DeptID.ToString() + ",0," + BrJgbm + ") "; FrmMdiMain.Database.DoCommand(sSql); string sSql0 = "update zy_inpatient set out_mode=4,out_date='" + this.dTimePicker1.Value.ToString() + "',out_diagnosis='" + Convertor.IsNull(txtXY.Tag, "") + "'," + "flag=4 where inpatient_id='" + this.BinID.ToString() + "'"; FrmMdiMain.Database.DoCommand(sSql0); if (this.BabyID == 0) { //Modify by jchl 优先删除该病人的废的第1诊断 string sqlDelZd = string.Format(@"delete from ZY_DISEASE_MANY where INPATIENT_ID='{0}' and DISEASE_MARK='第1诊断'", this.BinID.ToString()); FrmMdiMain.Database.DoCommand(sqlDelZd); //Modify by jchl 新增第一诊断 sSql = String.Format(@" INSERT INTO ZY_DISEASE_MANY (INPATIENT_ID ,INPATIENT_NO ,BABY_ID ,DISEASE_MARK ,DISEASE_CODE ,DISEASE_NAME ,JGBM,YBJBBM,YBJBMC) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}',{6},'{7}','{8}')", this.BinID.ToString(), lblZyh.Text.Trim(), "0", "第1诊断", Convertor.IsNull(txtXY.Tag, ""), txtXY.Text, BrJgbm, Convertor.IsNull(lblYbjbbm.Tag, ""), lblYbjbbm.Text); FrmMdiMain.Database.DoCommand(sSql); } if (this.radBt1.Checked == true) { num = -1; } else { num = Convert.ToInt16(this.numUD.Value); } // //停医嘱 myQuery.StopOrders(FrmMdiMain.Database, this.dTimePicker1.Value.ToString(), this.YS_ID, this.BinID, this.BabyID, num); //停账单 myQuery.StopOrders_ZD(FrmMdiMain.Database, this.dTimePicker1.Value.ToString(), this.YS_ID, this.BinID, this.BabyID, num, 0); FrmMdiMain.Database.CommitTransaction(); outType = true; string msg_wardid = InstanceForm._currentDept.WardId; long msg_deptid = 0; long msg_empid = 0; string msg_sender = FrmMdiMain.CurrentDept.DeptName + ":" + FrmMdiMain.CurrentUser.Name; string msg_msg = lblBedNo.Text + " 床 " + lblName.Text + " 有死亡医嘱,请处理!"; TrasenFrame.Classes.WorkStaticFun.SendMessage(true, SystemModule.住院护士站, msg_wardid, msg_deptid, msg_empid, msg_sender, msg_msg); } catch (Exception err) { FrmMdiMain.Database.RollbackTransaction(); MessageBox.Show("生成死亡医嘱错误!请重试!\n" + err.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); er = err.ToString(); this.Close(); } finally { // _Database.Close(); if (er.Trim() == "") { myQuery.SaveLog(this.DeptID, this.YS_ID, "开死亡医嘱", this.BinID.ToString() + ": " + txtXY.Text.Trim() + ",死亡时间" + this.dTimePicker1.Value.ToString() + ",末日次数:" + num.ToString(), 0, 41); } else { myQuery.SaveLog(this.DeptID, this.YS_ID, "死亡医嘱失败", this.BinID.ToString() + ":" + er.Trim() + " ⊙" + txtXY.Text.Trim() + ",死亡时间" + this.dTimePicker1.Value.ToString() + ",末日次数:" + num.ToString(), 1, 41); } } //FrmYZGL.outType=true; Ts_zyys_main.frmMain.outflag = true; this.Close(); }