/// <summary> /// 根据企业编码和主键科目详情 /// </summary> /// <param name="CompanyCD">企业编码</param> /// <param name="ID">主键</param> /// <returns>DataTable</returns> public static DataTable GetAccountsByID(string ID) { string CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD; if (string.IsNullOrEmpty(CompanyCD) && string.IsNullOrEmpty(ID)) { return(null); } try { return(AccountSubjectsDBHelper.GetAccountsByID(CompanyCD, ID)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 删除会计科目 /// </summary> /// <param name="ID">主键编码</param> /// <param name="CompanyCD">公司编码</param> /// <returns>True 成功,false失败</returns> public static string DeleteAccountSubjects(string ID, string SubjectsCode, string CompanyCD) { try { bool isSucc = false; UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"]; string[] sql = null; //sql语句数组 string Execresult = ""; //执行结果 DataTable dt = AccountSubjectsDBHelper.GetAccountsByID(CompanyCD, ID); if (dt != null && dt.Rows.Count > 0) { if (dt.Rows[0]["UsedStatus"].ToString().Trim() == ConstUtil.USED_STATUS_ON) { Execresult = ConstUtil.USED_STATUS_ON; } else { //查找当前科目是否有子节点 int count = AccountSubjectsDBHelper.ChildrenCount(SubjectsCode, CompanyCD); if (count > 0) { sql = new string[2]; sql[0] = "delete from officedba.AccountSubjects where CompanyCD='" + CompanyCD + "' and ID='" + ID + "'"; sql[1] = "delete from officedba.AccountSubjects where CompanyCD='" + CompanyCD + "' and ParentID='" + SubjectsCode + "'"; } else { sql = new string[1]; sql[0] = "delete from officedba.AccountSubjects where CompanyCD='" + CompanyCD + "' and ID='" + ID + "'"; } Execresult = AccountSubjectsDBHelper.DelAccountSubjects(sql) == true ? ConstUtil.EXEC_RESULT_SUCCESS_NAME : ConstUtil.EXEC_RESULT_FAIL_NAME; if (Execresult == ConstUtil.EXEC_RESULT_SUCCESS_NAME) { isSucc = true; } //定义变量 string remark; //成功时 if (isSucc) { //设置操作成功标识 remark = ConstUtil.LOG_PROCESS_SUCCESS; } else { //设置操作成功标识 remark = ConstUtil.LOG_PROCESS_FAILED; } string[] noList = ID.Split(','); for (int i = 0; i < noList.Length; i++) { //获取编号 string no = noList[i]; //替换两边的 ' no = no.Replace("'", string.Empty); //操作日志 LogInfoModel logModel = InitLogInfo(no); //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空 logModel.Element = ConstUtil.LOG_PROCESS_DELETE; //设置操作成功标识 logModel.Remark = remark; //登陆日志 LogDBHelper.InsertLog(logModel); } } } return(Execresult); } catch (Exception ex) { throw ex; } }