/// <summary>
        /// Method to get one recoder by primary key
        /// </summary>    	 
        public MDLAccountsPermissions GetModel(int PermissionId)
        {
			//Set up a return value
            MDLAccountsPermissions model = null;

            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT [PermissionId], [PermissionName], [PermissionCategoryId], [Sequence] ");
            strSql.Append(" FROM [AccountsPermissions] ");
            strSql.Append(" WHERE [PermissionId]=" + PermissionId.ToString());
            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
            {
                if (sdr.Read())
                    model = new MDLAccountsPermissions(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetInt32(3));
				else
                    model = new MDLAccountsPermissions();                
            }
            return model;
        }
		/// <summary>
        /// Method to get recoders with condition
        /// </summary>    	 
        public IList<MDLAccountsPermissions> GetList()
        {
            IList<MDLAccountsPermissions> list = new List<MDLAccountsPermissions>();

            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT [PermissionId], [PermissionName], [PermissionCategoryId], [Sequence] ");
            strSql.Append(" FROM [AccountsPermissions] ");            

            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
            {
                while (sdr.Read())
                {
                    MDLAccountsPermissions item = new MDLAccountsPermissions(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetInt32(3));
                    list.Add(item);
                }
            }
            return list;
        }
        /// <summary>
        /// Add one record
        /// </summary>
        public int Add(MDLAccountsPermissions model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("INSERT INTO [AccountsPermissions](");
            strSql.Append("[PermissionName],[PermissionCategoryId],[Sequence]");
            strSql.Append(")");
            strSql.Append(" VALUES (");
            strSql.Append("'" + model.PermissionName + "',");
			strSql.Append("" + model.PermissionCategoryId + ",");
			strSql.Append("" + model.Sequence + "");
			strSql.Append(")");
            strSql.Append(";SELECT @@IDENTITY");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 1;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
 /// <summary>
 /// Update one record
 /// </summary>
 public void Update(MDLAccountsPermissions model)
 {
 	dal.Update(model);
 }
 /// <summary>
 /// Add one record
 /// </summary>
 public int Add(MDLAccountsPermissions model)
 {
     return dal.Add(model);
 }
        /// <summary>
        /// Update one record
        /// </summary>
        public void Update(MDLAccountsPermissions model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("UPDATE [AccountsPermissions] SET ");
            strSql.Append("[PermissionName]='" + model.PermissionName + "',");
			strSql.Append("[PermissionCategoryId]=" + model.PermissionCategoryId + ",");
			strSql.Append("[Sequence]=" + model.Sequence + "");
			strSql.Append(" WHERE [PermissionId]=" + model.PermissionId + "");
            DbHelperSQL.ExecuteSql(strSql.ToString());
        }