/// <summary>
        /// 更新用法
        /// </summary>
        /// <param name="usage"></param>
        public void UpdateUsageItem(UsageItem usage)
        {
            try
            {
                string strWhere = Tables.base_usagediction.ID + oleDb.EuqalTo( ) + usage.ID;

                Base_UsageDiction base_usagediction = BindEntity <Base_UsageDiction> .CreateInstanceDAL(oleDb).GetModel(strWhere);

                if (base_usagediction == null)
                {
                    throw new Exception("无效的用法标识!");
                }
                string old_name = base_usagediction.Name.Trim( );
                base_usagediction.Name       = usage.Name;
                base_usagediction.Py_Code    = usage.Py_Code;
                base_usagediction.Wb_Code    = usage.Wb_Code;
                base_usagediction.D_Code     = "0";
                base_usagediction.Unit       = usage.Unit;
                base_usagediction.Print_Long = usage.PrintLongOrder == true ? 1 : 0;
                base_usagediction.Print_Temp = usage.PrintTempOrder == true ? 1 : 0;
                base_usagediction.Delete_Bit = usage.DeleteBit == true ? 1 : 0;
                BindEntity <Base_UsageDiction> .CreateInstanceDAL(oleDb).Update(base_usagediction);

                UpdateUsageAssociatedItems(usage, old_name);
            }
            catch (Exception err)
            {
                ErrorController.Instance( ).LogEvent(err);
                throw new Exception("保存用法项目发生错误!");
            }
        }
        /// <summary>
        /// 保存执行科室
        /// </summary>
        /// <param name="ItemId"></param>
        /// <param name="ComplexId"></param>
        /// <param name="Depts"></param>
        public void SaveHospitalItemExecDept(int ItemId, int ComplexId, List <Department> Depts)
        {
            string strWhere = Tables.base_item_dept.ITEM_ID + oleDb.EuqalTo( ) + ItemId;

            strWhere += oleDb.And( );
            strWhere += Tables.base_item_dept.COMPLEX_ID + oleDb.EuqalTo( ) + ComplexId;

            oleDb.BeginTransaction( );
            try
            {
                BindEntity <Model.BASE_ITEM_DEPT> .CreateInstanceDAL(oleDb).Delete(strWhere);

                foreach (Department dept in Depts)
                {
                    Model.BASE_ITEM_DEPT base_item_dept = new HIS.Model.BASE_ITEM_DEPT( );
                    base_item_dept.ITEM_ID      = ItemId;
                    base_item_dept.COMPLEX_ID   = ComplexId;
                    base_item_dept.DEPT_ID      = dept.DeptID;
                    base_item_dept.DEFAULT_FLAG = dept.DefaultFlag;
                    BindEntity <Model.BASE_ITEM_DEPT> .CreateInstanceDAL(oleDb).Add(base_item_dept);
                }
                oleDb.CommitTransaction( );
            }
            catch (Exception err)
            {
                oleDb.RollbackTransaction( );
                ErrorController.Instance().LogEvent(err);
                throw err;
            }
        }
        /// <summary>
        /// 更新医嘱项目
        /// </summary>
        /// <param name="order"></param>
        public void UpdateOrderItem(OrderItem order)
        {
            try
            {
                oleDb.BeginTransaction();
                string strWhere = Tables.base_order_items.ORDER_ID + oleDb.EuqalTo() + order.ORDER_ID;

                Base_Order_Items base_order_item = BindEntity <Base_Order_Items> .CreateInstanceDAL(oleDb).GetModel(strWhere);

                if (base_order_item == null)
                {
                    throw new Exception("无效的医嘱标识!");
                }

                base_order_item.Book_Date     = order.BOOK_DATE;
                base_order_item.Bz            = order.BZ;
                base_order_item.D_Code        = order.D_CODE;
                base_order_item.Default_Usage = order.DEFAULT_USAGE;
                base_order_item.Del_Date      = order.DEL_DATE;
                base_order_item.Delete_Bit    = order.DELETE_BIT;
                base_order_item.Item_Id       = order.ITEM_ID;
                if (order.ORDER_TYPE == 7)   //说明类医嘱不关联收费项目
                {
                    base_order_item.Item_Id = 0;
                }

                if (order.MEDICAL_CLASS != 0)
                {
                    base_order_item.Medical_Class = order.MEDICAL_CLASS;
                }
                else
                {
                    base_order_item.Medical_Class = GetMedicalClass(order.ORDER_TYPE);
                }
                base_order_item.Order_Name = order.ORDER_NAME;
                base_order_item.Order_Type = order.ORDER_TYPE;
                base_order_item.Order_Unit = order.ORDER_UNIT;
                base_order_item.Py_Code    = order.PY_CODE;
                base_order_item.Tc_Flag    = order.TC_FLAG;
                base_order_item.Wb_Code    = order.WB_CODE;
                if (order.TC_FLAG == 1)
                {
                    AddComplexDetail(order);
                }
                BindEntity <Base_Order_Items> .CreateInstanceDAL(oleDb).Update(base_order_item);

                oleDb.CommitTransaction();
            }
            catch (Exception err)
            {
                oleDb.RollbackTransaction();
                ErrorController.Instance().LogEvent(err);
                throw new Exception("保存医嘱项目发生错误!");
            }
        }
 /// <summary>
 /// 更新用法联动的费用表(该方法用途为防止直接修改用法名称导致原来的明细丢失)
 /// 因为表结构设计上的缺陷,用用法名称做外键,所以更新前需要判断是否修改过名称
 /// </summary>
 /// <param name="usage"></param>
 /// <param name="oldUsageName">原用法名称</param>
 private void UpdateUsageAssociatedItems(UsageItem usage, string oldUsageName)
 {
     try
     {
         oleDb.BeginTransaction( );
         string strSql = "DELETE FROM BASE_USEAGE_FEE WHERE USE_NAME = '" + oldUsageName + "'";
         oleDb.DoCommand(strSql);
         foreach (LinkageItem item in usage.AssociatedItems)
         {
             strSql  = "INSERT INTO BASE_USEAGE_FEE(USE_NAME,NUM,HSITEM_ID,WORKID)";
             strSql += "VALUES('" + usage.Name + "'," + item.Num + "," + item.ITEM_ID + "," + HIS.SYSTEM.Core.EntityConfig.WorkID + ")";
             oleDb.DoCommand(strSql);
         }
         oleDb.CommitTransaction( );
     }
     catch (Exception err)
     {
         oleDb.RollbackTransaction( );
         ErrorController.Instance( ).LogEvent(err);
         throw new Exception("保存用法对应联动收费项目!");
     }
 }
        /// <summary>
        /// 增加用法
        /// </summary>
        /// <param name="usage"></param>
        public void AddUsageItem(UsageItem usage)
        {
            try
            {
                Base_UsageDiction base_usagediction = new Base_UsageDiction( );
                base_usagediction.Name       = usage.Name;
                base_usagediction.Py_Code    = usage.Py_Code;
                base_usagediction.Wb_Code    = usage.Wb_Code;
                base_usagediction.D_Code     = "0";
                base_usagediction.Unit       = usage.Unit;
                base_usagediction.Print_Long = usage.PrintLongOrder == true ? 1 : 0;
                base_usagediction.Print_Temp = usage.PrintTempOrder == true ? 1 : 0;
                base_usagediction.Delete_Bit = usage.DeleteBit == true ? 1 : 0;
                BindEntity <Base_UsageDiction> .CreateInstanceDAL(oleDb).Add(base_usagediction);

                UpdateUsageAssociatedItems(usage);
            }
            catch (Exception err)
            {
                ErrorController.Instance( ).LogEvent(err);
                throw new Exception("保存用法项目发生错误!");
            }
        }