/// <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="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("保存用法项目发生错误!"); } }