public static List <string> GetEditRoleList(string docId) { try { using (IDbConnection conn = DbSwitcher.GetOpenConnection()) { List <string> vs = new List <string>(); var lst = conn.GetList <Model.DocRoleCtrl>(new { DocId = docId }).ToList(); if (lst != null && lst.Count > 0) { foreach (var item in lst) { if (!vs.Contains(item.RoleId)) { vs.Add(item.RoleId); } } } return(vs); } } catch (Exception) { } return(new List <string>()); }
public static List <string> GetListByDocId(string docId) { try { using (IDbConnection conn = DbSwitcher.GetOpenConnection()) { List <string> vs = new List <string>(); var lst = conn.GetList <Model.DocUsrRole>(new { DocId = docId }).ToList(); if (lst != null && lst.Count > 0) { foreach (var item in lst) { if (!vs.Contains(item.roleId)) { vs.Add(item.roleId); } } } return(vs); } } catch (Exception ex) { string str = ex.Message; } return(new List <string>()); }
public static bool Delete(string docTypeId, out string strTips) { StringBuilder strSql = new StringBuilder(); strSql.Append("select COUNT(1) from helpdoc where docTypeId=?docTypeId"); using (IDbConnection conn = DbSwitcher.GetOpenConnection()) { DynamicParameters parameters = new DynamicParameters(); parameters.Add("?docTypeId", docTypeId); int.TryParse(conn.ExecuteScalar(strSql.ToString(), parameters)?.ToString(), out int result); if (result > 0) { strTips = ActionService.ResponseMessageTips.MSG_DOCTYPE_HAS_BIND_DOC; return(false); } strSql = new StringBuilder(); strSql.Append("delete from doctypeconfig "); strSql.Append(" where docTypeId=?docTypeId"); int rows = mysql.ExcuteNonQuery <Model.DocTypeConfig>(DapperMySQLHelper.ConnectionString, strSql.ToString(), parameters, false); strTips = rows > 0 ? ActionService.ResponseMessageTips.MSG_DOCTYPE_DELETE_SUCCESS : ActionService.ResponseMessageTips.MSG_DOCTYPE_DELETE_FAIL; return(rows > 0); } }
public static bool Delete(Model.DocRoleCtrl docRoleCtrl) { using (IDbConnection conn = DbSwitcher.GetOpenConnection()) { conn.Delete(docRoleCtrl); } return(false); }
public static List <Model.DocRoleCtrl> Get(string docId) { using (IDbConnection conn = DbSwitcher.GetOpenConnection()) { var lst = conn.GetList <Model.DocRoleCtrl>(new { DocId = docId })?.ToList(); return(lst); } }
public static string GetMaxDeptNumByPreDeptId(string preDeptId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select max(deptNO) from dept where preDeptId=?preDeptId"); //DynamicParameters parameters = new DynamicParameters(); //parameters.Add("?preDeptId", preDeptId); using (IDbConnection conn = DbSwitcher.GetOpenConnection()) { DynamicParameters parameters = new DynamicParameters(); parameters.Add("?preDeptId", preDeptId); return(conn.ExecuteScalar(strSql.ToString(), parameters)?.ToString()); } //return mysql.FindOne<Model.Dept>(DapperMySQLHelper.ConnectionString, strSql.ToString(), parameters, false); }
public static bool Add(List <Model.DocRoleCtrl> docRoleCtrls) { if (docRoleCtrls != null && docRoleCtrls.Count > 0) { Delete(docRoleCtrls); using (IDbConnection conn = DbSwitcher.GetOpenConnection()) { foreach (var item in docRoleCtrls) { if (Get(item.DocId, item.RoleId) == null || Get(item.DocId, item.RoleId).Count == 0) { conn.Insert(item); } } return(true); } } return(false); }
public static bool Delete(List <Model.DocRoleCtrl> docRoleCtrlList) { try { using (IDbConnection conn = DbSwitcher.GetOpenConnection()) { foreach (var item in docRoleCtrlList) { var lst = Get(item.DocId); foreach (var _item in lst) { conn.Delete(_item); } } return(true); } } catch (Exception) { } return(false); }