private static string get(string ParameterName, DataTable DTtParameter = null) { tParameter tpta = new tParameter(); try { if (DTtParameter != null) { DataRow[] DR = DTtParameter.Select("IDParameter = '" + ParameterName + "'"); if (DR.Count() == 1) { return(DR[0]["vchValue"].ToString()); } else { throw new ArgumentException("Parâmetro inexistente ou inacessível"); } } else { tpta.GetDataByID(ParameterName); if (tpta.Count() == 1) { return(tpta.Columns.vchValue); } else { throw new ArgumentException("Parâmetro inexistente ou inacessível"); } } } catch (Exception ex) { throw new Exception("Ocorreu uma excessão no GET {" + ParameterName + "}", ex); } finally { tpta.Dispose(); } }
public static void set(string ParameterName, string ParameterValue, string ParameterType, DataTable DTtParameter = null, bool InsertIfNotFound = false) { tParameter tp = new tParameter(); try { get(ParameterName, DTtParameter); tp.Update(ParameterName, ParameterValue, ParameterType); if (DTtParameter != null) { DataRow[] DR = DTtParameter.Select("IDParameter = '" + ParameterName + "'"); DR[0]["vchValue"] = ParameterType; } } catch (Exception ex) { if (InsertIfNotFound && ex.InnerException != null && ex.InnerException.GetType() == typeof(ArgumentException)) { try { tp.Insert(ParameterName, ParameterValue, ParameterType); } catch (Exception ex2) { throw new Exception("Ocorreu uma excessão no SET {" + ParameterName + "}", ex2); } } else { throw new Exception("Ocorreu uma excessão no SET {" + ParameterName + "}", ex); } } finally { tp.Dispose(); } }
public static tParameter.tParameterTable getAll(string tag) { tParameter tparameter = new tParameter(); try { if (string.IsNullOrEmpty(tag)) { tparameter.GetData(); } else { tparameter.GetDataLike(tag); } return(tparameter.Table); } finally { tparameter.Dispose(); } }