Ejemplo n.º 1
0
 /// <summary>
 /// 保存模板明细
 /// </summary>
 /// <param name="mouldLists"></param>
 public int Save(IList mouldLists)
 {
     _oleDb.BeginTransaction();
     try
     {
         foreach (PresMouldList mouldList in mouldLists)
         {
             mouldList.SetRealValue();
             if (mouldList.Status == HIS.MZDoc_BLL.Public.PresStatus.新建状态)
             {
                 BindEntity <Model.Mz_Doc_PresMouldList> .CreateInstanceDAL(_oleDb).Add(mouldList);
             }
             else if (mouldList.Status == HIS.MZDoc_BLL.Public.PresStatus.修改状态)
             {
                 BindEntity <Model.Mz_Doc_PresMouldList> .CreateInstanceDAL(_oleDb).Update(mouldList);
             }
         }
         _oleDb.CommitTransaction();
         return((int)Public.PresStatus.保存状态);
     }
     catch (Exception e)
     {
         _oleDb.RollbackTransaction();
         throw e;
     }
 }
Ejemplo n.º 2
0
        //移除计划
        private void btnDel_Click(object sender, EventArgs e)
        {
            try
            {
                int rowIndex = dataGridView1.CurrentCell.RowIndex;
                if (rowIndex < 0)
                {
                    return;
                }
                Guid jhid = new Guid(dataGridView1.Rows[rowIndex].Cells["cid"].Value.ToString());
                List <YK_ZJJG_JH> listJh = YK_ZJJG_JH.GetJhList(string.Format(" and a.id= '{0}' and a.bshbz=0", jhid), "", db);
                if (listJh.Count <= 0)
                {
                    MessageBox.Show("找不到该计划或该计划已审核,请刷新后重试!");
                    return;
                }
                YK_ZJJG_JH   jh     = listJh[0];
                DialogResult result = MessageBox.Show("确定要移除计划?", "移除计划", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (result == DialogResult.Cancel)
                {
                    return;
                }
                db.BeginTransaction();

                YK_ZJJG_Class.RemoveScjh(jh, db, InstanceForm._menuTag.Jgbm);
                db.CommitTransaction();
                MessageBox.Show("移除计划成功!");
                butref_Click(0, e);
            }
            catch (Exception err)
            {
                db.RollbackTransaction();
                MessageBox.Show("移除计划失败! " + err.Message);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 删除单条处方明细记录
        /// </summary>
        public int Delete()
        {
            _oleDb.BeginTransaction();
            try
            {
                Model.Mz_Doc_PresHead presHead = BindEntity <Model.Mz_Doc_PresHead> .CreateInstanceDAL(_oleDb).GetModel(this.PresHeadId);

                if (presHead.Pres_Flag > 0)
                {
                    return(presHead.Pres_Flag);
                }
                this.Delete_Bit = 1;
                BindEntity <Model.Mz_Doc_PresList> .CreateInstanceDAL(_oleDb).Update(this);

                string strsql = @"update mz_doc_preslist set orderno=orderno-1 
                         where presheadid=" + this.PresHeadId + " and orderno>" + this.OrderNo + " and workid=" + HIS.SYSTEM.Core.EntityConfig.WorkID;
                if (this.Group_Id > 0)
                {
                    strsql = @"update mz_doc_preslist set group_id=group_id-1 
                         where presheadid=" + this.PresNo + " and orderno>" + this.OrderNo + " and orderno-group_id=" + (this.OrderNo - this.Group_Id) + " and workid=" + HIS.SYSTEM.Core.EntityConfig.WorkID;
                    _oleDb.DoCommand(strsql);
                }
                _oleDb.DoCommand(strsql);
                _oleDb.CommitTransaction();
                return(presHead.Pres_Flag);
            }
            catch (Exception e)
            {
                _oleDb.RollbackTransaction();
                throw e;
            }
        }
Ejemplo n.º 4
0
        public static string SaveFee(DataSet dset, RelationalDatabase db)
        {
            //TrasenFrame.Forms.FrmMdiMain.Database = db;
            TrasenFrame.Forms.FrmMdiMain.JgYybm = 1000;
            TrasenFrame.Forms.FrmMdiMain.Jgbm   = 1000;
            TrasenFrame.Forms.FrmMdiMain.Jgmc   = "";
            try
            {
                db.BeginTransaction();

                DataRow row        = dset.Tables[0].Rows[0];
                string  zyh        = Convertor.IsNull(row["zyh"], "");
                string  bz         = Convertor.IsNull(row["bz"], "");
                string  je         = Convertor.IsNull(row["je"], "");
                string  xmbm       = Convertor.IsNull(row["xmbm"], "");
                string  lb         = Convertor.IsNull(row["lb"], "");
                string  yy         = Convertor.IsNull(row["yy"], "");
                string  rq         = Convertor.IsNull(row["rq"], "");
                string  lxks       = Convertor.IsNull(row["lxks"], "");
                string  djm        = Convertor.IsNull(row["djm"], "");
                string  djh        = Convertor.IsNull(row["djh"], "");
                string  zffs       = Convertor.IsNull(row["zffs"], "");
                string  qqje       = Convertor.IsNull(row["qqje"], "");
                string  jyje       = Convertor.IsNull(row["jyje"], "");
                string  sfjs       = Convertor.IsNull(row["sfjs"], "");
                string  dyfl       = Convertor.IsNull(row["dyfl"], "");
                string  pzr        = Convertor.IsNull(row["pzr"], "");
                string  zjzh       = Convertor.IsNull(row["zjzh"], "");
                string  czy        = Convertor.IsNull(row["czy"], "");
                string  sl         = Convertor.IsNull(row["sl"], "");
                string  dh         = Convertor.IsNull(row["dh"], "");
                string  xmpzr      = Convertor.IsNull(row["xmpzr"], "");
                string  sfyp       = Convertor.IsNull(row["sfyp"], "");
                string  sjh        = Convertor.IsNull(row["sjh"], "");
                string  czgg       = Convertor.IsNull(row["czgg"], "");
                string  dw         = Convertor.IsNull(row["dw"], "");
                string  dj         = Convertor.IsNull(row["dj"], "");
                string  eventid    = Convertor.IsNull(row["id"], "");
                string  czlx       = Convertor.IsNull(row["czlx"], "");
                string  oldhisdjsj = Convertor.IsNull(row["djsj"], "");

                string ssql = "insert into whzxyy_yw_zyfymx (zyh,bz,je,xmbm,lb,yy,rq,lxks,djm,djh,zffs,qqje,jyje,sfjs,dyfl,pzr,zjzh,czy,sl,dh,xmpzr,sfyp,sjh,czgg,dw,dj,eventid,czlx,oldhisdjsj,djsj)values('" +
                              zyh + "','" + bz + "'," + je + ",'" + xmbm + "','" + lb + "','" + yy + "','" + rq + "','" + lxks + "','" + djm + "','" + djh + "','" + zffs + "'," + qqje + "," + jyje + ",'" + sfjs + "','" +
                              dyfl + "','" + pzr + "','" + zjzh + "','" + czy + "'," + sl + ",'" + dh + "','" + xmpzr + "','" + sfyp + "','" + sjh + "','" + czgg + "','" + dw + "'," + dj + "," + eventid + "," + czlx + ",'" + oldhisdjsj + "',getdate())";
                db.DoCommand(ssql);

                db.CommitTransaction();
                System.String[] str = { "0", "保存成功", "", "" };
                //TrasenFrame.Forms.FrmMdiMain.Database.Close();
                return(HisFunctions.GetResponseString("SaveFee", str));
            }
            catch (Exception err)
            {
                db.RollbackTransaction();
                //TrasenFrame.Forms.FrmMdiMain.Database.Close();
                throw err;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 新增诊区|更新诊区 Modiffy By zp 2013-07-31
        /// </summary>
        /// <param name="zq"></param>
        /// <param name="_DataBase"></param>
        /// <returns></returns>
        public bool SaveZqInfo(Fz_Zq zq, RelationalDatabase _DataBase, out string msg)
        {
            _DataBase.BeginTransaction();
            try
            {
                msg = "保存成功!";
                string sql = "";

                if (zq.Zqid <= 0)
                {
                    sql = string.Format(@"INSERT INTO JC_FZ_ZQ(ZQ_NAME,ZQ_ADDRESS,ZQ_IPADDRESS,ZQ_HJCS,ZQ_MEMO,ZQ_BDFS,BSCBZ,QYYY,XSFS)
                           VALUES('{0}','{1}','{2}',{3},'{4}',{5},{6},{7},{8})", zq.Zqname, zq.Zqaddress, zq.Zqipaddress, zq.Zqhjcs, zq.Zqmemo, zq.Zqbdfs, Convert.ToInt32(zq.Zqscbz), zq.Isqyyy, zq.Xsfs);
                    object zqid = 0;

                    if (_DataBase.InsertRecord(sql, out zqid) > 0)
                    {
                        sql = string.Format(@"INSERT INTO JC_FZ_ZQTV(ZQID,HZTBA,HZTBB,HZTBC,HZTBD)
                           VALUES({0},{1},{2},{3},{4})", zqid, zq.Hztba, zq.Hztbb, zq.Hztbc, zq.Hztbd);
                        _DataBase.DoCommand(sql);

                        _DataBase.CommitTransaction();
                        return(true);
                    }
                    _DataBase.RollbackTransaction();
                }
                else
                {
                    sql = string.Format(@"UPDATE JC_FZ_ZQ SET ZQ_NAME='{0}',ZQ_ADDRESS='{1}',ZQ_IPADDRESS='{2}',ZQ_HJCS={3},ZQ_MEMO='{4}'
                     ,ZQ_BDFS={5},BSCBZ={6},QYYY={7},XSFS={8} WHERE ZQ_ID={9}", zq.Zqname, zq.Zqaddress, zq.Zqipaddress, zq.Zqhjcs, zq.Zqmemo, zq.Zqbdfs, Convert.ToInt32(zq.Zqscbz), zq.Isqyyy, zq.Xsfs, zq.Zqid);

                    if (_DataBase.DoCommand(sql) > 0)
                    {
                        sql = "select * from JC_FZ_ZQTV where ZQID=" + zq.Zqid + "";
                        if (_DataBase.GetDataTable(sql).Rows.Count > 0)
                        {
                            sql = @"UPDATE JC_FZ_ZQTV SET HZTBA=" + zq.Hztba + ",HZTBB=" + zq.Hztbb + ",HZTBC=" + zq.Hztbc + ",HZTBD=" + zq.Hztbd + " WHERE ZQID=" + zq.Zqid + "";
                        }
                        else
                        {
                            sql = @"INSERT INTO JC_FZ_ZQTV(ZQID,HZTBA,HZTBB,HZTBC,HZTBD) VALUES(" + zq.Zqid + "," + zq.Hztba + "," + zq.Hztbb + "," + zq.Hztbc + "," + zq.Hztbd + ")";
                        }

                        _DataBase.DoCommand(sql);
                        _DataBase.CommitTransaction();
                        return(true);
                    }
                    _DataBase.RollbackTransaction();
                }
                msg = "保存失败!";
                return(false);
            }
            catch (Exception ea)
            {
                _DataBase.RollbackTransaction();
                msg = "保存失败!";
                throw ea;
            }
        }
Ejemplo n.º 6
0
        public void SingleRelationshipSavesAndDeletes()
        {
            _testName = System.Reflection.MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString();

            var seed = new Seed32();
            List<MockClassE> objs = null;
            var ids = new List<int>();

            using (var fLock = new ManagedFileLock(_testName))
            {
                Cleanup();

                using (var db = new RelationalDatabase<int, MockClassD>(_testName + ".database", "Id"))
                {
                    db.Load();

                    using (var t = db.BeginTransaction())
                    {
                        objs = TestResourceFactory.GetMockClassDObjects(3, db).ToList();

                        objs.ToList().ForEach(o => o.Id = db.Add(o));

                        t.Commit();
                    }
                }

                using (var db = new RelationalDatabase<int, MockClassD>(_testName + ".database"))
                {
                    db.Load();

                    var first = db.Fetch(objs[0].Id);

                    using (var t = db.BeginTransaction())
                    {
                        first.LowBall = new List<MockClassD>();

                        db.Update(first, first.Id);

                        t.Commit();
                    }

                    first = db.Fetch(objs[0].Id);

                    Assert.AreEqual(0, first.LowBall.Count());
                }

                using (var db = new RelationalDatabase<int, MockClassD>(_testName + ".database"))
                {
                    db.Load();

                    var first = db.Fetch(objs.First().Id);

                    Assert.AreEqual(0, first.LowBall.Count());
                }
            }
        }
Ejemplo n.º 7
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            if (lvwNew.Items.Count == 0)
            {
                return;
            }
            try
            {
                //定义多院操作日志 Modify By Tany 2010-01-29
                ts_HospData_Share.ts_update_log ts = new ts_HospData_Share.ts_update_log();
                Guid log_djid = Guid.Empty;

                db.BeginTransaction();
                foreach (ListViewItem item in this.lvwNew.Items)
                {
                    string sql = "update pub_system_menu set sort_id=" + item.Text + " where sys_menu_id=" + item.Tag.ToString();
                    db.DoCommand(sql);
                }
                //处理多院数据处理,首先插入操作日志 Modify By Tany 2010-01-29
                string cznr = "修改系统菜单:【system_id=" + systemId.ToString().Trim() + "】";
                ts.Save_log(ts_HospData_Share.czlx.jc_系统菜单修改, cznr, "pub_system_menu", "system_id", systemId.ToString(), jgbm, -999, "", out log_djid, db);
                db.CommitTransaction();

                try
                {
                    //查看该类型操作是否属于立即执行 Modify By Tany 2010-01-29
                    string errtext = "";
                    ts_HospData_Share.ts_update_type ty = new ts_HospData_Share.ts_update_type((int)ts_HospData_Share.czlx.jc_系统菜单修改, db);
                    if (ty.Bzx == 1 && log_djid != Guid.Empty)
                    {
                        //立即执行该操作 Modify By Tany 2010-01-29
                        ts.Pexec_log(log_djid, db, out errtext);
                    }
                    if (errtext != "")
                    {
                        throw new Exception(errtext);
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show("发生错误:" + err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                this.Close();
            }
            catch (Exception err)
            {
                db.RollbackTransaction();
                MessageBox.Show(err.Message);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 产生医嘱不产生费用
        /// </summary>
        /// <param name="inpatient_no">住院号</param>
        /// <param name="yzid">医嘱项目id</param>
        /// <param name="xyl">剂量</param>
        /// <param name="app_docid">申请医生id</param>
        /// <param name="app_deptid">申请科室id</param>
        /// <param name="_database">数据库连接对象</param>
        /// <param name="baby_id">婴儿id,大人为0</param>
        /// <param name="bb">标本id</param>
        /// <param name="jgbm">机构编码</param>
        /// <param name="bz">备注</param>
        public static void CommitOrder_notexe(string inpatient_no, long yzid, Decimal xyl, long app_docid, long app_deptid, RelationalDatabase _database, long baby_id, string bb, long jgbm, string bz)
        {
            string    sql = "select * from zy_inpatient where inpatient_no='" + inpatient_no + "' and flag in(1,3,4)";
            DataTable tb  = _database.GetDataTable(sql);

            bz = "";
            if (tb.Rows.Count == 0)
            {
                throw new Exception("没有找到住院号为【" + inpatient_no + "】的病人信息!!");
            }
            else
            {
                _database.BeginTransaction();
                try
                {
                    Ts_zyys_public.DbQuery dbquery = new DbQuery(_database);
                    sql = "select *,CASE WHEN  b.EXEC_DEPT>0 THEN b.EXEC_DEPT ELSE A.DEFAULT_DEPT END zkxsid   "
                          + " from JC_HOITEMDICTION a left join JC_HOI_DEPT b  on a.ORDER_ID=b.ORDER_ID "
                          + "  left join JC_DEPT_PROPERTY c on c.DEPT_ID=b.EXEC_DEPT  where a.ORDER_ID=" + yzid + "  and  c.jgbm=" + jgbm;
                    DataTable hoitemtb = _database.GetDataTable(sql);
                    if (hoitemtb.Rows.Count == 0)
                    {
                        throw new Exception("获取医嘱项目失败!!");
                    }
                    long   zxksid       = long.Parse(hoitemtb.Rows[0]["zkxsid"].ToString());
                    string ward_id      = Convert.ToString(_database.GetDataResult("select ward_id from JC_WARDRDEPT where dept_id='" + tb.Rows[0]["dept_id"].ToString() + "'"));
                    Guid   inpatient_id = new Guid(tb.Rows[0]["inpatient_id"].ToString());
                    long   yzNum        = dbquery.GetYzNum(_database, inpatient_id) + 1;
                    Guid   order_id     = PubStaticFun.NewGuid();
                    string commandtext  = string.Concat(new object[] {
                        "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,dwlx,MEMO,MEMO1,jgbm,zsl,jz_flag) "
                        + " VALUES('", order_id, "',", yzNum.ToString(), ",'", inpatient_id.ToString(), "',", app_deptid, ",'", ward_id, "',1,5,", FrmMdiMain.CurrentUser.EmployeeId, ",", yzid, ",2,'", "",
                        hoitemtb.Rows[0]["ORDER_NAME"].ToString() + bz, "',", xyl.ToString(), ",1,'", hoitemtb.Rows[0]["ORDER_UNIT"].ToString(), "',GetDate(),GetDate(),0,'", "", "','',", app_docid, ",0,0,", baby_id.ToString(), ",", tb.Rows[0]["dept_id"], ",", zxksid.ToString(), ",",
                        bb.ToString(), ",'", "", "★", "", "','", "", "',", jgbm, "," + xyl.ToString() + ",0)"
                    });
                    _database.DoCommand(commandtext);

                    dbquery.insertJY(_database, inpatient_id, baby_id, order_id);
                    // ts_zyhs_classes.BaseFunc bfucn = new ts_zyhs_classes.BaseFunc(_database);
                    //bfucn.ExecOrders("", inpatient_id, baby_id, yzNum, 1, DateManager.ServerDateTimeByDBType(_database), DateManager.ServerDateTimeByDBType(_database), app_docid, (int)jgbm);
                    _database.CommitTransaction();
                }
                catch (Exception ex)
                {
                    _database.RollbackTransaction();
                    throw ex;
                }
            }
        }
Ejemplo n.º 9
0
        public static string SaveMztf(DataSet dset, RelationalDatabase db)
        {
            try
            {
                db.BeginTransaction();
                DataTable tb        = dset.Tables["examReqInfoType"];
                string    ssql      = "";
                DataRow   row       = tb.Rows[0];
                string    examReqId = row["examReqId"].ToString();
                string    id        = row["id"].ToString();

                ParameterEx[] parameters = new ParameterEx[4];

                string sSql = "SP_WHZXYY_mz_cfb_tf";
                parameters[0].Value         = examReqId;
                parameters[0].Text          = "@jsdjh";
                parameters[1].ParaDirection = ParameterDirection.Output;
                parameters[1].Text          = "@Err_Code";
                parameters[1].ParaSize      = 50;
                parameters[2].ParaDirection = ParameterDirection.Output;
                parameters[2].Text          = "@err_text";
                parameters[2].ParaSize      = 1000;
                parameters[3].Value         = "";
                parameters[3].Text          = "@tfy";
                db.DoCommand(sSql, parameters, 60);

                int    errocde = Convert.ToInt32(parameters[1].Value);
                string errtext = parameters[2].Value.ToString();
                if (errocde != 0)
                {
                    throw new Exception(errtext);
                }

                db.CommitTransaction();

                System.String[] str = { errocde.ToString(), "保存成功" };
                return(HisFunctions.GetResponseString("SaveMzcf", str));
            }
            catch (Exception err)
            {
                db.RollbackTransaction();
                throw err;
            }
            finally
            {
            }
        }
Ejemplo n.º 10
0
        private bool ModifyDate()
        {
            RelationalDatabase db = InstanceForm.BDatabase;

            try
            {
                int i = 0;
                db.BeginTransaction();
                StringBuilder strUpdate = new StringBuilder();
                strUpdate.Append(" if (select isnull(yjid,'" + Guid.Empty + "') from VI_YK_DJ where id='" + this.t1.Tag.ToString().Trim() + "') = '" + Guid.Empty + "' ");
                strUpdate.Append("  begin");
                strUpdate.Append(" if exists(select * from yk_dj where id='" + this.t1.Tag.ToString().Trim() + "' and ywlx='012' )");
                strUpdate.Append("  begin");
                strUpdate.Append(" update yk_dj set sumjhje=sumjhje+" + (Convert.ToDecimal(t11.Text.Trim()) - yje) + " where id='" + this.t1.Tag.ToString().Trim() + "' and ywlx='012' ");
                strUpdate.Append("  end");
                strUpdate.Append("  else ");
                strUpdate.Append("   begin");
                strUpdate.Append(" update yk_dj_H set sumjhje=sumjhje+" + (Convert.ToDecimal(t11.Text.Trim()) - yje) + " where id='" + this.t1.Tag.ToString().Trim() + "' and ywlx='012' ");
                strUpdate.Append("    end");
                strUpdate.Append(" if exists(select * from yk_djmx where djid='" + this.t1.Tag.ToString().Trim() + "' and deptid='" + t2.Tag.ToString().Trim() + "' and cjid='" + t3.Tag.ToString().Trim() + "')");
                strUpdate.Append("  begin ");
                strUpdate.Append("  update yk_djmx set jhje=" + Convert.ToDecimal(t11.Text.Trim()) + " where djid='" + this.t1.Tag.ToString().Trim() + "' and deptid='" + t2.Tag.ToString().Trim() + "' and cjid='" + t3.Tag.ToString().Trim() + "'");
                strUpdate.Append("  end ");
                strUpdate.Append("  else ");
                strUpdate.Append("  begin");
                strUpdate.Append("  update yk_djmx_h set jhje=" + Convert.ToDecimal(t11.Text.Trim()) + " where djid='" + this.t1.Tag.ToString().Trim() + "' and deptid='" + t2.Tag.ToString().Trim() + "' and cjid='" + t3.Tag.ToString().Trim() + "'");
                strUpdate.Append("   end");
                strUpdate.Append(" update yk_cwtz_temp set tzjg=" + Convert.ToDecimal(t9.Text.Trim()) + ",tzsl=" + Convert.ToDecimal(t10.Text.Trim()) + ",tzje=" + Convert.ToDecimal(t11.Text.Trim()) + "  where id='" + this.Tag.ToString().Trim() + "'");
                strUpdate.Append("  end ");

                i = db.DoCommand(strUpdate.ToString());
                db.CommitTransaction();
                if (i > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception err)
            {
                db.RollbackTransaction();
                throw err;
            }
        }
Ejemplo n.º 11
0
        //通过划价id和处方内存表得到 医技申请表需要删除的记录 Modify By zp 2013-10-10
        //public static DataTable GetUnYjInfo(Guid hjid, DataRow[] rows, RelationalDatabase db)
        //{
        //    DataTable dt = new DataTable();
        //    try
        //    {

        //        string sql = @"SELECT * FROM YJ_MZSQ WHERE YZID='" + hjid + "'";
        //        DataTable dt_yj = db.GetDataTable(sql);

        //        for (int k = 0; k < dt_yj.Rows.Count; k++)
        //        {
        //            for (int j = 0; j < rows.Length; j++)
        //            {
        //                int r_sl = Convert.ToInt32(rows[j]["剂量"]);
        //                int d_sl = Convert.ToInt32(dt_yj.Rows[k]["SL"]);
        //                if (dt_yj.Rows[k]["YZXMID"].ToString().Trim()== rows[j]["yzid"].ToString().Trim() &&
        //                d_sl==r_sl)
        //                {
        //                    dt_yj.Rows.RemoveAt(k);
        //                    k--;
        //                    break;
        //                }
        //            }
        //        }
        //        /*得到最后的是医技表有的记录,处方表没有的 即需要删除医技的申请项目*/
        //        dt = dt_yj.Copy();
        //    }
        //    catch (Exception ea)
        //    {
        //        throw ea;
        //    }
        //    return dt;
        //}
        //通过老的挂号id 更新医技申请表、划价表的挂号id为新的挂号id 用于门诊收费时收费员先产生医技处方记录后产生挂号记录
        public static bool UpdateYjGhxxId(Guid UnGhid, Guid NewJzid, Guid NewGhid, RelationalDatabase db)
        {
            try
            {
                string sql = string.Format(@"UPDATE YJ_MZSQ GHXXID='{0}',JZID='{1}' WHERE GHXXID='{2}'", NewGhid, NewJzid, UnGhid);
                db.BeginTransaction();
                db.DoCommand(sql);
                sql = string.Format(@"UPDATE MZ_HJB SET GHXXID='{0}',JZID='{1}' WHERE GHXXID='{2}'", NewGhid, NewJzid, UnGhid);
                db.DoCommand(sql);
                db.CommitTransaction();
            }
            catch (Exception ea)
            {
                db.RollbackTransaction();
                throw ea;
            }
            return(true);
        }
Ejemplo n.º 12
0
        public void SingleRelationshipSaves()
        {
            _testName = System.Reflection.MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString();

            var seed = new Seed32();
            IList<MockClassE> objs = null;
            var ids = new List<int>();

            using (var fLock = new ManagedFileLock(_testName))
            {
                Cleanup();

                using (var db = new RelationalDatabase<int, MockClassD>(_testName + ".database", "Id"))
                {
                    db.Load();

                    using (var t = db.BeginTransaction())
                    {
                        objs = TestResourceFactory.GetMockClassDObjects(3, db).ToList();

                        objs.ToList().ForEach(o => o.Id = db.Add(o));

                        t.Commit();
                    }
                }

                using (var db = new RelationalDatabase<int, MockClassD>(_testName + ".database"))
                {
                    db.Load();

                    foreach (var obj in objs)
                    {
                        var orig = obj as MockClassE;
                        var item = db.Fetch(obj.Id) as MockClassE;

                        AssertMockClassE(item, orig, db);
                    }
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        ///  2014-7-15 jianqg 增加函数,整合收费项目联动处理医嘱项目状态(收费项目停用调用本函数,处理医嘱项目停用)
        /// 使用前 需要实例化类,主要是,_order_id,_order_name
        /// </summary>
        /// <param name="Used"></param>
        /// <param name="db">数据库连接</param>
        /// <param name="bTransaction">是否启用事务(医嘱项目直接保存用true,收费项目联动保存用false)</param>
        /// <param name="jgbm">机构编码(医嘱项目直接保存用InstanceForm._menuTag.Jgbm,收费项目联动保存传入)</param>
        /// <returns></returns>
        public bool SetUseable(bool Used, RelationalDatabase db, bool bTransaction, int jgbm)
        {
            ts_HospData_Share.ts_update_log ts = new ts_HospData_Share.ts_update_log();
            Guid   log_djid = Guid.Empty;
            string bz       = "";

            try
            {
                //InstanceForm.BDatabase.BeginTransaction();
                if (bTransaction)
                {
                    db.BeginTransaction();              //2014-7-15 修改,采用参数判断处理
                }
                string sql = "update jc_hoitemdiction set delete_bit=" + (Used ? "0" : "1") + " where order_id=" + this._order_id;
                //InstanceForm.BDatabase.DoCommand(sql);
                db.DoCommand(sql); //2014-7-15 修改,采用参数处理

                //三院数据处理
                bz = Used == true ? "启用医嘱项目:" + _order_name : "停用医嘱项目:" + _order_name;
                //ts.Save_log(ts_HospData_Share.czlx.jc_基础数据单表修改, bz, "jc_hoitemdiction", "order_id", _order_id.ToString(), InstanceForm._menuTag.Jgbm, 0, "", out log_djid, InstanceForm.BDatabase);
                ts.Save_log(ts_HospData_Share.czlx.jc_基础数据单表修改, bz, "jc_hoitemdiction", "order_id", _order_id.ToString(), jgbm, 0, "", out log_djid, db);//2014-7-15 修改,采用参数处理

                //InstanceForm.BDatabase.CommitTransaction();
                if (bTransaction)
                {
                    db.CommitTransaction();              //2014-7-15 修改,采用参数判断处理
                }
                //三院数据处理
                try
                {
                    string errtext = "";
                    //ts_HospData_Share.ts_update_type ty = new ts_HospData_Share.ts_update_type((int)ts_HospData_Share.czlx.jc_基础数据单表修改, InstanceForm.BDatabase);
                    ts_HospData_Share.ts_update_type ty = new ts_HospData_Share.ts_update_type((int)ts_HospData_Share.czlx.jc_基础数据单表修改, db);//2014-7-15 修改,采用参数处理
                    if (ty.Bzx == 1)
                    {
                        //ts.Pexec_log(log_djid, InstanceForm.BDatabase, out errtext);
                        ts.Pexec_log(log_djid, db, out errtext);//2014-7-15 修改,采用参数处理
                    }
                    if (errtext != "")
                    {
                        throw new Exception(errtext);
                    }
                }
                catch (System.Exception err)
                {
                    MessageBox.Show(bz + "成功  ." + err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception err)
            {
                //InstanceForm.BDatabase.RollbackTransaction();
                if (bTransaction)
                {
                    db.RollbackTransaction();              //2014-7-15 修改,采用参数判断处理
                }
                throw new Exception("Set医嘱项目Useable/" + err.Message);
            }


            return(true);
        }
Ejemplo n.º 14
0
        //保存按钮
        private void btsave_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable tb = (DataTable)dgvyzxm.DataSource;
                if (tb.Rows.Count == 0)
                {
                    MessageBox.Show("没有确认的费用", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
                }
                ;

                //验证病人的状态,如果出区或结算,不能修改费用 Modify By Tany 2015-06-16
                string    ssql = "select * from zy_inpatient(nolock) where inpatient_id in (select INPATIENT_ID from ZY_ORDERRECORD(nolock) where ORDER_ID='" + order_id + "')";
                DataTable tbpa = _DataBase.GetDataTable(ssql);
                if (tbpa.Rows.Count > 0)
                {
                    //出院病人不能修改费用
                    if (tbpa.Rows[0]["flag"].ToString() == "5" || tbpa.Rows[0]["flag"].ToString() == "2" || tbpa.Rows[0]["flag"].ToString() == "6" || tbpa.Rows[0]["flag"].ToString() == "10")
                    {
                        MessageBox.Show("该病人已经定义出院,不能执行该操作!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                //Modify by jchl   2016-12-30   不允许医技科室2016-12-31 18:00:00  到  2017-01-01 00:10:00  操作费用
                string _yblx = tbpa.Rows[0]["YBLX"].ToString().Trim();
                if (_yblx.Trim().Equals("1"))
                {
                    DateTime serDate = DateManager.ServerDateTimeByDBType(_DataBase);
                    DateTime dtMin   = DateTime.Parse("2016-12-31 18:00:00");
                    DateTime dtMax   = DateTime.Parse("2017-01-01 00:10:00");
                    if (serDate >= dtMin && serDate <= dtMax)
                    {
                        MessageBox.Show("因为年底大调价,根据医院的统一部署安排,12月31日 18点 至 次日0:10分 医保病人不允许操作费用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                ssql = "select * from zy_fee_speci(nolock) where order_id='" + order_id + "' and delete_bit=0 ";
                DataTable tbfee = _DataBase.GetDataTable(ssql);
                if (tbfee.Rows.Count > 0)
                {
                    if (tbfee.Rows[0]["discharge_bit"].ToString() == "1")
                    {
                        MessageBox.Show("该费用已结算,不能执行该操作", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    //Modify By Tany 2015-06-16 将这段代码移到外层
                    //ssql = "select * from zy_inpatient(nolock) where inpatient_id='" + tbfee.Rows[0]["inpatient_id"].ToString() + "' ";
                    //tbpa = _DataBase.GetDataTable(ssql);
                    //if (tbpa.Rows.Count > 0)
                    //{
                    //    //出院病人不能修改费用
                    //    if (tbpa.Rows[0]["flag"].ToString() == "5" || tbpa.Rows[0]["flag"].ToString() == "2" || tbpa.Rows[0]["flag"].ToString() == "6" || tbpa.Rows[0]["flag"].ToString() == "10")
                    //    {
                    //        MessageBox.Show("该病人定义出院,不能执行该操作", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //        return;
                    //    }
                    //}
                }

                if (new Guid(Convertor.IsNull(yjqrid, Guid.Empty.ToString())) != Guid.Empty)
                {
                    ssql = "select * from yj_zysq(nolock) where zxid='" + orderexec_id + "' and bscbz=0 and btfbz<>0";
                    DataTable tbtf = _DataBase.GetDataTable(ssql);
                    if (tbtf.Rows.Count > 0)
                    {
                        MessageBox.Show("该申请有退费信息,请先确认退费信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
                    }
                }


                DataTable tbmx = select.SelectTopFee(new Guid(order_id), _DataBase);
                if (tbmx.Rows.Count == 0)
                {
                    MessageBox.Show("没有找到该申请的原记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
                }
                ;

                string sDate = DateManager.ServerDateTimeByDBType(_DataBase).ToString();//登记时间

                Guid inpatient_id = new Guid(tbmx.Rows[0]["inpatient_id"].ToString());
                long baby_id      = Convert.ToInt64(tbmx.Rows[0]["baby_id"]);
                //Guid orderexec_id = new Guid(tbmx.Rows[0]["orderexec_id"].ToString());
                Guid    prescription_id = new Guid(tbmx.Rows[0]["prescription_id"].ToString());
                decimal presc_no        = Convert.ToDecimal(tbmx.Rows[0]["presc_no"].ToString());
                string  presc_date      = Convert.ToString(tbmx.Rows[0]["presc_date"].ToString());
                int     doc_id          = Convert.ToInt32(tbmx.Rows[0]["doc_id"].ToString());
                int     dept_id         = Convert.ToInt32(tbmx.Rows[0]["dept_id"].ToString());
                int     dept_br         = Convert.ToInt32(tbmx.Rows[0]["dept_br"].ToString());
                int     execdept_id     = Convert.ToInt32(tbmx.Rows[0]["execdept_id"].ToString());
                int     dept_ly         = Convert.ToInt32(tbmx.Rows[0]["dept_ly"].ToString());

                try
                {
                    _DataBase.BeginTransaction();

                    //添加或取消费用
                    bool    _bok = false;
                    decimal qrje = 0;
                    for (int i = 0; i <= tb.Rows.Count - 1; i++)
                    {
                        string id      = Convertor.IsNull(tb.Rows[i]["id"], "");
                        string y_cz_id = Convertor.IsNull(tb.Rows[i]["y_cz_id"], "");

                        string delete_bit = Convertor.IsNull(tb.Rows[i]["delete_bit"], "");
                        if (id == "")
                        {
                            string  cz_id         = Convertor.IsNull(tb.Rows[i]["cz_id"], "");
                            string  statitem_code = Convert.ToString(tb.Rows[i]["statitem_code"].ToString());
                            long    xmid          = Convert.ToInt64(tb.Rows[i]["xmid"].ToString());
                            string  subcode       = Convert.ToString(tb.Rows[i]["code"].ToString());
                            string  item_name     = Convert.ToString(tb.Rows[i]["name"].ToString());
                            string  unit          = Convert.ToString(tb.Rows[i]["item_unit"].ToString());
                            decimal price         = Convert.ToDecimal(tb.Rows[i]["price"].ToString());
                            decimal num           = Convert.ToDecimal(tb.Rows[i]["num"].ToString());
                            decimal je            = Convert.ToDecimal(tb.Rows[i]["je"].ToString());
                            qrje = qrje + je;
                            Guid   NewID    = Guid.Empty;
                            int    err_code = -1;
                            string err_text = "";
                            yjqr.SaveFee(inpatient_id, baby_id, new Guid(order_id), new Guid(orderexec_id), prescription_id, presc_no, presc_date, sDate, TrasenFrame.Forms.FrmMdiMain.CurrentUser.EmployeeId,
                                         statitem_code, xmid, subcode, item_name, unit, price, num, je, new Guid(Convertor.IsNull(cz_id, Guid.Empty.ToString())), doc_id, dept_id, dept_br, execdept_id, dept_ly, jgbm,
                                         out NewID, out err_code, out err_text, _DataBase);
                            if (err_code != 0 || NewID == Guid.Empty)
                            {
                                throw new Exception(err_text);
                            }
                            _bok = true;
                        }
                        if (delete_bit == "1")
                        {
                            decimal je = Convert.ToDecimal(tb.Rows[i]["je"].ToString());
                            qrje = qrje + (-1) * je;
                            yjqr.DeleteFee(new Guid(id), new Guid(Convertor.IsNull(y_cz_id, Guid.Empty.ToString())), _DataBase, new Guid(orderexec_id));
                        }
                    }

                    //控制签收问题
                    ssql = "select * from yj_zysq where zxid='" + orderexec_id + "' and bqsbz=1";
                    DataTable tbbbqs = _DataBase.GetDataTable(ssql);
                    if (tbbbqs.Rows.Count > 0 && new SystemCfg(10011, _DataBase).Config == "1")
                    {
                        throw new Exception("该申请标本已签收,不能修改费用");
                    }


                    //产生医技确认记灵
                    Guid NewQrid = Guid.Empty;
                    if (yjqrid != "" && (qrje != 0 || _bok == true))
                    {
                        int       err_code = -1;
                        string    err_text = "";
                        DataTable tbsq     = select.SelectZYSQ(new Guid(yjsqid), _DataBase);
                        if (tbsq.Rows.Count == 0)
                        {
                            throw new Exception("没有找到原申请记录");
                        }
                        yjqr.yj_zysq_qrjl(new Guid(order_id), new Guid(orderexec_id), new Guid(yjsqid), qrje, TrasenFrame.Forms.FrmMdiMain.CurrentDept.DeptId,
                                          sDate, TrasenFrame.Forms.FrmMdiMain.CurrentUser.EmployeeId, 0, Convertor.IsNull(tbsq.Rows[0]["jcrq"], ""),
                                          Convert.ToInt32(Convertor.IsNull(tbsq.Rows[0]["jcys"], "0")), "", out NewQrid, out err_code, out err_text, 0, _DataBase);
                        if (err_code != 0 || NewQrid == Guid.Empty)
                        {
                            throw new Exception(err_text);
                        }
                        btsave.Enabled   = false;
                        btadd.Enabled    = false;
                        btdel.Enabled    = false;
                        btcancel.Enabled = false;
                    }

                    _DataBase.CommitTransaction();

                    #region "医保智审调用"

                    try
                    {
                        bool CanAudit = ClsAuditCheck.CheckIsAuditCheck(inpatient_id.ToString(), _DataBase);//是否需要智审
                        if (CanAudit)
                        {
                            if (baby_id == 0)
                            {
                                string strMsg = "";
                                bool   bSuc   = DoVaildYbFee(new DataTable(), 1, 1, inpatient_id, baby_id, out strMsg);
                                if (!bSuc)
                                {
                                    MessageBox.Show(strMsg, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }
                        }
                    }
                    catch
                    { }

                    #endregion

                    if (NewQrid != Guid.Empty)
                    {
                        yjqrid = NewQrid.ToString();
                    }
                    loaddata();
                }
                catch (System.Exception err)
                {
                    _DataBase.RollbackTransaction();
                    throw new Exception(err.Message);
                }
            }
            catch (System.Exception err)
            {
                MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 15
0
        public void SingleRelationshipSavesAndSelects()
        {
            _testName = System.Reflection.MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString();

            var seed = new Seed32();
            List<MockClassE> objs = null;
            var ids = new List<int>();

            using (var fLock = new ManagedFileLock(_testName))
            {
                Cleanup();

                using (var db = new RelationalDatabase<int, MockClassD>(_testName + ".database", "Id"))
                {
                    db.Load();

                    using (var t = db.BeginTransaction())
                    {
                        objs = TestResourceFactory.GetMockClassDObjects(3, db).ToList();

                        objs.ToList().ForEach(o => o.Id = db.Add(o));

                        t.Commit();
                    }
                }

                using (var db = new RelationalDatabase<int, MockClassD>(_testName + ".database"))
                {
                    db.Load();

                    var first = db.SelectFirst(s => s.Value<int>("Id") > 0, 50);

                    foreach (var obj in objs)
                        AssertMockClassE((MockClassE)first.First(f => f.Id == obj.Id), obj as MockClassE, db);

                    var last = db.SelectLast(s => s.Value<int>("Id") > 0, 50);

                    foreach (var obj in objs)
                        AssertMockClassE((MockClassE)last.First(f => f.Id == obj.Id), obj as MockClassE, db);
                }
            }
        }
Ejemplo n.º 16
0
        //单病种
        public static void dbz_yb_js(Guid brxxid, Guid ghxxid, string mzh, User _BCurrentUser, Department _BCurrentDept, RelationalDatabase _DataBase)
        {
            #region 变量付值

            SystemCfg cfg1063 = new SystemCfg(1063);// 是否自动确费 Add By Zj 2012-07-02

            DataTable tb = mz_sf.Select_Wsfcf(0, Guid.Empty, ghxxid, 0, 0, Guid.Empty, 1, _DataBase);

            string ssql = "";

            //分组处方
            string[] GroupbyField           = { "HJID", "科室ID", "医生ID", "执行科室ID", "住院科室ID", "项目来源", "剂数", "划价日期", "hjy", "划价窗口" };
            string[] ComputeField           = { "金额", "hjmxid" };
            string[] CField                 = { "sum", "count" };
            TrasenFrame.Classes.TsSet xcset = new TrasenFrame.Classes.TsSet();
            xcset.TsDataTable = tb;
            DataTable tbcf = xcset.GroupTable(GroupbyField, ComputeField, CField, "1=1");
            if (tbcf.Rows.Count == 0)
            {
                MessageBox.Show("没有要收费的处方"); return;
            }

            Guid _hjid = Guid.Empty;
            int  _xmly = 0;

            //返回变量
            int    err_code = -1;
            string err_text = "";
            //时间
            string sDate = DateManager.ServerDateTimeByDBType(_DataBase).ToString();

            #endregion

            #region 处方审核
            try
            {
                //处方审核控制
                //医保病人处方需要审核
                //SystemCfg syscfg1 = new SystemCfg(1042);
                //if (syscfg1.Config == "1" && Convertor.IsNull(cmbyblx.SelectedValue, "0") != "0")
                //{
                //    DataRow[] rows = tb.Select(" 审核状态=0 or 审核状态=2");
                //    if (rows.Length > 0)
                //    {
                //        MessageBox.Show("该病人有处方未通过审核,不能收费", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //        return;
                //    }
                //}
                //所有病人的药品处方需要审核
                SystemCfg syscfg2 = new SystemCfg(1043);
                if (syscfg2.Config == "1")
                {
                    DataRow[] rows = tb.Select(" (审核状态=0 or 审核状态=2) and 项目来源=1");
                    if (rows.Length > 0)
                    {
                        MessageBox.Show("该病人有药品处方未通过审核,不能收费", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
            }
            catch (System.Exception err)
            {
                MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            #endregion

            #region 验证是否更改处方
            for (int i = 0; i <= tbcf.Rows.Count - 1; i++)
            {
                Guid    yz_hjid = new Guid(Convertor.IsNull(tbcf.Rows[i]["hjid"], Guid.Empty.ToString()));
                decimal yz_cfje = Math.Round(Convert.ToDecimal(Convertor.IsNull(tbcf.Rows[i]["金额"], "0")), 2);
                ssql = "select * from mz_hjb where hjid='" + yz_hjid + "'";
                DataTable yz_tb = _DataBase.GetDataTable(ssql);
                if (yz_tb.Rows.Count > 0)
                {
                    if (Convert.ToDecimal(yz_tb.Rows[0]["cfje"]) != yz_cfje)
                    {
                        MessageBox.Show("处方可能已更改,请重新刷新数据后重试!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (yz_tb.Rows[0]["bsfbz"].ToString() == "1")
                    {
                        MessageBox.Show("处方可能已收费,请重新刷新数据后重试!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("处方可能已删除,请刷新数据后重试!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                //add by zouchihua 2013-4-9 增加项目的判断 yzid
                ssql = "select * from mz_hjb_mx where hjid='" + yz_hjid + "' and  yzid='" + tbcf.Rows[i]["yzid"].ToString() + "'";
                DataTable hjmx = _DataBase.GetDataTable(ssql);
                if (hjmx.Rows.Count <= 0)
                {
                    MessageBox.Show("处方可能已经修改,请刷新数据后重试!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            #endregion

            try
            {
                sDate = DateManager.ServerDateTimeByDBType(_DataBase).ToString();

                _DataBase.BeginTransaction();

                #region 保处到处方表
                //decimal cfje = 0;
                for (int i = 0; i <= tbcf.Rows.Count - 1; i++)
                {
                    //插入处方头
                    Guid   _NewCfid = Guid.Empty;
                    string _mzh     = mzh;
                    _hjid = new Guid(Convertor.IsNull(tbcf.Rows[i]["hjid"], Guid.Empty.ToString()));
                    int _ksdm   = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["科室id"], "0"));
                    int _ysdm   = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["医生id"], "0"));
                    int _zxksdm = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["执行科室id"], "0"));
                    int _zyksdm = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["住院科室id"], "0"));
                    _xmly = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["项目来源"], "0"));
                    int     _js    = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["剂数"], "0"));
                    string  _cfrq  = tbcf.Rows[i]["划价日期"].ToString();
                    int     _hjyid = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["hjy"], "0"));
                    string  _hjyxm = Fun.SeekEmpName(_hjyid, _DataBase);
                    string  _hjck  = tbcf.Rows[i]["划价窗口"].ToString();
                    decimal _cfje  = Math.Round(Convert.ToDecimal(Convertor.IsNull(tbcf.Rows[i]["金额"], "0")), 2);


                    DataRow[] rows = tb.Select("HJID='" + _hjid + "' and 项目id>0");

                    long rowcount = Convert.ToInt32(tbcf.Rows[i]["HJMXID"]);
                    if (rowcount != rows.Length)
                    {
                        throw new Exception("分组处方时有" + rowcount + "行,插入处方时有" + rows.Length + "行.请检查处方状态或刷新处方再试");
                    }

                    if (rows.Length == 0)
                    {
                        throw new Exception("没有找到处方明细,请和管理员联系");
                    }
                    mz_cf.SaveCf(Guid.Empty, brxxid, ghxxid, _mzh, _hjck, _cfje, _cfrq, _hjyid, _hjyxm, _hjck, _hjid, _ksdm, Fun.SeekDeptName(_ksdm, _DataBase), _ysdm, Fun.SeekEmpName(_ysdm, _DataBase), _zyksdm, _zxksdm, Fun.SeekDeptName(_zxksdm, _DataBase), 0, 0, _xmly, 0, _js, TrasenFrame.Forms.FrmMdiMain.Jgbm, out _NewCfid, out err_code, out err_text, _DataBase);
                    if (_NewCfid == Guid.Empty || err_code != 0)
                    {
                        throw new Exception(err_text);
                    }

                    //插处方明细表

                    for (int j = 0; j <= rows.Length - 1; j++)
                    {
                        int _tcid = Convert.ToInt32(Convertor.IsNull(rows[j]["套餐id"], "0"));
                        //如果是套餐则分解保存
                        if (_tcid > 0)
                        {
                            #region 如果是套餐则分解保存

                            DataRow[] tcrow = tb.Select("HJID='" + _hjid + "' and  套餐id=" + _tcid + " ");
                            if (tcrow.Length == 0)
                            {
                                throw new Exception("查找套餐次数时出错,没有找到匹配的行");
                            }
                            _js = Convert.ToInt32(Convertor.IsNull(tcrow[0]["数量"], "0"));
                            DataTable Tabtc   = mz_sf.Select_Wsfcf(0, Guid.Empty, ghxxid, _tcid, _js, _hjid, _DataBase);
                            long      _tcyzid = Convert.ToInt64(Convertor.IsNull(rows[j]["yzid"], "0")); //Add By Zj 2012-08-14 根据yzid判断套餐
                            DataRow[] rows_tc = Tabtc.Select(" yzid=" + _tcyzid + " ");                  //" "
                            if (rows_tc.Length == 0)
                            {
                                throw new Exception("没有找到套餐的明细");
                            }
                            for (int xx = 0; xx <= rows_tc.Length - 1; xx++)
                            {
                                Guid    _NewCfmxid = Guid.Empty;
                                Guid    _hjmxid    = new Guid(Convertor.IsNull(rows_tc[xx]["hjmxid"], Guid.Empty.ToString()));
                                string  _pym       = Convertor.IsNull(rows_tc[xx]["拼音码"], "");
                                string  _bm        = Convertor.IsNull(rows_tc[xx]["编码"], "");
                                string  _pm        = Convertor.IsNull(rows_tc[xx]["项目名称"], "");
                                string  _spm       = Convertor.IsNull(rows_tc[xx]["商品名"], "");
                                string  _gg        = Convertor.IsNull(rows_tc[xx]["规格"], "");
                                string  _cj        = Convertor.IsNull(rows_tc[xx]["厂家"], "");
                                decimal _dj        = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["单价"], "0"));
                                decimal _sl        = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["数量"], "0"));
                                string  _dw        = Convertor.IsNull(rows_tc[xx]["单位"], "");
                                int     _ydwbl     = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["ydwbl"], "0"));
                                decimal _je        = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["金额"], "0"));
                                string  _tjdxmdm   = Convertor.IsNull(rows_tc[xx]["统计大项目"], "");
                                long    _xmid      = Convert.ToInt64(Convertor.IsNull(rows_tc[xx]["项目id"], "0"));
                                //int _bpsyybz = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["皮试用药"], "0"));
                                int _bpsbz = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["皮试标志"], "0"));
                                //int _bmsbz = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["免试标志"], "0"));
                                decimal _yl     = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["剂量"], "0"));
                                string  _yldw   = Convertor.IsNull(rows_tc[xx]["剂量单位"], "");
                                int     _yldwid = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["剂量单位id"], "0"));
                                int     _dwlx   = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["dwlx"], "0"));
                                int     _yfid   = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["用法id"], "0"));
                                string  _yfmc   = Convert.ToString(Convertor.IsNull(rows_tc[xx]["用法"], "0"));
                                int     _pcid   = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["频次id"], "0"));
                                string  _pcmc   = Convert.ToString(Convertor.IsNull(rows_tc[xx]["频次"], "0"));
                                decimal _ts     = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["天数"], "0"));
                                string  _zt     = Convert.ToString(Convertor.IsNull(rows_tc[xx]["嘱托"], "0"));
                                int     _fzxh   = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["处方分组序号"], "0"));
                                int     _pxxh   = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["排序序号"], "0"));
                                decimal _pfj    = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["批发价"], "0"));
                                decimal _pfje   = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["批发金额"], "0"));
                                if (_js != Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["剂数"], "0")))
                                {
                                    throw new Exception("处方可能已修改,请重新刷新");
                                }
                                mz_cf.SaveCfmx(Guid.Empty, _NewCfid, _pym, _bm, _pm, _spm, _gg, _cj, _dj, _sl, _dw, _ydwbl, _js, _je, _tjdxmdm, _xmid, _hjmxid, _bm, 0, _bpsbz,
                                               Guid.Empty, _yl, _yldw, _yfmc, _pcid, _ts, _zt, _fzxh, _pxxh, Guid.Empty, _pfj, _pfje, _tcid, out _NewCfmxid, out err_code, out err_text, _DataBase);
                                if (_NewCfmxid == Guid.Empty || err_code != 0)
                                {
                                    throw new Exception(err_text);
                                }

                                #region 套餐确费
                                if (cfg1063.Config == "1" && Convert.ToInt32(Convertor.IsNull(rows[j]["执行科室ID"], "0")) != 0)
                                {
                                    ParameterEx[] parameters = new ParameterEx[10];
                                    parameters[0].Text  = "@CFID";
                                    parameters[0].Value = _NewCfid;
                                    parameters[1].Text  = "@CFMXID";
                                    parameters[1].Value = _NewCfmxid;
                                    parameters[2].Text  = "@TCID";
                                    parameters[2].Value = _tcid;


                                    parameters[3].Text  = "@BQRBZ";
                                    parameters[3].Value = 1;
                                    parameters[4].Text  = "@QRKS";
                                    parameters[4].Value = Convert.ToInt32(Convertor.IsNull(rows[j]["执行科室ID"], "0"));
                                    parameters[5].Text  = "@QRRQ";
                                    parameters[5].Value = sDate;

                                    parameters[6].Text  = "@QRDJY";
                                    parameters[6].Value = _BCurrentUser.EmployeeId;

                                    parameters[7].Text          = "@err_code";
                                    parameters[7].ParaDirection = ParameterDirection.Output;
                                    parameters[7].DataType      = System.Data.DbType.Int32;
                                    parameters[7].ParaSize      = 100;

                                    parameters[8].Text          = "@err_text";
                                    parameters[8].ParaDirection = ParameterDirection.Output;
                                    parameters[8].ParaSize      = 100;

                                    parameters[9].Text  = "@YQRKS";
                                    parameters[9].Value = 0;

                                    _DataBase.GetDataTable("SP_YJ_SAVE_QRJL_MZ", parameters, 60);
                                    err_code = Convert.ToInt32(parameters[7].Value);
                                    err_text = Convert.ToString(parameters[8].Value);
                                    if (err_code != 0)
                                    {
                                        throw new Exception(err_text);
                                    }
                                }
                                #endregion
                            }

                            #endregion
                        }
                        else
                        {
                            #region 非套餐
                            Guid    _NewCfmxid = Guid.Empty;
                            Guid    _hjmxid    = new Guid(Convertor.IsNull(rows[j]["hjmxid"], Guid.Empty.ToString()));
                            string  _pym       = Convertor.IsNull(rows[j]["拼音码"], "");
                            string  _bm        = Convertor.IsNull(rows[j]["编码"], "");
                            string  _pm        = Convertor.IsNull(rows[j]["项目名称"], "");
                            string  _spm       = Convertor.IsNull(rows[j]["商品名"], "");
                            string  _gg        = Convertor.IsNull(rows[j]["规格"], "");
                            string  _cj        = Convertor.IsNull(rows[j]["厂家"], "");
                            decimal _dj        = Convert.ToDecimal(Convertor.IsNull(rows[j]["单价"], "0"));
                            decimal _sl        = Convert.ToDecimal(Convertor.IsNull(rows[j]["数量"], "0"));
                            string  _dw        = Convertor.IsNull(rows[j]["单位"], "");
                            int     _ydwbl     = Convert.ToInt32(Convertor.IsNull(rows[j]["ydwbl"], "0"));
                            decimal _je        = Convert.ToDecimal(Convertor.IsNull(rows[j]["金额"], "0"));
                            string  _tjdxmdm   = Convertor.IsNull(rows[j]["统计大项目"], "");
                            long    _xmid      = Convert.ToInt64(Convertor.IsNull(rows[j]["项目id"], "0"));
                            //int _bpsyybz = Convert.ToInt32(Convertor.IsNull(rows[j]["皮试用药"], "0"));
                            int _bpsbz = Convert.ToInt32(Convertor.IsNull(rows[j]["皮试标志"], "0"));
                            //int _bmsbz = Convert.ToInt32(Convertor.IsNull(rows[j]["免试标志"], "0"));
                            decimal _yl       = Convert.ToDecimal(Convertor.IsNull(rows[j]["剂量"], "0"));
                            string  _yldw     = Convertor.IsNull(rows[j]["剂量单位"], "");
                            int     _yldwid   = Convert.ToInt32(Convertor.IsNull(rows[j]["剂量单位id"], "0"));
                            int     _dwlx     = Convert.ToInt32(Convertor.IsNull(rows[j]["dwlx"], "0"));
                            int     _yfid     = Convert.ToInt32(Convertor.IsNull(rows[j]["用法id"], "0"));
                            string  _yfmc     = Convert.ToString(Convertor.IsNull(rows[j]["用法"], "0"));
                            int     _pcid     = Convert.ToInt32(Convertor.IsNull(rows[j]["频次id"], "0"));
                            string  _pcmc     = Convert.ToString(Convertor.IsNull(rows[j]["频次"], "0"));
                            decimal _ts       = Convert.ToDecimal(Convertor.IsNull(rows[j]["天数"], "0"));
                            string  _zt       = Convert.ToString(Convertor.IsNull(rows[j]["嘱托"], ""));
                            int     _fzxh     = Convert.ToInt32(Convertor.IsNull(rows[j]["处方分组序号"], "0"));
                            int     _pxxh     = Convert.ToInt32(Convertor.IsNull(rows[j]["排序序号"], "0"));
                            decimal _pfj      = Convert.ToDecimal(Convertor.IsNull(rows[j]["批发价"], "0"));
                            decimal _pfje     = Convert.ToDecimal(Convertor.IsNull(rows[j]["批发金额"], "0"));
                            Guid    _pshjmxid = new Guid(Convertor.IsNull(rows[j]["pshjmxid"], Guid.Empty.ToString()));
                            mz_cf.SaveCfmx(Guid.Empty, _NewCfid, _pym, _bm, _pm, _spm, _gg, _cj, _dj, _sl, _dw, _ydwbl, _js, _je, _tjdxmdm, _xmid, _hjmxid, _bm, 0, _bpsbz,
                                           _pshjmxid, _yl, _yldw, _yfmc, _pcid, _ts, _zt, _fzxh, _pxxh, Guid.Empty, _pfj, _pfje, 0, out _NewCfmxid, out err_code, out err_text, _DataBase);
                            if (_NewCfmxid == Guid.Empty || err_code != 0)
                            {
                                throw new Exception(err_text);
                            }
                            //Add By Zj 2012-07-10
                            string updatejsdsql = "update mz_cfb_mx set jsd='" + Convert.ToString(Convertor.IsNull(rows[j]["JSD"], "0")) + "' where cfmxid='" + _NewCfmxid.ToString() + "' ";
                            _DataBase.DoCommand(updatejsdsql);
                            #region 非套餐确费
                            if (cfg1063.Config == "1" && Convert.ToInt32(Convertor.IsNull(rows[j]["执行科室ID"], "0")) != 0)
                            {
                                ParameterEx[] parameters = new ParameterEx[10];
                                parameters[0].Text  = "@CFID";
                                parameters[0].Value = _NewCfid;
                                parameters[1].Text  = "@CFMXID";
                                parameters[1].Value = _NewCfmxid;
                                parameters[2].Text  = "@TCID";
                                parameters[2].Value = 0;


                                parameters[3].Text  = "@BQRBZ";
                                parameters[3].Value = 1;
                                parameters[4].Text  = "@QRKS";
                                parameters[4].Value = Convert.ToInt32(Convertor.IsNull(rows[j]["执行科室ID"], "0"));
                                parameters[5].Text  = "@QRRQ";
                                parameters[5].Value = sDate;

                                parameters[6].Text  = "@QRDJY";
                                parameters[6].Value = _BCurrentUser.EmployeeId;

                                parameters[7].Text          = "@err_code";
                                parameters[7].ParaDirection = ParameterDirection.Output;
                                parameters[7].DataType      = System.Data.DbType.Int32;
                                parameters[7].ParaSize      = 100;

                                parameters[8].Text          = "@err_text";
                                parameters[8].ParaDirection = ParameterDirection.Output;
                                parameters[8].ParaSize      = 100;

                                parameters[9].Text  = "@YQRKS";
                                parameters[9].Value = 0;

                                _DataBase.GetDataTable("SP_YJ_SAVE_QRJL_MZ", parameters, 60);
                                err_code = Convert.ToInt32(parameters[7].Value);
                                err_text = Convert.ToString(parameters[8].Value);
                                if (err_code != 0)
                                {
                                    throw new Exception(err_text);
                                }
                            }
                            #endregion
                            #endregion 非套餐
                        }
                    }
                }
                #endregion

                _DataBase.CommitTransaction();
            }
            catch (System.Exception err)
            {
                _DataBase.RollbackTransaction();
                MessageBox.Show("保存数据出错!" + err.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Ejemplo n.º 17
0
        private void butsave_Click(object sender, EventArgs e)
        {
            if (Convertor.IsNumeric(txtpfj.Text) == false)
            {
                MessageBox.Show("请输入批发价", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (Convertor.IsNumeric(txtlsj.Text) == false)
            {
                MessageBox.Show("请输入零售价", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (Convert.ToDecimal(txtpfj.Text) == 0)
            {
                if (MessageBox.Show("批发价为零您确认吗 ?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return;
                }
            }
            if (Convert.ToDecimal(txtlsj.Text) == 0)
            {
                if (MessageBox.Show("零售价为零您确认吗 ?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return;
                }
            }

            //药品所在服务器的链接
            string    ssql    = "select * from pub_menu where function_name='Fun_ts_yp_ypcd'";
            DataTable tbcd    = _DataBase.GetDataTable(ssql);
            int       cd_jgbm = Convert.ToInt32(tbcd.Rows[0]["jgbm"]);

            if (cd_jgbm == -1)
            {
                cd_jgbm = TrasenFrame.Forms.FrmMdiMain.Jgbm;
            }
            RelationalDatabase database = TrasenFrame.Classes.WorkStaticFun.GetJgbmDb(cd_jgbm);

            int    Newcjid  = 0;
            int    err_code = 0;
            string err_text = "";

            Ypcj cj = new Ypcj(_cjid, database);

            ssql = "select * from yp_ypcjd where ggid=" + cj.GGID + " and sccj=" + Convertor.IsNull(txtsccj.Tag, "0") + " and lsj=" + Math.Round(Convert.ToDecimal(txtlsj.Text), 2) + " ";
            DataTable tb = database.GetDataTable(ssql);

            if (tb.Rows.Count >= 1)
            {
                if (Convert.ToInt16(tb.Rows[0]["bdelete"]).ToString() == "1")
                {
                    if (MessageBox.Show("该价格的药品在词典中已存在,但已停用,您要启用吗 ?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        return;
                    }

                    Guid log_djid_x = Guid.Empty;
                    ts_HospData_Share.ts_update_log ts_x = new ts_HospData_Share.ts_update_log();

                    try
                    {
                        database.BeginTransaction();
                        ssql = "update yp_ypcjd set bdelete=0 where cjid=" + tb.Rows[0]["cjid"].ToString() + " ";
                        database.DoCommand(ssql);

                        ssql = "update yp_ypggd set bdelete=0 where ggid=" + tb.Rows[0]["ggid"].ToString() + " ";
                        database.DoCommand(ssql);

                        //三院数据处理
                        ts_x.Save_log(ts_HospData_Share.czlx.yp_药品字典修改, TrasenFrame.Forms.FrmMdiMain.CurrentUser.Name + "对药品【" + cj.S_YPPM + " " + cj.S_YPGG + "  " + cj.S_SCCJ + " 】 进行修改", "yp_ypcjd", "cjid", cj.CJID.ToString(), cd_jgbm, 0, "", out log_djid_x, database);
                        database.CommitTransaction();
                    }
                    catch (System.Exception err)
                    {
                        database.RollbackTransaction();
                        MessageBox.Show("启用时出错" + err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (log_djid_x != Guid.Empty)
                    {
                        ts_x.Pexec_log(log_djid_x, database, out err_text);
                    }

                    ReturnCjid = Convert.ToInt32(tb.Rows[0]["cjid"]);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("词典中已存在相同厂家和价格的药品,不能重复添加", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }


            Guid log_djid = Guid.Empty;

            ts_HospData_Share.ts_update_log ts = new ts_HospData_Share.ts_update_log();

            try
            {
                database.BeginTransaction();

                Ypcj newcj = new Ypcj();
                newcj           = cj;
                newcj.CJID      = 0;
                newcj.PFJ       = Convert.ToDecimal(txtpfj.Text);
                newcj.LSJ       = Convert.ToDecimal(txtlsj.Text);
                newcj.SCCJ      = Convert.ToInt32(Convertor.IsNull(txtsccj.Tag, "0"));
                newcj.S_SCCJ    = txtsccj.Text.Trim();
                newcj.MRJJ      = 0;
                newcj.CJBDELETE = false;
                newcj.CJDJSJ    = DateManager.ServerDateTimeByDBType(database).ToString();



                newcj.SaveCJ(out Newcjid, out err_code, out err_text, database);
                if (err_code != 0)
                {
                    throw new Exception(err_text);
                }


                //更新药品货号
                newcj.Update_shh(newcj.GGID, out err_code, out err_text, database);
                if (err_code != 0)
                {
                    throw new Exception(err_text);
                }

                //三院数据处理
                ts.Save_log(ts_HospData_Share.czlx.yp_药品字典修改, TrasenFrame.Forms.FrmMdiMain.CurrentUser.Name + "新增【" + newcj.S_YPPM + " " + newcj.S_YPGG + "  " + newcj.S_SCCJ + " 】 价格:" + txtlsj.Text.Trim() + "", "yp_ypcjd", "cjid", Newcjid.ToString(), cd_jgbm, 0, "", out log_djid, database);


                database.CommitTransaction();
            }
            catch (System.Exception err)
            {
                database.RollbackTransaction();
                MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (log_djid != Guid.Empty)
            {
                ts.Pexec_log(log_djid, database, out err_text);

                this.Cursor = TrasenClasses.GeneralClasses.PubStaticFun.WaitCursor();
                System.Threading.Thread.Sleep(2 * 5000);
            }



            ReturnCjid = Newcjid;
            this.Close();
        }
Ejemplo n.º 18
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text.Trim() == "" || this.textBox4.Text.Trim() == "")
            {
                MessageBox.Show("医疗机构编码和用户名不能为空!");
                return;
            }


            if (optype == OPTYPE.新增)
            {
                string Workno = this.textBox1.Text.Trim().ToUpper();
                string strsql = "select count(*) from HIS_WORKERS where Ucase(workno)='" + Workno + "'";
                if (Convert.ToInt32(_Oledb.GetDataResult(strsql)) > 0)
                {
                    MessageBox.Show("医疗机构编码已经存在,不能重复添加!");
                    this.textBox1.Focus();
                    return;
                }
                string Code = this.textBox4.Text.Trim().ToUpper();
                strsql = "select count(*) from base_user where ucase(code)='" + Code + "'";
                if (Convert.ToInt32(_Oledb.GetDataResult(strsql)) > 0)
                {
                    MessageBox.Show("此用户名已经存在,不能重复添加!");
                    this.textBox4.Focus();
                    return;
                }
                if (MessageBox.Show("医疗机构编码和用户名保存后就不允许修改,是否继续保存?", "询问", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
                object WorkID, LayerID, GroupID, EmployeeID, UserID;
                string strsql_work  = @"insert into his_workers(WORKNO, WORKNAME, WORKMEMO,CRYP_FLAG, PASSLENGTH, PASSBACK) 
                            values('" + Workno + "','" + this.textBox2.Text.Trim() + "','" + this.textBox3.Text.Trim() + "',0,4,0)";
                string strsql_layer = @"insert into base_dept_layer(P_LAYER_ID, NAME, WORKID) values(0,'全院',{0})";

                string strsql_dept       = @"insert into base_dept_property(P_DEPT_ID, LAYER,  NAME,  MZ_FLAG, ZY_FLAG, YJ_FLAG, JZ_FLAG, DELETED, ISFACT,
                                 WORKID)
                                values({0},0,'信息科',0,0,0,0,0,1,
                                 {1})";
                string strsql_group      = @"insert into base_group(NAME, DELETE_FLAG, ADMINISTRATORS, EVERYONE,WORKID)
                                values('超级用户组',0,1,0,{0})";
                string strsql_employee   = @"insert into base_employee_property(NAME, SEX, STATUS, DELETE_BIT, 
                                 WORKID)
                                values('" + this.textBox5.Text.Trim() + "',0,0,0,{0})";
                string strsql_user       = @"insert into base_user(EMPLOYEE_ID, CODE, PASSWORD, GROUP_ID, WORKID, ISADMIN)
                                values({0},'" + Code + "','1',{1},{2},1)";
                string strsql_GROUP_USER = @"insert into BASE_GROUP_USER(USER_ID, GROUP_ID, WORKID)
                                values({0},{1},{2})";
                try
                {
                    //_Oledb = new OleDB();
                    _Oledb.BeginTransaction();
                    _Oledb.InsertRecord(strsql_work, out WorkID);

                    strsql_layer = String.Format(strsql_layer, WorkID);
                    _Oledb.InsertRecord(strsql_layer, out LayerID);

                    strsql_dept = string.Format(strsql_dept, LayerID, WorkID);
                    _Oledb.DoCommand(strsql_dept);

                    strsql_group = string.Format(strsql_group, WorkID);
                    _Oledb.InsertRecord(strsql_group, out GroupID);

                    strsql_employee = string.Format(strsql_employee, WorkID);
                    _Oledb.InsertRecord(strsql_employee, out EmployeeID);

                    strsql_user = string.Format(strsql_user, EmployeeID, GroupID, WorkID);
                    _Oledb.InsertRecord(strsql_user, out UserID);

                    strsql_GROUP_USER = string.Format(strsql_GROUP_USER, UserID, GroupID, WorkID);
                    _Oledb.DoCommand(strsql_GROUP_USER);

                    _Oledb.CommitTransaction();
                    MessageBox.Show("添加成功!");
                    FrmMain_Load(null, null);
                }
                catch (Exception err)
                {
                    _Oledb.RollbackTransaction();
                    MessageBox.Show(err.Message);
                }
            }
            else
            {
                string strsql_worker = "update HIS_WORKERS set WORKNAME='" + this.textBox2.Text.Trim() + "' , WORKMEMO='" + this.textBox3.Text.Trim() + "' where workid=" + WorkID;
                // string strsql_employee="update base_employee_property set name='"+this.textBox5.Text.Trim()+"' where "
                _Oledb.DoCommand(strsql_worker);
                MessageBox.Show("修改成功!");
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 更新菜单信息
        /// </summary>
        private bool UpdateMenuInfo()
        {
            try
            {
                //jianqg emr-his 整合暂时注释  本函数 需要修改几处
                //增加参数CanUsePublicPwd jianqg 2012-10-6 emr-his框架整合  增加
                ParameterEx[] paras = new ParameterEx[10];
                #region ...
                paras[0].Text          = "@MenuId";
                paras[0].Value         = this.m_currentMenuId;
                paras[1].Text          = "@Name";
                paras[1].Value         = txtMenuName.Text.Trim();
                paras[2].Text          = "@DllName";
                paras[2].Value         = this.txtDllName.Text.Trim();
                paras[3].Text          = "@FunctionName";
                paras[3].Value         = this.txtFunctionName.Text.Trim();
                paras[4].Text          = "@DeleteBit";
                paras[4].Value         = 0;
                paras[5].Text          = "@ShowToolBar";
                paras[5].Value         = this.chkShowToolbar.Checked ? 1 : 0;
                paras[6].Text          = "@FunctionTag";
                paras[6].Value         = this.txtFunctionTag.Text.Trim();
                paras[7].Text          = "@Jgbm";
                paras[7].Value         = this.cmbJgbm.SelectedValue;
                paras[8].Text          = "@Errmsg";
                paras[8].ParaDirection = ParameterDirection.Output;
                paras[8].ParaSize      = 200;

                paras[9].Text  = "@CanUsePublicPwd";
                paras[9].Value = this.chk_CanUserPublicPwd.Checked ? 1 : 0;
                #endregion

                try
                {
                    //定义多院操作日志 Modify By Tany 2010-01-29
                    ts_HospData_Share.ts_update_log ts = new ts_HospData_Share.ts_update_log();
                    Guid log_djid = Guid.Empty;

                    db.BeginTransaction();

                    db.DoCommand("up_UpdateMenuInfo", paras, 30);

                    if (chkIco.Checked && Convertor.IsNull(picIco.Tag, "") != "")
                    {
                        System.IO.FileStream fs = new System.IO.FileStream(picIco.Tag.ToString(), System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read);
                        byte[] byteIco          = new byte[fs.Length];
                        fs.Read(byteIco, 0, Convert.ToInt32(fs.Length));
                        fs.Close();

                        string     sql = "update pub_menu set icon=@Ico where menu_id=@menuId";
                        IDbCommand cmd = db.GetCommand();
                        cmd.CommandText = sql;
                        cmd.CommandType = CommandType.Text;

                        IDataParameter parameter;
                        parameter = cmd.CreateParameter();
                        parameter.ParameterName = "@Ico";
                        parameter.Value         = byteIco;
                        cmd.Parameters.Add(parameter);

                        parameter = cmd.CreateParameter();
                        parameter.ParameterName = "@menuId";
                        parameter.Value         = m_currentMenuId;
                        cmd.Parameters.Add(parameter);

                        cmd.Transaction = db.GetTransaction();
                        cmd.ExecuteNonQuery();
                    }
                    else
                    {
                        if (picIco.Image != null)
                        {
                            db.DoCommand("update pub_menu set icon=null where menu_id=" + m_currentMenuId);
                        }
                    }

                    //处理多院数据处理,首先插入操作日志 Modify By Tany 2010-01-29
                    string cznr = "修改菜单:【" + txtMenuName.Text.Trim() + "】";
                    ts.Save_log(ts_HospData_Share.czlx.jc_菜单修改, cznr, "pub_menu", "menu_Id", this.m_currentMenuId.ToString(), jgbm, -999, "", out log_djid, db);

                    db.CommitTransaction();

                    try
                    {
                        //查看该类型操作是否属于立即执行 Modify By Tany 2010-01-29
                        string errtext = "";
                        ts_HospData_Share.ts_update_type ty = new ts_HospData_Share.ts_update_type((int)ts_HospData_Share.czlx.jc_菜单修改, db);
                        if (ty.Bzx == 1 && log_djid != Guid.Empty)
                        {
                            //立即执行该操作 Modify By Tany 2010-01-29
                            ts.Pexec_log(log_djid, db, out errtext);
                        }
                        if (errtext != "")
                        {
                            throw new Exception(errtext);
                        }
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show("发生错误:" + err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    return(true);
                }
                catch (Exception err)
                {
                    db.RollbackTransaction();
                    throw err;
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Ejemplo n.º 20
0
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            if (cmbCode.Text.Trim() == "")
            {
                MessageBox.Show("用户名不能为空!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //定义多院操作日志 Modify By Tany 2010-01-25
            ts_HospData_Share.ts_update_log ts = new ts_HospData_Share.ts_update_log();
            Guid log_djid = Guid.Empty;

            try
            {
                string sql = "";
                db.BeginTransaction();
                int userId = 0;
                if (UserExists() && cmbCode.SelectedValue != null && Convert.ToInt32(cmbCode.SelectedValue) != -1)
                {
                    //更新用户
                    sql = "update pub_user set locked_bit = " + (this.chkLock.Checked ? "1" : "0") + " where id=" + cmbCode.SelectedValue.ToString();//employee_id=" + employee.EmployeeId;
                    db.DoCommand(sql);
                    userId = Convert.ToInt32(this.cmbCode.SelectedValue);
                }
                else
                {
                    //添加用户
                    sql = "insert into pub_user (employee_id,code,password) values (" + employee.EmployeeId + ",'" + cmbCode.Text.Trim() + "','')";
                    object obj;
                    db.InsertRecord(sql, out obj);
                    userId = Convert.ToInt32(obj);
                }
                //分配组
                sql = "delete from pub_group_user where user_id =" + userId;
                db.DoCommand(sql);
                for (int i = 0; i < this.cklstGroup.Items.Count; i++)
                {
                    if (this.cklstGroup.GetItemChecked(i))
                    {
                        int groupId = Convert.ToInt32(((TrasenFrame.Classes.CheckListBoxItem)cklstGroup.Items[i]).ItemId.ToString());

                        sql = "insert into pub_group_user (group_id,user_id,delete_bit) values (" + groupId + "," + userId + ",0)";
                        db.DoCommand(sql);
                    }
                }

                //处理多院数据处理,首先插入操作日志 Modify By Tany 2010-01-25
                string cznr = "修改用户信息:【" + txtName.Text.Trim() + "】";
                ts.Save_log(ts_HospData_Share.czlx.jc_用户修改, cznr, "pub_user", "id", userId.ToString(), jgbm, -999, "", out log_djid, db);

                db.CommitTransaction();

                try
                {
                    //查看该类型操作是否属于立即执行 Modify By Tany 2010-01-25
                    string errtext = "";
                    ts_HospData_Share.ts_update_type ty = new ts_HospData_Share.ts_update_type((int)ts_HospData_Share.czlx.jc_用户修改, db);
                    if (ty.Bzx == 1 && log_djid != Guid.Empty)
                    {
                        //立即执行该操作 Modify By Tany 2010-01-25
                        ts.Pexec_log(log_djid, db, out errtext);
                    }
                    if (errtext != "")
                    {
                        throw new Exception(errtext);
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show("发生错误:" + err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                MessageBox.Show("保存成功!");

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception err)
            {
                db.RollbackTransaction();
                MessageBox.Show(err.Message);
            }
            //}
        }
Ejemplo n.º 21
0
        public static string SaveMzcf(DataSet dset, RelationalDatabase db)
        {
            RelationalDatabase old_db = DAL.BaseDal.GetDb_InFormix();

            try
            {
                db.BeginTransaction();
                DataTable tb        = dset.Tables["examReqInfoType"];
                string    ssql      = "";
                DataRow   row       = tb.Rows[0];
                string    examReqId = row["examReqId"].ToString();
                string    id        = row["id"].ToString();



                List <System.String[]> listInsert;

                ssql = "select * from mz_brjbxxb where id='" + id + "'";
                DataTable tbpatient = old_db.GetDataTable(ssql);
                listInsert = HisFunctions.GetInsertSql("whzxyy_mz_brjbxxb", tbpatient);
                for (int i = 0; i <= listInsert.Count - 1; i++)
                {
                    ssql = "select * from whzxyy_mz_brjbxxb where id='" + id + "'";
                    DataTable tbpa = db.GetDataTable(ssql);
                    if (tbpa.Rows.Count == 0)
                    {
                        db.DoCommand(listInsert[i][0]);
                    }
                }

                ssql = "select * from mz_cfd_zb where djhm='" + examReqId + "'";
                DataTable tb_zb = old_db.GetDataTable(ssql);
                listInsert = HisFunctions.GetInsertSql("whzxyy_mz_cfb_zb", tb_zb);
                for (int i = 0; i <= listInsert.Count - 1; i++)
                {
                    db.DoCommand(listInsert[i][0]);
                }

                ssql = " select  b.* from mz_cfd_zb a inner join mz_cfd_cb b on a.dh=b.dh where djhm='" + examReqId + "'";
                DataTable tb_cb = old_db.GetDataTable(ssql);
                listInsert = HisFunctions.GetInsertSql("whzxyy_mz_cfb_cb", tb_cb);
                for (int i = 0; i <= listInsert.Count - 1; i++)
                {
                    db.DoCommand(listInsert[i][0]);
                }


                ParameterEx[] parameters = new ParameterEx[4];

                string sSql = "SP_WHZXYY_mz_cfb";
                parameters[0].Value         = examReqId;
                parameters[0].Text          = "@jsdjh";
                parameters[1].ParaDirection = ParameterDirection.Output;
                parameters[1].Text          = "@Err_Code";
                parameters[1].ParaSize      = 50;
                parameters[2].ParaDirection = ParameterDirection.Output;
                parameters[2].Text          = "@err_text";
                parameters[2].ParaSize      = 1000;
                parameters[3].Value         = id;
                parameters[3].Text          = "@id";

                db.DoCommand(sSql, parameters, 60);

                int    errocde = Convert.ToInt32(parameters[1].Value);
                string errtext = parameters[2].Value.ToString();
                if (errocde != 0)
                {
                    throw new Exception(errtext);
                }

                db.CommitTransaction();

                System.String[] str = { errocde.ToString(), "保存成功" };
                return(HisFunctions.GetResponseString("SaveMzcf", str));
            }
            catch (Exception err)
            {
                db.RollbackTransaction();
                throw err;
            }
            finally
            {
                old_db.Close();
            }
        }
Ejemplo n.º 22
0
        //<summary>
        //合并打印发票
        //</summary>
        public static void Print(string Smzh, Guid brxxid, string Sfpid, EmptyFP newfp, int emplyeeId, string Dysj, RelationalDatabase _DataBase)
        {
            int    err_code = -1;
            string err_text = "";

            try
            {
                _DataBase.BeginTransaction();
                //更新发票记录的发票号,打印人,打印时间
                string[] Fpid = Sfpid.Replace("'", "").Replace("(", "").Replace(")", "").Split(',');
                for (int i = 0; i < Fpid.Length; i++)
                {
                    mz_sf.UpdateFpdyxx(new Guid(Fpid[i]), newfp.Fph, newfp.Qz, emplyeeId, Dysj, out err_text, _DataBase);
                }

                //更新领用表的当前发票号
                mz_sf.UpdateDqfph(newfp.FplyId, newfp.Fph, newfp.Fph, out err_text, _DataBase);

                UpdateFpdyxx(Smzh, newfp.Fph, newfp.Qz, emplyeeId, Dysj, out err_text, _DataBase);

                _DataBase.CommitTransaction();
            }
            catch (Exception err)
            {
                _DataBase.RollbackTransaction();
                throw new Exception("更新发票打印信息或更新当前发票号出错," + err.Message + "");
            }

            #region 打印发票

            try
            {
                string sDate = DateManager.ServerDateTimeByDBType(_DataBase).ToString();

                string    sql    = @"select * from yy_brxx a where a.brxxid='" + brxxid + "'";
                DataTable brxxTb = _DataBase.GetDataTable(sql);

                sql = @"select sum(isnull(zje,0)) zje,sum(isnull(xjzf,0)) xjzf,sum(isnull(zpzf,0)) zpzf,sum(isnull(ylkzf,0)) ylkzf, 
                                sfsj,sfy from MZ_HTDW_JZ where blh in" + Smzh + "group by sfsj,sfy";
                DataTable htdwjzTb = _DataBase.GetDataTable(sql);

                #region 打印

                PrintClass.OPDInvoice invoice = new PrintClass.OPDInvoice();
                invoice.OtherInfo    = "";
                invoice.HisName      = Constant.HospitalName;
                invoice.PatientName  = brxxTb.Rows[0]["brxm"].ToString();
                invoice.OutPatientNo = Smzh;
                //invoice.DepartmentName = Fun.SeekDeptName(ksdm, _DataBase);
                //invoice.DoctorName = Fun.SeekEmpName(ysdm, _DataBase);
                invoice.InvoiceNo = "电脑票号:" + newfp.Fph; //打印新发票的发票号 modify by wangzhi 201-12-1

                invoice.sfck = "";
                invoice.fyck = "";


                //invoice.TotalMoneyCN = Money.NumToChn(dset.Tables[0].Rows[0]["ZJE"].ToString());
                //invoice.TotalMoneyNum = Convert.ToDecimal(dset.Tables[0].Rows[0]["ZJE"]);

                invoice.Klx = "";
                //invoice.kh = kh;

                SystemCfg cfgsfy = new SystemCfg(3016);
                if (cfgsfy.Config == "1")
                {
                    invoice.Payee = Fun.SeekEmpName(Convert.ToInt32(htdwjzTb.Rows[0]["sfy"].ToString()), _DataBase);//FrmMdiMain.CurrentUser.Name;
                }
                else
                {
                    invoice.Payee = htdwjzTb.Rows[0]["sfy"].ToString();
                }

                DateTime time = Convert.ToDateTime(sDate);
                invoice.Year  = time.Year;
                invoice.Month = time.Month;
                invoice.Day   = time.Day;

                //invoice.Zxks = Fun.SeekDeptName(zxks, _DataBase);
                invoice.OtherInfo = Convert.ToDateTime(sDate).ToString() + "补打";



                invoice.sfsj = Convert.ToDateTime(sDate).ToLongTimeString();

                //获取已收费的发票信息
                DataSet dset = GetFpResult(Sfpid, out err_code, out err_text, _DataBase);

                PrintClass.InvoiceItem[]       item       = null;
                PrintClass.InvoiceItemDetail[] itemdetail = null; // 增加发票明细项目

                DataRow[] rows = dset.Tables[0].Select("");
                item = new PrintClass.InvoiceItem[rows.Length];
                for (int m = 0; m <= rows.Length - 1; m++)
                {
                    item[m].ItemName  = rows[m]["ITEM_NAME"].ToString().Trim();
                    item[m].ItemMoney = Convert.ToDecimal(rows[m]["je"]);//发票项目金额
                }
                invoice.Items = item;

                // 增加发票明细项目
                DataRow[] rowsdetail = dset.Tables[3].Select("");
                itemdetail = new PrintClass.InvoiceItemDetail[rowsdetail.Length];
                for (int m = 0; m <= rowsdetail.Length - 1; m++)
                {
                    itemdetail[m].ItemDetailName = rowsdetail[m]["PM"].ToString().Trim();
                    itemdetail[m].ItemDW         = rowsdetail[m]["DW"].ToString().Trim();
                    itemdetail[m].ItemGG         = rowsdetail[m]["GG"].ToString().Trim();
                    itemdetail[m].ItemJS         = Convert.ToDecimal(rowsdetail[m]["JS"]);
                    itemdetail[m].ItemNum        = Convert.ToDecimal(rowsdetail[m]["SL"]);
                    itemdetail[m].ItemPrice      = Convert.ToDecimal(rowsdetail[m]["DJ"]);
                    itemdetail[m].ItemJE         = Convert.ToDecimal(rowsdetail[m]["JE"]);
                }
                invoice.ItemDetail = itemdetail;

                //if (Bview != "true")
                invoice.Print();
                //else
                //invoice.Preview();

                #endregion
            }
            catch (System.Exception err)
            {
                throw new Exception("打印发票时发生错误:" + err.Message);
            }
            #endregion
        }