public string MenuMaxCode(int id) { try { StringBuilder sql = new StringBuilder(); sql.Append("select code from sys_menu where id = :pid; \r\n"); sql.Append("select nvl(max(code)+1,1) as maxcode from SYS_MENU where pid = :pid; \r\n"); using (var conn = new OraDBHelper().Conn) { string code = conn.ExecuteScalar <string>("select code from sys_menu where id = :pid", new { pid = id }); code = code == null ? "" : code; string maxcode = conn.ExecuteScalar <string>("select nvl(max(code),0) as maxcode from SYS_MENU where pid = :pid", new { pid = id }).ToString().PadLeft(2, '0'); string max = ""; if (!string.IsNullOrEmpty(code)) { var len = code.Length; var pos = maxcode.IndexOf(code) + len; max = maxcode.Substring(pos, maxcode.Length - pos); max = (Convert.ToInt32(max) + 1).ToString().PadLeft(2, '0'); } else { max = (Convert.ToInt32(maxcode) + 1).ToString().PadLeft(2, '0'); } return(code + max); } } catch (Exception e) { log.Error(e.Message); throw; } }
/// <summary> /// 点检编号 /// </summary> public string GetDJNo() { try { using (var conn = new OraDBHelper(constr).Conn) { var no = conn.ExecuteScalar <int>("select seq_pointcheck_no.nextval from dual"); return("DJ" + no.ToString().PadLeft(4, '0')); } } catch (Exception e) { log.Error(e.Message); throw; } }
public string GetSkillNo() { try { using (var conn = new OraDBHelper(constr).Conn) { int skillid = conn.ExecuteScalar <int>("SELECT seq_skill_id.nextval FROM dual"); return("JN" + skillid.ToString().PadLeft(4, '0')); } } catch (Exception e) { log.Error(e.Message); throw; } }
public string MaxCode() { try { StringBuilder sql = new StringBuilder(); sql.Append("select LPad(max(code) + 1, 2, '0') as maxcode from Sys_Role"); using (var conn = new OraDBHelper().Conn) { return(conn.ExecuteScalar <string>(sql.ToString())); } } catch (Exception e) { log.Error(e.Message); throw; } }
public bool IsExsitCode(string code) { try { using (var conn = new OraDBHelper().Conn) { int cnt = conn.ExecuteScalar <int>("select count(id) as cnt from sys_user where code=:code", new { code = code }); if (cnt > 0) { return(true); } else { return(false); } } } catch (Exception e) { log.Error(e.Message); throw; } }